diff --git a/libraries/botbuilder/etc/botbuilder.api.md b/libraries/botbuilder/etc/botbuilder.api.md index 1ea97d86c0..30f9cb79de 100644 --- a/libraries/botbuilder/etc/botbuilder.api.md +++ b/libraries/botbuilder/etc/botbuilder.api.md @@ -204,18 +204,18 @@ export abstract class ChannelServiceHandlerBase { handleSendToConversation(authHeader: string, conversationId: string, activity: Activity): Promise; handleUpdateActivity(authHeader: string, conversationId: string, activityId: string, activity: Activity): Promise; handleUploadAttachment(authHeader: string, conversationId: string, attachmentUpload: AttachmentData): Promise; - protected onCreateConversation(claimsIdentity: ClaimsIdentity, parameters: ConversationParameters): Promise; - protected onDeleteActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise; - protected onDeleteConversationMember(claimsIdentity: ClaimsIdentity, conversationId: string, memberId: string): Promise; - protected onGetActivityMembers(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise; - protected onGetConversationMembers(claimsIdentity: ClaimsIdentity, conversationId: string): Promise; - protected onGetConversationPagedMembers(claimsIdentity: ClaimsIdentity, conversationId: string, pageSize?: number, continuationToken?: string): Promise; - protected onGetConversations(claimsIdentity: ClaimsIdentity, conversationId: string, continuationToken?: string): Promise; - protected onReplyToActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise; - protected onSendConversationHistory(claimsIdentity: ClaimsIdentity, conversationId: string, transcript: Transcript): Promise; - protected onSendToConversation(claimsIdentity: ClaimsIdentity, conversationId: string, activity: Activity): Promise; - protected onUpdateActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise; - protected onUploadAttachment(claimsIdentity: ClaimsIdentity, conversationId: string, attachmentUpload: AttachmentData): Promise; + protected onCreateConversation(_claimsIdentity: ClaimsIdentity, _parameters: ConversationParameters): Promise; + protected onDeleteActivity(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string): Promise; + protected onDeleteConversationMember(_claimsIdentity: ClaimsIdentity, _conversationId: string, _memberId: string): Promise; + protected onGetActivityMembers(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string): Promise; + protected onGetConversationMembers(_claimsIdentity: ClaimsIdentity, _conversationId: string): Promise; + protected onGetConversationPagedMembers(_claimsIdentity: ClaimsIdentity, _conversationId: string, _pageSize?: number, _continuationToken?: string): Promise; + protected onGetConversations(_claimsIdentity: ClaimsIdentity, _conversationId: string, _continuationToken?: string): Promise; + protected onReplyToActivity(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string, _activity: Activity): Promise; + protected onSendConversationHistory(_claimsIdentity: ClaimsIdentity, _conversationId: string, _transcript: Transcript): Promise; + protected onSendToConversation(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activity: Activity): Promise; + protected onUpdateActivity(_claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string, _activity: Activity): Promise; + protected onUploadAttachment(_claimsIdentity: ClaimsIdentity, _conversationId: string, _attachmentUpload: AttachmentData): Promise; } // @public @@ -224,7 +224,7 @@ export class ChannelServiceRoutes { register(server: WebServer, basePath?: string): void; } -// @public (undocumented) +// @public export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAdapter { constructor(botFrameworkAuthentication?: BotFrameworkAuthentication); connectNamedPipe(pipeName: string, logic: (context: TurnContext) => Promise, appId: string, audience: string, callerId?: string, retryCount?: number): Promise; @@ -234,7 +234,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd // Warning: (ae-forgotten-export) The symbol "CloudChannelServiceHandler" needs to be exported by the entry point index.d.ts // -// @public (undocumented) +// @public export class CloudSkillHandler extends CloudChannelServiceHandler { constructor(adapter: BotAdapter, logic: (context: TurnContext) => Promise, conversationIdFactory: SkillConversationIdFactoryBase, auth: BotFrameworkAuthentication); protected onDeleteActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise; @@ -281,7 +281,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { // @public export class InspectionState extends BotState { constructor(storage: Storage_2); - protected getStorageKey(turnContext: TurnContext): string; + protected getStorageKey(_turnContext: TurnContext): string; } // @public @@ -356,29 +356,29 @@ export class StreamingHttpClient implements HttpClient { export class TeamsActivityHandler extends ActivityHandler { protected dispatchConversationUpdateActivity(context: TurnContext): Promise; protected dispatchEventActivity(context: TurnContext): Promise; - protected handleAdaptiveCardAction(context: TurnContext): Promise; - protected handleTeamsAppBasedLinkQuery(context: TurnContext, query: AppBasedLinkQuery): Promise; - protected handleTeamsCardActionInvoke(context: TurnContext): Promise; + protected handleAdaptiveCardAction(_context: TurnContext): Promise; + protected handleTeamsAppBasedLinkQuery(_context: TurnContext, _query: AppBasedLinkQuery): Promise; + protected handleTeamsCardActionInvoke(_context: TurnContext): Promise; protected handleTeamsFileConsent(context: TurnContext, fileConsentCardResponse: FileConsentCardResponse): Promise; - protected handleTeamsFileConsentAccept(context: TurnContext, fileConsentCardResponse: FileConsentCardResponse): Promise; - protected handleTeamsFileConsentDecline(context: TurnContext, fileConsentCardResponse: FileConsentCardResponse): Promise; - protected handleTeamsMessagingExtensionBotMessagePreviewEdit(context: TurnContext, action: MessagingExtensionAction): Promise; - protected handleTeamsMessagingExtensionBotMessagePreviewSend(context: TurnContext, action: MessagingExtensionAction): Promise; - protected handleTeamsMessagingExtensionCardButtonClicked(context: TurnContext, cardData: any): Promise; - protected handleTeamsMessagingExtensionConfigurationQuerySettingUrl(context: TurnContext, query: MessagingExtensionQuery): Promise; - protected handleTeamsMessagingExtensionConfigurationSetting(context: TurnContext, settings: any): Promise; - protected handleTeamsMessagingExtensionFetchTask(context: TurnContext, action: MessagingExtensionAction): Promise; - protected handleTeamsMessagingExtensionQuery(context: TurnContext, query: MessagingExtensionQuery): Promise; - protected handleTeamsMessagingExtensionSelectItem(context: TurnContext, query: any): Promise; - protected handleTeamsMessagingExtensionSubmitAction(context: TurnContext, action: MessagingExtensionAction): Promise; + protected handleTeamsFileConsentAccept(_context: TurnContext, _fileConsentCardResponse: FileConsentCardResponse): Promise; + protected handleTeamsFileConsentDecline(_context: TurnContext, _fileConsentCardResponse: FileConsentCardResponse): Promise; + protected handleTeamsMessagingExtensionBotMessagePreviewEdit(_context: TurnContext, _action: MessagingExtensionAction): Promise; + protected handleTeamsMessagingExtensionBotMessagePreviewSend(_context: TurnContext, _action: MessagingExtensionAction): Promise; + protected handleTeamsMessagingExtensionCardButtonClicked(_context: TurnContext, _cardData: any): Promise; + protected handleTeamsMessagingExtensionConfigurationQuerySettingUrl(_context: TurnContext, _query: MessagingExtensionQuery): Promise; + protected handleTeamsMessagingExtensionConfigurationSetting(_context: TurnContext, _settings: any): Promise; + protected handleTeamsMessagingExtensionFetchTask(_context: TurnContext, _action: MessagingExtensionAction): Promise; + protected handleTeamsMessagingExtensionQuery(_context: TurnContext, _query: MessagingExtensionQuery): Promise; + protected handleTeamsMessagingExtensionSelectItem(_context: TurnContext, _query: any): Promise; + protected handleTeamsMessagingExtensionSubmitAction(_context: TurnContext, _action: MessagingExtensionAction): Promise; protected handleTeamsMessagingExtensionSubmitActionDispatch(context: TurnContext, action: MessagingExtensionAction): Promise; - protected handleTeamsO365ConnectorCardAction(context: TurnContext, query: O365ConnectorCardActionQuery): Promise; - protected handleTeamsSigninTokenExchange(context: TurnContext, query: SigninStateVerificationQuery): Promise; - protected handleTeamsSigninVerifyState(context: TurnContext, query: SigninStateVerificationQuery): Promise; - protected handleTeamsTabFetch(context: TurnContext, tabRequest: TabRequest): Promise; - protected handleTeamsTabSubmit(context: TurnContext, tabSubmit: TabSubmit): Promise; - protected handleTeamsTaskModuleFetch(context: TurnContext, taskModuleRequest: TaskModuleRequest): Promise; - protected handleTeamsTaskModuleSubmit(context: TurnContext, taskModuleRequest: TaskModuleRequest): Promise; + protected handleTeamsO365ConnectorCardAction(_context: TurnContext, _query: O365ConnectorCardActionQuery): Promise; + protected handleTeamsSigninTokenExchange(_context: TurnContext, _query: SigninStateVerificationQuery): Promise; + protected handleTeamsSigninVerifyState(_context: TurnContext, _query: SigninStateVerificationQuery): Promise; + protected handleTeamsTabFetch(_context: TurnContext, _tabRequest: TabRequest): Promise; + protected handleTeamsTabSubmit(_context: TurnContext, _tabSubmit: TabSubmit): Promise; + protected handleTeamsTaskModuleFetch(_context: TurnContext, _taskModuleRequest: TaskModuleRequest): Promise; + protected handleTeamsTaskModuleSubmit(_context: TurnContext, _taskModuleRequest: TaskModuleRequest): Promise; protected onInvokeActivity(context: TurnContext): Promise; protected onSignInInvoke(context: TurnContext): Promise; protected onTeamsChannelCreated(context: any): Promise; @@ -387,7 +387,6 @@ export class TeamsActivityHandler extends ActivityHandler { onTeamsChannelDeletedEvent(handler: (channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise): this; protected onTeamsChannelRenamed(context: any): Promise; onTeamsChannelRenamedEvent(handler: (channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise): this; - // (undocumented) protected onTeamsChannelRestored(context: any): Promise; onTeamsChannelRestoredEvent(handler: (channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise): this; protected onTeamsMeetingEnd(context: TurnContext): Promise; diff --git a/libraries/botbuilder/src/activityValidator.ts b/libraries/botbuilder/src/activityValidator.ts index d187967ccb..d6d6c37978 100644 --- a/libraries/botbuilder/src/activityValidator.ts +++ b/libraries/botbuilder/src/activityValidator.ts @@ -10,15 +10,16 @@ import { Activity, ActivityTimestamps } from 'botbuilder-core'; /** * Validates an [Activity](xref:botbuilder-core.Activity) and formats the timestamp fields. + * * @param activity [Activity](xref:botbuilder-core.Activity) to be validated. * @returns The [Activity](xref:botframework-schema.Activity). */ export function validateAndFixActivity(activity: Activity): Activity { if (typeof activity !== 'object') { - throw new Error(`validateAndFixActivity(): invalid request body.`); + throw new Error('validateAndFixActivity(): invalid request body.'); } if (typeof activity.type !== 'string') { - throw new Error(`validateAndFixActivity(): missing activity type.`); + throw new Error('validateAndFixActivity(): missing activity type.'); } if (typeof activity.timestamp === 'string') { (activity as ActivityTimestamps).rawTimestamp = activity.timestamp; diff --git a/libraries/botbuilder/src/botFrameworkAdapter.ts b/libraries/botbuilder/src/botFrameworkAdapter.ts index a38b00c7cb..308a385d04 100644 --- a/libraries/botbuilder/src/botFrameworkAdapter.ts +++ b/libraries/botbuilder/src/botFrameworkAdapter.ts @@ -306,6 +306,8 @@ export class BotFrameworkAdapter /** * Used in streaming contexts to check if the streaming connection is still open for the bot to send activities. + * + * @returns True if the streaming connection is open, otherwise false. */ public get isStreamingConnectionOpen(): boolean { return this.streamingServer?.isConnected ?? false; @@ -501,7 +503,7 @@ export class BotFrameworkAdapter maybeLogic?: (context: TurnContext) => Promise ): Promise { if (!reference.serviceUrl) { - throw new Error(`BotFrameworkAdapter.createConversation(): missing serviceUrl.`); + throw new Error('BotFrameworkAdapter.createConversation(): missing serviceUrl.'); } const parameters = LogicT.check(parametersOrLogic) ? {} : parametersOrLogic; @@ -576,13 +578,13 @@ export class BotFrameworkAdapter */ public async deleteActivity(context: TurnContext, reference: Partial): Promise { if (!reference.serviceUrl) { - throw new Error(`BotFrameworkAdapter.deleteActivity(): missing serviceUrl`); + throw new Error('BotFrameworkAdapter.deleteActivity(): missing serviceUrl'); } if (!reference.conversation || !reference.conversation.id) { - throw new Error(`BotFrameworkAdapter.deleteActivity(): missing conversation or conversation.id`); + throw new Error('BotFrameworkAdapter.deleteActivity(): missing conversation or conversation.id'); } if (!reference.activityId) { - throw new Error(`BotFrameworkAdapter.deleteActivity(): missing activityId`); + throw new Error('BotFrameworkAdapter.deleteActivity(): missing activityId'); } const client: ConnectorClient = this.getOrCreateConnectorClient( context, @@ -605,10 +607,10 @@ export class BotFrameworkAdapter */ public async deleteConversationMember(context: TurnContext, memberId: string): Promise { if (!context.activity.serviceUrl) { - throw new Error(`BotFrameworkAdapter.deleteConversationMember(): missing serviceUrl`); + throw new Error('BotFrameworkAdapter.deleteConversationMember(): missing serviceUrl'); } if (!context.activity.conversation || !context.activity.conversation.id) { - throw new Error(`BotFrameworkAdapter.deleteConversationMember(): missing conversation or conversation.id`); + throw new Error('BotFrameworkAdapter.deleteConversationMember(): missing conversation or conversation.id'); } const serviceUrl: string = context.activity.serviceUrl; const conversationId: string = context.activity.conversation.id; @@ -637,14 +639,14 @@ export class BotFrameworkAdapter activityId = context.activity.id; } if (!context.activity.serviceUrl) { - throw new Error(`BotFrameworkAdapter.getActivityMembers(): missing serviceUrl`); + throw new Error('BotFrameworkAdapter.getActivityMembers(): missing serviceUrl'); } if (!context.activity.conversation || !context.activity.conversation.id) { - throw new Error(`BotFrameworkAdapter.getActivityMembers(): missing conversation or conversation.id`); + throw new Error('BotFrameworkAdapter.getActivityMembers(): missing conversation or conversation.id'); } if (!activityId) { throw new Error( - `BotFrameworkAdapter.getActivityMembers(): missing both activityId and context.activity.id` + 'BotFrameworkAdapter.getActivityMembers(): missing both activityId and context.activity.id' ); } const serviceUrl: string = context.activity.serviceUrl; @@ -671,10 +673,10 @@ export class BotFrameworkAdapter */ public async getConversationMembers(context: TurnContext): Promise { if (!context.activity.serviceUrl) { - throw new Error(`BotFrameworkAdapter.getConversationMembers(): missing serviceUrl`); + throw new Error('BotFrameworkAdapter.getConversationMembers(): missing serviceUrl'); } if (!context.activity.conversation || !context.activity.conversation.id) { - throw new Error(`BotFrameworkAdapter.getConversationMembers(): missing conversation or conversation.id`); + throw new Error('BotFrameworkAdapter.getConversationMembers(): missing conversation or conversation.id'); } const serviceUrl: string = context.activity.serviceUrl; const conversationId: string = context.activity.conversation.id; @@ -743,6 +745,7 @@ export class BotFrameworkAdapter ): Promise; /** * Asynchronously attempts to retrieve the token for a user that's in a login flow. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for the turn. * @param connectionName The name of the auth connection to use. * @param magicCode Optional. The validation code the user entered. @@ -757,7 +760,7 @@ export class BotFrameworkAdapter oAuthAppCredentials?: AppCredentials ): Promise { if (!context.activity.from || !context.activity.from.id) { - throw new Error(`BotFrameworkAdapter.getUserToken(): missing from or from.id`); + throw new Error('BotFrameworkAdapter.getUserToken(): missing from or from.id'); } if (!connectionName) { throw new Error('getUserToken() requires a connectionName but none was provided.'); @@ -810,7 +813,7 @@ export class BotFrameworkAdapter oAuthAppCredentials?: AppCredentials ): Promise { if (!context.activity.from || !context.activity.from.id) { - throw new Error(`BotFrameworkAdapter.signOutUser(): missing from or from.id`); + throw new Error('BotFrameworkAdapter.signOutUser(): missing from or from.id'); } if (!userId) { userId = context.activity.from.id; @@ -871,7 +874,7 @@ export class BotFrameworkAdapter ): Promise { if (userId && userId != context.activity.from.id) { throw new ReferenceError( - `cannot retrieve OAuth signin link for a user that's different from the conversation` + "cannot retrieve OAuth signin link for a user that's different from the conversation" ); } @@ -931,7 +934,7 @@ export class BotFrameworkAdapter oAuthAppCredentials?: AppCredentials ): Promise { if (!userId && (!context.activity.from || !context.activity.from.id)) { - throw new Error(`BotFrameworkAdapter.getTokenStatus(): missing from or from.id`); + throw new Error('BotFrameworkAdapter.getTokenStatus(): missing from or from.id'); } this.checkEmulatingOAuthCards(context); userId = userId || context.activity.from.id; @@ -985,7 +988,7 @@ export class BotFrameworkAdapter oAuthAppCredentials?: AppCredentials ): Promise<{ [propertyName: string]: TokenResponse }> { if (!context.activity.from || !context.activity.from.id) { - throw new Error(`BotFrameworkAdapter.getAadTokens(): missing from or from.id`); + throw new Error('BotFrameworkAdapter.getAadTokens(): missing from or from.id'); } this.checkEmulatingOAuthCards(context); const userId: string = context.activity.from.id; @@ -1010,7 +1013,7 @@ export class BotFrameworkAdapter * @param connectionName The name of the auth connection to use. * @param userId The user id that will be associated with the token. * @param finalRedirect The final URL that the OAuth flow will redirect to. - * + * @param appCredentials Optional. The CoreAppCredentials for OAuth. * @returns The [BotSignInGetSignInResourceResponse](xref:botframework-connector.BotSignInGetSignInResourceResponse) object. */ public async getSignInResource( @@ -1025,7 +1028,7 @@ export class BotFrameworkAdapter } if (!context.activity.from || !context.activity.from.id) { - throw new Error(`BotFrameworkAdapter.getSignInResource(): missing from or from.id`); + throw new Error('BotFrameworkAdapter.getSignInResource(): missing from or from.id'); } // The provided userId doesn't match the from.id on the activity. (same for finalRedirect) @@ -1054,6 +1057,7 @@ export class BotFrameworkAdapter /** * Asynchronously Performs a token exchange operation such as for single sign-on. + * * @param context Context for the current turn of conversation with the user. * @param connectionName Name of the auth connection to use. * @param userId The user id that will be associated with the token. @@ -1069,6 +1073,7 @@ export class BotFrameworkAdapter ): Promise; /** * Asynchronously Performs a token exchange operation such as for single sign-on. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for the turn. * @param connectionName Name of the auth connection to use. * @param userId The user id that will be associated with the token. @@ -1311,7 +1316,7 @@ export class BotFrameworkAdapter if (processError && (processError as Error).stack) { throw new Error(`BotFrameworkAdapter.processActivityDirect(): ERROR\n ${processError.stack}`); } else { - throw new Error(`BotFrameworkAdapter.processActivityDirect(): ERROR`); + throw new Error('BotFrameworkAdapter.processActivityDirect(): ERROR'); } } } @@ -1347,12 +1352,12 @@ export class BotFrameworkAdapter context.turnState.set(INVOKE_RESPONSE_KEY, activity); responses.push({} as ResourceResponse); break; - default: + default: { if (!activity.serviceUrl) { - throw new Error(`BotFrameworkAdapter.sendActivity(): missing serviceUrl.`); + throw new Error('BotFrameworkAdapter.sendActivity(): missing serviceUrl.'); } if (!activity.conversation || !activity.conversation.id) { - throw new Error(`BotFrameworkAdapter.sendActivity(): missing conversation id.`); + throw new Error('BotFrameworkAdapter.sendActivity(): missing conversation id.'); } if (activity && BotFrameworkAdapter.isStreamingServiceUrl(activity.serviceUrl)) { if (!this.isStreamingConnectionOpen) { @@ -1380,6 +1385,7 @@ export class BotFrameworkAdapter ); } break; + } } } return responses; @@ -1394,19 +1400,19 @@ export class BotFrameworkAdapter * * @param context The context object for the turn. * @param activity The updated version of the activity to replace. - * + * @returns A `Promise` representing the [ResourceResponse](xref:botframework-schema.ResourceResponse) for the operation. * @remarks * Not all channels support this operation. For channels that don't, this call may throw an exception. */ public async updateActivity(context: TurnContext, activity: Partial): Promise { if (!activity.serviceUrl) { - throw new Error(`BotFrameworkAdapter.updateActivity(): missing serviceUrl`); + throw new Error('BotFrameworkAdapter.updateActivity(): missing serviceUrl'); } if (!activity.conversation || !activity.conversation.id) { - throw new Error(`BotFrameworkAdapter.updateActivity(): missing conversation or conversation.id`); + throw new Error('BotFrameworkAdapter.updateActivity(): missing conversation or conversation.id'); } if (!activity.id) { - throw new Error(`BotFrameworkAdapter.updateActivity(): missing activity.id`); + throw new Error('BotFrameworkAdapter.updateActivity(): missing activity.id'); } const client = this.getOrCreateConnectorClient(context, activity.serviceUrl, this.credentials); @@ -1417,7 +1423,7 @@ export class BotFrameworkAdapter * Creates a connector client. * * @param serviceUrl The client's service URL. - * + * @returns The [ConnectorClient](xref:botbuilder-connector.ConnectorClient) instance. * @remarks * Override this in a derived class to create a mock connector client for unit testing. */ @@ -1427,6 +1433,7 @@ export class BotFrameworkAdapter /** * Create a ConnectorClient with a ClaimsIdentity. + * * @remarks * If the ClaimsIdentity contains the claims for a Skills request, create a ConnectorClient for use with Skills. * Derives the correct audience from the ClaimsIdentity, or the instance's credentials property. @@ -1439,6 +1446,7 @@ export class BotFrameworkAdapter ): Promise; /** * Create a ConnectorClient with a ClaimsIdentity and an explicit audience. + * * @remarks * If the trimmed audience is not a non-zero length string, the audience will be derived from the ClaimsIdentity or * the instance's credentials property. @@ -1453,6 +1461,7 @@ export class BotFrameworkAdapter ): Promise; /** * Create a [ConnectorClient](xref:botbuilder-connector.ConnectorClient) with a [ClaimsIdentity](xref:botbuilder-connector.ClaimsIdentity). + * * @remarks * If the [ClaimsIdentity](xref:botbuilder-connector.ClaimsIdentity) contains the claims for a Skills request, create a [ConnectorClient](xref:botbuilder-connector.ConnectorClient) for use with Skills. * Derives the correct audience from the [ClaimsIdentity](xref:botbuilder-connector.ClaimsIdentity), or the instance's credentials property. @@ -1515,14 +1524,14 @@ export class BotFrameworkAdapter }); const acceptHeader: RequestPolicyFactory = { - create:(nextPolicy) => ({ - sendRequest: (httpRequest)=>{ - if(!httpRequest.headers.contains('accept')) { + create: (nextPolicy) => ({ + sendRequest: (httpRequest) => { + if (!httpRequest.headers.contains('accept')) { httpRequest.headers.set('accept', '*/*'); } return nextPolicy.sendRequest(httpRequest); - } - }) + }, + }), }; // Resolve any user request policy factories, then include our user agent via a factory policy @@ -1575,6 +1584,7 @@ export class BotFrameworkAdapter /** * Returns the correct [OAuthScope](xref:botframework-connector.AppCredentials.OAuthScope) for [AppCredentials](xref:botframework-connector.AppCredentials). + * * @param botAppId The bot's AppId. * @param claims The [Claim](xref:botbuilder-connector.Claim) list to check. * @@ -1595,8 +1605,9 @@ export class BotFrameworkAdapter * * @remarks * When building credentials for bot-to-bot communication, oAuthScope must be passed in. - * @param appId - * @param oAuthScope + * @param appId The application id. + * @param oAuthScope The optional OAuth scope. + * @returns The app credentials to be used to acquire tokens. */ protected async buildCredentials(appId: string, oAuthScope?: string): Promise { // There is no cache for AppCredentials in JS as opposed to C#. @@ -1652,6 +1663,7 @@ export class BotFrameworkAdapter /** * Allows for the overriding of authentication in unit tests. + * * @param request Received request. * @param authHeader Received authentication header. */ @@ -1688,7 +1700,9 @@ export class BotFrameworkAdapter /** * Generates the CallerId property for the activity based on * https://github.com/microsoft/botframework-obi/blob/main/protocols/botframework-activity/botframework-activity.md#appendix-v---caller-id-values. - * @param identity + * + * @param identity The inbound claims. + * @returns {Promise} a promise representing the generated callerId. */ private async generateCallerId(identity: ClaimsIdentity): Promise { if (!identity) { @@ -1728,7 +1742,7 @@ export class BotFrameworkAdapter * a [TurnContext](xref:botbuilder-core.TurnContext). For a turn context, the context's * [activity](xref:botbuilder-core.TurnContext.activity).[serviceUrl](xref:botframework-schema.Activity.serviceUrl) * is used for the URL. - * + * @returns The endpoint used for the API requests. * @remarks * Override this in a derived class to create a mock OAuth API endpoint for unit testing. */ @@ -1762,7 +1776,7 @@ export class BotFrameworkAdapter * Creates a turn context. * * @param request An incoming request body. - * + * @returns A new [TurnContext](xref:botbuilder-core.TurnContext) instance. * @remarks * Override this in a derived class to modify how the adapter creates a turn context. */ @@ -1773,6 +1787,7 @@ export class BotFrameworkAdapter /** * Checks the validity of the request and attempts to map it the correct virtual endpoint, * then generates and returns a response if appropriate. + * * @param request A ReceiveRequest from the connected channel. * @returns A response created by the BotAdapter to be sent to the client that originated the request. */ @@ -1781,7 +1796,7 @@ export class BotFrameworkAdapter if (!request) { response.statusCode = StatusCodes.BAD_REQUEST; - response.setBody(`No request provided.`); + response.setBody('No request provided.'); return response; } @@ -1934,7 +1949,7 @@ export class BotFrameworkAdapter // Each BotFrameworkAdapter instance is scoped to a stream, so switching streams // results in dropped conversations that the bot cannot reconnect to. throw new Error( - `This BotFrameworkAdapter instance is already connected to a different stream. Use a new instance to connect to the provided pipeName.` + 'This BotFrameworkAdapter instance is already connected to a different stream. Use a new instance to connect to the provided pipeName.' ); } } @@ -2014,6 +2029,7 @@ export class BotFrameworkAdapter /** * Connects the handler to a WebSocket server and begins listening for incoming requests. + * * @param socket The socket to use when creating the server. */ private async startWebSocket(socket: ISocket): Promise { @@ -2030,9 +2046,10 @@ export class BotFrameworkAdapter attachmentStreams.map(async (attachmentStream) => { const contentType = attachmentStream.contentType; - const content = contentType === 'application/json' - ? await attachmentStream.readAsJson() - : await attachmentStream.readAsString(); + const content = + contentType === 'application/json' + ? await attachmentStream.readAsJson() + : await attachmentStream.readAsString(); return { contentType, content }; }) @@ -2082,7 +2099,9 @@ export class BotFrameworkAdapter * This can be determined by looking at the ServiceUrl property: * (1) All channels that send messages via http/https are not streaming * (2) Channels that send messages via streaming have a ServiceUrl that does not begin with http/https. + * * @param serviceUrl the serviceUrl provided in the resquest. + * @returns True if the serviceUrl is a streaming url, otherwise false. */ private static isStreamingServiceUrl(serviceUrl: string): boolean { return serviceUrl && !serviceUrl.toLowerCase().startsWith('http'); @@ -2129,7 +2148,7 @@ function parseRequest(req: WebRequest): Promise { */ function abortWebSocketUpgrade(socket: INodeSocket, err: any): void { if (socket.writable) { - const connectionHeader = `Connection: 'close'\r\n`; + const connectionHeader = "Connection: 'close'\r\n"; let message = ''; AuthenticationError.isStatusCodeError(err) diff --git a/libraries/botbuilder/src/botFrameworkHttpClient.ts b/libraries/botbuilder/src/botFrameworkHttpClient.ts index 2520fca5b7..fe7da41e30 100644 --- a/libraries/botbuilder/src/botFrameworkHttpClient.ts +++ b/libraries/botbuilder/src/botFrameworkHttpClient.ts @@ -36,6 +36,7 @@ export class BotFrameworkHttpClient implements BotFrameworkClient { /** * Creates a new instance of the [BotFrameworkHttpClient](xref:botbuilder.BotFrameworkHttpClient) class + * * @param credentialProvider An instance of [ICredentialProvider](xref:botframework-connector.ICredentialProvider). * @param channelService Optional. The channel service. */ @@ -50,8 +51,8 @@ export class BotFrameworkHttpClient implements BotFrameworkClient { /** * Forwards an activity to another bot. - * @remarks * + * @remarks * @template T The type of body in the InvokeResponse. * @param fromBotId The MicrosoftAppId of the bot sending the activity. * @param toBotId The MicrosoftAppId of the bot receiving the activity. @@ -59,6 +60,7 @@ export class BotFrameworkHttpClient implements BotFrameworkClient { * @param serviceUrl The callback Url for the skill host. * @param conversationId A conversation ID to use for the conversation with the skill. * @param activity Activity to forward. + * @returns {Promise>} A promise representing the asynchronous operation. */ public async postActivity( fromBotId: string, @@ -146,9 +148,10 @@ export class BotFrameworkHttpClient implements BotFrameworkClient { /** * Logic to build an [AppCredentials](xref:botframework-connector.AppCredentials) to be used to acquire tokens for this `HttpClient`. + * * @param appId The application id. * @param oAuthScope Optional. The OAuth scope. - * + * * @returns The app credentials to be used to acquire tokens. */ protected async buildCredentials(appId: string, oAuthScope?: string): Promise { diff --git a/libraries/botbuilder/src/channelServiceHandlerBase.ts b/libraries/botbuilder/src/channelServiceHandlerBase.ts index 0592a1b54f..bebf920fa0 100644 --- a/libraries/botbuilder/src/channelServiceHandlerBase.ts +++ b/libraries/botbuilder/src/channelServiceHandlerBase.ts @@ -236,14 +236,14 @@ export abstract class ChannelServiceHandlerBase { * conversation. * * Use SendToConversation in all other cases. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation identifier - * @param activity Activity to send + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation identifier + * @param _activity Activity to send */ protected async onSendToConversation( - claimsIdentity: ClaimsIdentity, - conversationId: string, - activity: Activity + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _activity: Activity ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -270,16 +270,16 @@ export abstract class ChannelServiceHandlerBase { * conversation. * * Use SendToConversation in all other cases. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param activityId activityId the reply is to (OPTIONAL). - * @param activity Activity to send. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _activityId activityId the reply is to (OPTIONAL). + * @param _activity Activity to send. */ protected async onReplyToActivity( - claimsIdentity: ClaimsIdentity, - conversationId: string, - activityId: string, - activity: Activity + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _activityId: string, + _activity: Activity ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -291,6 +291,7 @@ export abstract class ChannelServiceHandlerBase { /** * UpdateActivity() API for Skill. + * * @remarks * Edit an existing activity. * @@ -298,16 +299,16 @@ export abstract class ChannelServiceHandlerBase { * state of a bot conversation. * * For example, you can remove buttons after someone has clicked "Approve" button. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param activityId activityId to update. - * @param activity replacement Activity. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _activityId activityId to update. + * @param _activity replacement Activity. */ protected async onUpdateActivity( - claimsIdentity: ClaimsIdentity, - conversationId: string, - activityId: string, - activity: Activity + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _activityId: string, + _activity: Activity ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -327,14 +328,14 @@ export abstract class ChannelServiceHandlerBase { * this method will remove the specified activity. * * - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param activityId activityId to delete. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _activityId activityId to delete. */ protected async onDeleteActivity( - claimsIdentity: ClaimsIdentity, - conversationId: string, - activityId: string + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _activityId: string ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -353,14 +354,14 @@ export abstract class ChannelServiceHandlerBase { * This REST API takes a ConversationId and a ActivityId, returning an array * of ChannelAccount objects representing the members of the particular * activity in the conversation. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param activityId Activity ID. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _activityId Activity ID. */ protected async onGetActivityMembers( - claimsIdentity: ClaimsIdentity, - conversationId: string, - activityId: string + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _activityId: string ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -387,12 +388,12 @@ export abstract class ChannelServiceHandlerBase { * Most channels only support the semantics of bots initiating a direct * message conversation. * - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param parameters Parameters to create the conversation from. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _parameters Parameters to create the conversation from. */ protected async onCreateConversation( - claimsIdentity: ClaimsIdentity, - parameters: ConversationParameters + _claimsIdentity: ClaimsIdentity, + _parameters: ConversationParameters ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -418,14 +419,14 @@ export abstract class ChannelServiceHandlerBase { * Each ConversationMembers object contains the ID of the conversation and an * array of ChannelAccounts that describe the members of the conversation. * - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param continuationToken Skip or continuation token. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _continuationToken Skip or continuation token. */ protected async onGetConversations( - claimsIdentity: ClaimsIdentity, - conversationId: string, - continuationToken?: string + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _continuationToken?: string ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -443,12 +444,12 @@ export abstract class ChannelServiceHandlerBase { * * This REST API takes a ConversationId and returns an array of ChannelAccount * objects representing the members of the conversation. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. */ protected async onGetConversationMembers( - claimsIdentity: ClaimsIdentity, - conversationId: string + _claimsIdentity: ClaimsIdentity, + _conversationId: string ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -479,16 +480,16 @@ export abstract class ChannelServiceHandlerBase { * * A response to a request that has a continuation token from a prior request * may rarely return members from a previous request. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param pageSize Suggested page size. - * @param continuationToken Continuation Token. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _pageSize Suggested page size. + * @param _continuationToken Continuation Token. */ protected async onGetConversationPagedMembers( - claimsIdentity: ClaimsIdentity, - conversationId: string, - pageSize = -1, - continuationToken?: string + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _pageSize = -1, + _continuationToken?: string ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -500,20 +501,21 @@ export abstract class ChannelServiceHandlerBase { /** * DeleteConversationMember() API for Skill. + * * @remarks * Deletes a member from a conversation. * * This REST API takes a ConversationId and a memberId (of type string) and * removes that member from the conversation. If that member was the last member * of the conversation, the conversation will also be deleted. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param memberId ID of the member to delete from this conversation. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _memberId ID of the member to delete from this conversation. */ protected async onDeleteConversationMember( - claimsIdentity: ClaimsIdentity, - conversationId: string, - memberId: string + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _memberId: string ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -525,6 +527,7 @@ export abstract class ChannelServiceHandlerBase { /** * SendConversationHistory() API for Skill. + * * @remarks * This method allows you to upload the historic activities to the * conversation. @@ -533,14 +536,14 @@ export abstract class ChannelServiceHandlerBase { * appropriate timestamps. The ids are used by the client to deal with * duplicate activities and the timestamps are used by the client to render * the activities in the right order. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param transcript Transcript of activities. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _transcript Transcript of activities. */ protected async onSendConversationHistory( - claimsIdentity: ClaimsIdentity, - conversationId: string, - transcript: Transcript + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _transcript: Transcript ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, @@ -552,6 +555,7 @@ export abstract class ChannelServiceHandlerBase { /** * UploadAttachment() API for Skill. + * * @remarks * Upload an attachment directly into a channel's blob storage. * @@ -560,14 +564,14 @@ export abstract class ChannelServiceHandlerBase { * * The response is a ResourceResponse which contains an AttachmentId which is * suitable for using with the attachments API. - * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. - * @param conversationId Conversation ID. - * @param attachmentUpload Attachment data. + * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. + * @param _conversationId Conversation ID. + * @param _attachmentUpload Attachment data. */ protected async onUploadAttachment( - claimsIdentity: ClaimsIdentity, - conversationId: string, - attachmentUpload: AttachmentData + _claimsIdentity: ClaimsIdentity, + _conversationId: string, + _attachmentUpload: AttachmentData ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, diff --git a/libraries/botbuilder/src/channelServiceRoutes.ts b/libraries/botbuilder/src/channelServiceRoutes.ts index 252a01b20b..8f8c8f2155 100644 --- a/libraries/botbuilder/src/channelServiceRoutes.ts +++ b/libraries/botbuilder/src/channelServiceRoutes.ts @@ -37,12 +37,13 @@ export interface WebServer { */ export class ChannelServiceRoutes { /** - * @param channelServiceHandler + * @param channelServiceHandler The channel service handler. */ constructor(private readonly channelServiceHandler: ChannelServiceHandlerBase) {} /** * Registers all Channel Service paths on the provided WebServer. + * * @param server WebServer * @param basePath Optional basePath which is appended before the service's REST API is configured on the WebServer. */ @@ -279,7 +280,7 @@ export class ChannelServiceRoutes { const authHeader = req.headers.authorization || req.headers.Authorization || ''; this.channelServiceHandler .handleDeleteConversationMember(authHeader, req.params.conversationId, req.params.memberId) - .then((resourceResponse) => { + .then(() => { res.status(200); res.end(); }) diff --git a/libraries/botbuilder/src/cloudAdapter.ts b/libraries/botbuilder/src/cloudAdapter.ts index d5b0fcf286..36af7138d5 100644 --- a/libraries/botbuilder/src/cloudAdapter.ts +++ b/libraries/botbuilder/src/cloudAdapter.ts @@ -40,6 +40,9 @@ import { // Note: this is _okay_ because we pass the result through `validateAndFixActivity`. Should not be used otherwise. const ActivityT = z.custom((val) => z.record(z.unknown()).check(val), { message: 'Activity' }); +/** + * An adapter that implements the Bot Framework Protocol and can be hosted in different cloud environmens both public and private. + */ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAdapter { /** * Initializes a new instance of the [CloudAdapter](xref:botbuilder:CloudAdapter) class. diff --git a/libraries/botbuilder/src/cloudChannelServiceHandler.ts b/libraries/botbuilder/src/cloudChannelServiceHandler.ts index 14b3b152d2..a019512c40 100644 --- a/libraries/botbuilder/src/cloudChannelServiceHandler.ts +++ b/libraries/botbuilder/src/cloudChannelServiceHandler.ts @@ -4,7 +4,13 @@ import { BotFrameworkAuthentication, ClaimsIdentity } from 'botframework-connector'; import { ChannelServiceHandlerBase } from './channelServiceHandlerBase'; +/** + * A class to help with the implementation of the Bot Framework protocol using [BotFrameworkAuthentication](xref:botframework-connector.BotFrameworkAuthentication). + */ export class CloudChannelServiceHandler extends ChannelServiceHandlerBase { + /** + * @param auth Bot framework authentication + */ constructor(private readonly auth: BotFrameworkAuthentication) { super(); } diff --git a/libraries/botbuilder/src/eventFactory.ts b/libraries/botbuilder/src/eventFactory.ts index 7174b21e92..941aaaa27a 100644 --- a/libraries/botbuilder/src/eventFactory.ts +++ b/libraries/botbuilder/src/eventFactory.ts @@ -4,7 +4,15 @@ */ import { v4 as uuidv4 } from 'uuid'; -import { Activity, ActivityTypes, Attachment, ConversationAccount, ConversationReference, Transcript, TurnContext } from 'botbuilder-core'; +import { + Activity, + ActivityTypes, + Attachment, + ConversationAccount, + ConversationReference, + Transcript, + TurnContext, +} from 'botbuilder-core'; import * as dayjs from 'dayjs'; import * as timezone from 'dayjs/plugin/timezone'; dayjs.extend(timezone); @@ -16,9 +24,11 @@ import { HandoffEventNames } from './handoffEventNames'; export class EventFactory { /** * Create handoff initiation event. + * * @param context The context object for the turn. * @param handoffContext Agent hub-specific context. * @param transcript Transcript of the conversation. + * @returns The handoff event activity. */ public static createHandoffInitiation( context: TurnContext, @@ -55,9 +65,11 @@ export class EventFactory { /** * Create handoff status event. + * * @param conversation Conversation being handed over. * @param state State, possible values are: "accepted", "failed", "completed". * @param message Additional message for failed handoff. + * @returns The handoff event activity. */ public static createHandoffStatus(conversation: ConversationAccount, state: string, message?: string): Activity { if (!conversation) { diff --git a/libraries/botbuilder/src/fileTranscriptStore.ts b/libraries/botbuilder/src/fileTranscriptStore.ts index 28055f6706..9f4b5269a9 100644 --- a/libraries/botbuilder/src/fileTranscriptStore.ts +++ b/libraries/botbuilder/src/fileTranscriptStore.ts @@ -8,9 +8,7 @@ import { join, parse } from 'path'; import { mkdirp, pathExists, readdir, readFile, remove, writeFile } from 'fs-extra'; import { Activity, PagedResult, TranscriptInfo, TranscriptStore } from 'botbuilder-core'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const filenamify = require('filenamify'); +import * as filenamify from 'filenamify'; /** * @private @@ -103,6 +101,7 @@ export class FileTranscriptStore implements TranscriptStore { /** * Creates an instance of FileTranscriptStore. + * * @param folder Root folder where transcript will be stored. */ constructor(folder: string) { @@ -115,7 +114,9 @@ export class FileTranscriptStore implements TranscriptStore { /** * Log an activity to the transcript. + * * @param activity Activity being logged. + * @returns {Promise} a promise representing the asynchronous operation. */ public async logActivity(activity: Activity): Promise { if (!activity) { @@ -130,10 +131,12 @@ export class FileTranscriptStore implements TranscriptStore { /** * Get all activities associated with a conversation id (aka get the transcript). + * * @param channelId Channel Id. * @param conversationId Conversation Id. * @param continuationToken (Optional) Continuation token to page through results. * @param startDate (Optional) Earliest time to include. + * @returns {Promise>} PagedResult of activities. */ public async getTranscriptActivities( channelId: string, @@ -181,8 +184,10 @@ export class FileTranscriptStore implements TranscriptStore { /** * List all the logged conversations for a given channelId. + * * @param channelId Channel Id. * @param continuationToken (Optional) Continuation token to page through results. + * @returns {Promise>} PagedResult of transcripts. */ public async listTranscripts(channelId: string, continuationToken?: string): Promise> { if (!channelId) { @@ -211,8 +216,10 @@ export class FileTranscriptStore implements TranscriptStore { /** * Delete a conversation and all of it's activities. + * * @param channelId Channel Id where conversation took place. * @param conversationId Id of the conversation to delete. + * @returns {Promise} A promise representing the asynchronous operation. */ public async deleteTranscript(channelId: string, conversationId: string): Promise { if (!channelId) { @@ -230,9 +237,11 @@ export class FileTranscriptStore implements TranscriptStore { /** * Saves the [Activity](xref:botframework-schema.Activity) as a JSON file. + * * @param activity The [Activity](xref:botframework-schema.Activity) to transcript. * @param transcriptPath The path where the transcript will be saved. * @param activityFilename The name for the file. + * @returns {Promise} A promise representing the asynchronous operation. */ private async saveActivity(activity: Activity, transcriptPath: string, activityFilename: string): Promise { const json: string = JSON.stringify(activity, null, '\t'); diff --git a/libraries/botbuilder/src/inspectionMiddleware.ts b/libraries/botbuilder/src/inspectionMiddleware.ts index b7acc1e013..261278b9b7 100644 --- a/libraries/botbuilder/src/inspectionMiddleware.ts +++ b/libraries/botbuilder/src/inspectionMiddleware.ts @@ -81,8 +81,10 @@ class TraceActivity { /** @private */ abstract class InterceptionMiddleware implements Middleware { - /** Implement middleware signature - * @param context {TurnContext} An incoming TurnContext object. + /** + * Implement middleware signature + * + * @param turnContext {TurnContext} An incoming TurnContext object. * @param next {function} The next delegate function. */ public async onTurn(turnContext: TurnContext, next: () => Promise): Promise { @@ -179,6 +181,11 @@ export class InspectionMiddleware extends InterceptionMiddleware { /** * Create the Inspection middleware for sending trace activities out to an emulator session + * + * @param inspectionState A state management object for inspection state. + * @param userState A state management object for user state. + * @param conversationState A state management object for conversation state. + * @param credentials The authentication credentials. */ constructor( inspectionState: InspectionState, @@ -198,6 +205,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { /** * Indentifies open and attach commands and calls the appropriate method. + * * @param turnContext The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @returns True if the command is open or attached, otherwise false. */ @@ -227,8 +235,10 @@ export class InspectionMiddleware extends InterceptionMiddleware { /** * Processes inbound activities. + * * @param turnContext The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param traceActivity The trace activity. + * @returns {Promise} A promise representing the asynchronous operation. */ protected async inbound(turnContext: TurnContext, traceActivity: Partial): Promise { if (await this.processCommand(turnContext)) { @@ -249,6 +259,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { /** * Processes outbound activities. + * * @param turnContext The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param traceActivities A collection of trace activities. */ @@ -266,6 +277,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { /** * Processes the state management object. + * * @param turnContext The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. */ protected async traceState(turnContext: TurnContext): Promise { @@ -409,7 +421,7 @@ class InspectionSession { try { await this.connectorClient.conversations.sendToConversation(activity.conversation.id, activity as Activity); - } catch (err) { + } catch { return false; } @@ -436,6 +448,7 @@ class InspectionSessionsByStatus { export class InspectionState extends BotState { /** * Creates a new instance of the [InspectionState](xref:botbuilder.InspectionState) class. + * * @param storage The [Storage](xref:botbuilder-core.Storage) layer this state management object will use to store and retrieve state. */ constructor(storage: Storage) { @@ -446,9 +459,11 @@ export class InspectionState extends BotState { /** * Gets the key to use when reading and writing state to and from storage. - * @param turnContext The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. + * + * @param _turnContext The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. + * @returns The storage key. */ - protected getStorageKey(turnContext: TurnContext) { + protected getStorageKey(_turnContext: TurnContext) { return 'InspectionState'; } } diff --git a/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts b/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts index f28ab95241..5645674239 100644 --- a/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts +++ b/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts @@ -14,6 +14,7 @@ import { ClaimsIdentity, ConnectorClient } from 'botframework-connector'; export interface ConnectorClientBuilder { /** * Creates the connector client asynchronous. + * * @param serviceUrl The service URL. * @param claimsIdentity The claims claimsIdentity. * @param audience The target audience for the ConnectorClient. diff --git a/libraries/botbuilder/src/interfaces/response.ts b/libraries/botbuilder/src/interfaces/response.ts index 1e81db6e04..13936873fd 100644 --- a/libraries/botbuilder/src/interfaces/response.ts +++ b/libraries/botbuilder/src/interfaces/response.ts @@ -18,7 +18,6 @@ export interface Response { } export const ResponseT = z.custom( - // eslint-disable-next-line @typescript-eslint/no-explicit-any (val: any) => typeof val.end === 'function' && typeof val.header === 'function' && diff --git a/libraries/botbuilder/src/skills/cloudSkillHandler.ts b/libraries/botbuilder/src/skills/cloudSkillHandler.ts index 9a5f8a8d91..db0586dda5 100644 --- a/libraries/botbuilder/src/skills/cloudSkillHandler.ts +++ b/libraries/botbuilder/src/skills/cloudSkillHandler.ts @@ -14,6 +14,9 @@ import { TurnContext, } from 'botbuilder-core'; +/** + * A Bot Framework Handler for skills. + */ export class CloudSkillHandler extends CloudChannelServiceHandler { /** * Used to access the CovnersationReference sent from the Skill to the Parent. diff --git a/libraries/botbuilder/src/skills/skillHandlerImpl.ts b/libraries/botbuilder/src/skills/skillHandlerImpl.ts index b72d460712..0a9dc188c6 100644 --- a/libraries/botbuilder/src/skills/skillHandlerImpl.ts +++ b/libraries/botbuilder/src/skills/skillHandlerImpl.ts @@ -19,6 +19,9 @@ import { * @internal */ export class SkillHandlerImpl { + /** + * @internal + */ constructor( private readonly skillConversationReferenceKey: symbol, private readonly adapter: BotAdapter, @@ -27,6 +30,9 @@ export class SkillHandlerImpl { private readonly getOauthScope: () => string | undefined = () => undefined ) {} + /** + * @internal + */ onSendToConversation( claimsIdentity: ClaimsIdentity, conversationId: string, @@ -35,6 +41,9 @@ export class SkillHandlerImpl { return this.processActivity(claimsIdentity, conversationId, null, activity); } + /** + * @internal + */ onReplyToActivity( claimsIdentity: ClaimsIdentity, conversationId: string, @@ -44,6 +53,9 @@ export class SkillHandlerImpl { return this.processActivity(claimsIdentity, conversationId, activityId, activity); } + /** + * @internal + */ async onUpdateActivity( claimsIdentity: ClaimsIdentity, conversationId: string, @@ -66,6 +78,9 @@ export class SkillHandlerImpl { return resourceResponse ? resourceResponse : { id: activityId }; } + /** + * @internal + */ async onDeleteActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise { return this.continueConversation(claimsIdentity, conversationId, (context) => context.deleteActivity(activityId) diff --git a/libraries/botbuilder/src/skills/skillHttpClient.ts b/libraries/botbuilder/src/skills/skillHttpClient.ts index 709164d701..c196329fe9 100644 --- a/libraries/botbuilder/src/skills/skillHttpClient.ts +++ b/libraries/botbuilder/src/skills/skillHttpClient.ts @@ -30,6 +30,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { /** * Creates a new instance of the [SkillHttpClient](xref:botbuilder-core.SkillHttpClient) class. + * * @param credentialProvider An instance of [ICredentialProvider](xref:botframework-connector.ICredentialProvider). * @param conversationIdFactory An instance of a class derived from [SkillConversationIdFactoryBase](xref:botbuilder-core.SkillConversationIdFactoryBase). * @param channelService Optional. The channel service. @@ -49,6 +50,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { /** * Uses the SkillConversationIdFactory to create or retrieve a Skill Conversation Id, and sends the activity. + * * @template T The type of body in the InvokeResponse. * @param originatingAudience The OAuth audience scope, used during token retrieval. (Either https://api.botframework.com or bot app id.) * @param fromBotId The MicrosoftAppId of the bot sending the activity. @@ -65,6 +67,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { ): Promise>; /** * Uses the SkillConversationIdFactory to create or retrieve a Skill Conversation Id, and sends the activity. + * * @deprecated This overload is deprecated. Please use SkillHttpClient.postToSkill() that takes an `originatingAudience`. * @param fromBotId The MicrosoftAppId of the bot sending the activity. * @param toSkill The skill to create the Conversation Id for. @@ -79,13 +82,14 @@ export class SkillHttpClient extends BotFrameworkHttpClient { ): Promise; /** * Uses the `SkillConversationIdFactory` to create or retrieve a Skill Conversation Id, and sends the [Activity](xref:botframework-schema.Activity). + * * @param audienceOrFromBotId The OAuth audience scope, used during token retrieval or the AppId of the bot sending the [Activity](xref:botframework-schema.Activity). * @param fromBotIdOrSkill The AppId of the bot sending the [Activity](xref:botframework-schema.Activity) or the skill to create the Conversation Id for. * @param toSkillOrCallbackUrl The skill to create the Conversation Id for or the callback Url for the skill host. * @param callbackUrlOrActivity The callback Url for the skill host or the [Activity](xref:botframework-schema.Activity) to send. * @param activityToForward Optional. The [Activity](xref:botframework-schema.Activity) to forward. * @returns A `Promise` representing the [InvokeResponse](xref:botbuilder-core.InvokeResponse) for the operation. - */ + */ public async postToSkill( audienceOrFromBotId: string, fromBotIdOrSkill: string | BotFrameworkSkill, diff --git a/libraries/botbuilder/src/streaming/streamingHttpClient.ts b/libraries/botbuilder/src/streaming/streamingHttpClient.ts index 3546eb1742..26ed8ec167 100644 --- a/libraries/botbuilder/src/streaming/streamingHttpClient.ts +++ b/libraries/botbuilder/src/streaming/streamingHttpClient.ts @@ -22,7 +22,7 @@ export class StreamingHttpClient implements HttpClient { */ public constructor(server: IStreamingTransportServer) { if (!server) { - throw new Error(`StreamingHttpClient: Expected server.`); + throw new Error('StreamingHttpClient: Expected server.'); } this.server = server; } @@ -33,7 +33,7 @@ export class StreamingHttpClient implements HttpClient { * and converting it to a form that can be sent over a streaming transport. * * @param httpRequest The outgoing request created by the BotframeworkAdapter. - * @return The streaming transport compatible response to send back to the client. + * @returns The streaming transport compatible response to send back to the client. */ public async sendRequest(httpRequest: WebResource): Promise { if (!httpRequest) { diff --git a/libraries/botbuilder/src/streaming/tokenResolver.ts b/libraries/botbuilder/src/streaming/tokenResolver.ts index 5c7fc14fc8..c6c6e51883 100644 --- a/libraries/botbuilder/src/streaming/tokenResolver.ts +++ b/libraries/botbuilder/src/streaming/tokenResolver.ts @@ -31,6 +31,7 @@ export class TokenResolver { /** * Checks if we have token responses from OAuth cards. + * * @param adapter The [BotFrameworkAdapter](xref:botbuilder.BotFrameworkAdapter). * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param activity The [Activity](xref:botframework-schema.Activity) to be checked. @@ -50,7 +51,7 @@ export class TokenResolver { if (attachment.contentType == CardFactory.contentTypes.oauthCard) { const oauthCard = attachment.content; if (!oauthCard.connectionName) { - throw new Error(`The OAuthPrompt's ConnectionName property is missing a value.`); + throw new Error("The OAuthPrompt's ConnectionName property is missing a value."); } let pollingTimeoutMs = context.turnState.get(TokenPollingSettingsKey); diff --git a/libraries/botbuilder/src/teamsActivityHandler.ts b/libraries/botbuilder/src/teamsActivityHandler.ts index f28cf588fd..6b5b3e00ce 100644 --- a/libraries/botbuilder/src/teamsActivityHandler.ts +++ b/libraries/botbuilder/src/teamsActivityHandler.ts @@ -14,7 +14,6 @@ import { Channels, FileConsentCardResponse, InvokeResponse, - MeetingEventDetails, MeetingStartEventDetails, MeetingEndEventDetails, MessagingExtensionAction, @@ -60,6 +59,7 @@ const TeamsMeetingEndT = z /** * Adds support for Microsoft Teams specific events and interactions. + * * @remarks * Developers may handle Conversation Update activities sent from Microsoft Teams via two methods: * 1. Overriding methods starting with `on..` and *not* ending in `..Event()` (e.g. `onTeamsMembersAdded()`), or instead @@ -75,6 +75,7 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Invoked when an invoke activity is received from the connector. * Invoke activities can be used to communicate many different things. + * * @param context A context object for this turn. * @returns An Invoke Response for the activity. */ @@ -179,10 +180,11 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Handles a Teams Card Action Invoke activity. - * @param context A context object for this turn. + * + * @param _context A context object for this turn. * @returns An Invoke Response for the activity. */ - protected async handleTeamsCardActionInvoke(context: TurnContext): Promise { + protected async handleTeamsCardActionInvoke(_context: TurnContext): Promise { throw new Error('NotImplemented'); } @@ -191,6 +193,7 @@ export class TeamsActivityHandler extends ActivityHandler { * `handleTeamsFileConsentAccept` and `handleTeamsFileConsentDecline`. * Developers are not passed a pointer to the next `handleTeamsFileConsent` handler because the _wrapper_ around * the handler will call `onDialogs` handlers after delegating to `handleTeamsFileConsentAccept` or `handleTeamsFileConsentDecline`. + * * @param context A context object for this turn. * @param fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card. * @returns A promise that represents the work queued. @@ -211,49 +214,53 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Receives invoke activities with Activity name of 'fileConsent/invoke' with confirmation from user + * * @remarks * This type of invoke activity occur during the File Consent flow. - * @param context A context object for this turn. - * @param fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card. + * @param _context A context object for this turn. + * @param _fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card. * @returns A promise that represents the work queued. */ protected async handleTeamsFileConsentAccept( - context: TurnContext, - fileConsentCardResponse: FileConsentCardResponse + _context: TurnContext, + _fileConsentCardResponse: FileConsentCardResponse ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'fileConsent/invoke' with decline from user + * * @remarks * This type of invoke activity occur during the File Consent flow. - * @param context A context object for this turn. - * @param fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card. + * @param _context A context object for this turn. + * @param _fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card. * @returns A promise that represents the work queued. */ protected async handleTeamsFileConsentDecline( - context: TurnContext, - fileConsentCardResponse: FileConsentCardResponse + _context: TurnContext, + _fileConsentCardResponse: FileConsentCardResponse ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'actionableMessage/executeAction'. - * @param context A context object for this turn. - * @param query The O365 connector card HttpPOST invoke query. - * @returnsa A promise that represents the work queued. + * + * @param _context A context object for this turn. + * @param _query The O365 connector card HttpPOST invoke query. + * @returns A promise that represents the work queued. */ protected async handleTeamsO365ConnectorCardAction( - context: TurnContext, - query: O365ConnectorCardActionQuery + _context: TurnContext, + _query: O365ConnectorCardActionQuery ): Promise { throw new Error('NotImplemented'); } /** * Invoked when a signIn invoke activity is received from the connector. + * * @param context A context object for this turn. * @returns A promise that represents the work queued. */ @@ -268,133 +275,147 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Receives invoke activities with Activity name of 'signin/verifyState'. - * @param context A context object for this turn. - * @param query Signin state (part of signin action auth flow) verification invoke query. + * + * @param _context A context object for this turn. + * @param _query Signin state (part of signin action auth flow) verification invoke query. * @returns A promise that represents the work queued. */ protected async handleTeamsSigninVerifyState( - context: TurnContext, - query: SigninStateVerificationQuery + _context: TurnContext, + _query: SigninStateVerificationQuery ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'signin/tokenExchange' - * @param context A context object for this turn. - * @param query Signin state (part of signin action auth flow) verification invoke query + * + * @param _context A context object for this turn. + * @param _query Signin state (part of signin action auth flow) verification invoke query * @returns A promise that represents the work queued. */ protected async handleTeamsSigninTokenExchange( - context: TurnContext, - query: SigninStateVerificationQuery + _context: TurnContext, + _query: SigninStateVerificationQuery ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'composeExtension/onCardButtonClicked' - * @param context A context object for this turn. - * @param cardData Object representing the card data. + * + * @param _context A context object for this turn. + * @param _cardData Object representing the card data. * @returns A promise that represents the work queued. */ - protected async handleTeamsMessagingExtensionCardButtonClicked(context: TurnContext, cardData: any): Promise { + protected async handleTeamsMessagingExtensionCardButtonClicked( + _context: TurnContext, + _cardData: any + ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'task/fetch' - * @param context A context object for this turn. - * @param taskModuleRequest The task module invoke request value payload. + * + * @param _context A context object for this turn. + * @param _taskModuleRequest The task module invoke request value payload. * @returns A Task Module Response for the request. */ protected async handleTeamsTaskModuleFetch( - context: TurnContext, - taskModuleRequest: TaskModuleRequest + _context: TurnContext, + _taskModuleRequest: TaskModuleRequest ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'task/submit' - * @param context A context object for this turn. - * @param taskModuleRequest The task module invoke request value payload. + * + * @param _context A context object for this turn. + * @param _taskModuleRequest The task module invoke request value payload. * @returns A Task Module Response for the request. */ protected async handleTeamsTaskModuleSubmit( - context: TurnContext, - taskModuleRequest: TaskModuleRequest + _context: TurnContext, + _taskModuleRequest: TaskModuleRequest ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'tab/fetch' - * @param context A context object for this turn. - * @param tabRequest The tab invoke request value payload. + * + * @param _context A context object for this turn. + * @param _tabRequest The tab invoke request value payload. * @returns A Tab Response for the request. */ - protected async handleTeamsTabFetch(context: TurnContext, tabRequest: TabRequest): Promise { + protected async handleTeamsTabFetch(_context: TurnContext, _tabRequest: TabRequest): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'tab/submit' - * @param context A context object for this turn. - * @param tabSubmit The tab submit invoke request value payload. + * + * @param _context A context object for this turn. + * @param _tabSubmit The tab submit invoke request value payload. * @returns A Tab Response for the request. */ - protected async handleTeamsTabSubmit(context: TurnContext, tabSubmit: TabSubmit): Promise { + protected async handleTeamsTabSubmit(_context: TurnContext, _tabSubmit: TabSubmit): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with Activity name of 'composeExtension/queryLink' + * * @remarks * Used in creating a Search-based Message Extension. - * @param context A context object for this turn. - * @param query he invoke request body type for app-based link query. + * @param _context A context object for this turn. + * @param _query he invoke request body type for app-based link query. * @returns The Messaging Extension Response for the query. */ protected async handleTeamsAppBasedLinkQuery( - context: TurnContext, - query: AppBasedLinkQuery + _context: TurnContext, + _query: AppBasedLinkQuery ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with the name 'composeExtension/query'. + * * @remarks * Used in creating a Search-based Message Extension. - * @param context A context object for this turn. - * @param query The query for the search command. + * @param _context A context object for this turn. + * @param _query The query for the search command. * @returns The Messaging Extension Response for the query. */ protected async handleTeamsMessagingExtensionQuery( - context: TurnContext, - query: MessagingExtensionQuery + _context: TurnContext, + _query: MessagingExtensionQuery ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with the name 'composeExtension/selectItem'. + * * @remarks * Used in creating a Search-based Message Extension. - * @param context A context object for this turn. - * @param query he object representing the query. + * @param _context A context object for this turn. + * @param _query he object representing the query. * @returns The Messaging Extension Response for the query. */ protected async handleTeamsMessagingExtensionSelectItem( - context: TurnContext, - query: any + _context: TurnContext, + _query: any ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with the name 'composeExtension/submitAction' and dispatches to botMessagePreview-flows as applicable. + * * @remarks * A handler registered through this method does not dispatch to the next handler (either `handleTeamsMessagingExtensionSubmitAction`, `handleTeamsMessagingExtensionBotMessagePreviewEdit`, or `handleTeamsMessagingExtensionBotMessagePreviewSend`). * This method exists for developers to optionally add more logic before the TeamsActivityHandler routes the activity to one of the @@ -423,13 +444,14 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Receives invoke activities with the name 'composeExtension/submitAction'. - * @param context A context object for this turn. - * @param action The messaging extension action. + * + * @param _context A context object for this turn. + * @param _action The messaging extension action. * @returns The Messaging Extension Action Response for the action. */ protected async handleTeamsMessagingExtensionSubmitAction( - context: TurnContext, - action: MessagingExtensionAction + _context: TurnContext, + _action: MessagingExtensionAction ): Promise { throw new Error('NotImplemented'); } @@ -437,13 +459,14 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Receives invoke activities with the name 'composeExtension/submitAction' with the 'botMessagePreview' property present on activity.value. * The value for 'botMessagePreview' is 'edit'. - * @param context A context object for this turn. - * @param action The messaging extension action. + * + * @param _context A context object for this turn. + * @param _action The messaging extension action. * @returns The Messaging Extension Action Response for the action. */ protected async handleTeamsMessagingExtensionBotMessagePreviewEdit( - context: TurnContext, - action: MessagingExtensionAction + _context: TurnContext, + _action: MessagingExtensionAction ): Promise { throw new Error('NotImplemented'); } @@ -451,64 +474,69 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Receives invoke activities with the name 'composeExtension/submitAction' with the 'botMessagePreview' property present on activity.value. * The value for 'botMessagePreview' is 'send'. - * @param context A context object for this turn. - * @param action The messaging extension action. + * + * @param _context A context object for this turn. + * @param _action The messaging extension action. * @returns The Messaging Extension Action Response for the action. */ protected async handleTeamsMessagingExtensionBotMessagePreviewSend( - context: TurnContext, - action: MessagingExtensionAction + _context: TurnContext, + _action: MessagingExtensionAction ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with the name 'composeExtension/fetchTask' - * @param context A context object for this turn. - * @param action The messaging extension action. + * + * @param _context A context object for this turn. + * @param _action The messaging extension action. * @returns The Messaging Extension Action Response for the action. */ protected async handleTeamsMessagingExtensionFetchTask( - context: TurnContext, - action: MessagingExtensionAction + _context: TurnContext, + _action: MessagingExtensionAction ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with the name 'composeExtension/querySettingUrl' - * @param context A context object for this turn. - * @param query The Messaging extension query. + * + * @param _context A context object for this turn. + * @param _query The Messaging extension query. * @returns The Messaging Extension Action Response for the query. */ protected async handleTeamsMessagingExtensionConfigurationQuerySettingUrl( - context: TurnContext, - query: MessagingExtensionQuery + _context: TurnContext, + _query: MessagingExtensionQuery ): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with the name 'adaptiveCard/action' - * @param context A context object for this turn. + * + * @param _context A context object for this turn. * @returns The Messaging Extension Action Response for the query. */ - protected async handleAdaptiveCardAction(context: TurnContext): Promise { + protected async handleAdaptiveCardAction(_context: TurnContext): Promise { throw new Error('NotImplemented'); } /** * Receives invoke activities with the name 'composeExtension/setting' - * @param context A context object for this turn. - * @param settings Object representing the configuration settings. - * @returns A promise that represents the work queued. + * + * @param _context A context object for this turn. + * @param _settings Object representing the configuration settings. */ - protected handleTeamsMessagingExtensionConfigurationSetting(context: TurnContext, settings: any): Promise { + protected handleTeamsMessagingExtensionConfigurationSetting(_context: TurnContext, _settings: any): Promise { throw new Error('NotImplemented'); } /** * Override this method to change the dispatching of ConversationUpdate activities. + * * @param context A context object for this turn. * @returns A promise that represents the work queued. */ @@ -573,6 +601,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Called in `dispatchConversationUpdateActivity()` to trigger the `'TeamsMembersAdded'` handlers. * Override this in a derived class to provide logic for when members other than the bot * join the channel, such as your bot's welcome logic. + * * @remarks * If no handlers are registered for the `'TeamsMembersAdded'` event, the `'MembersAdded'` handlers will run instead. * @param context A context object for this turn. @@ -625,6 +654,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Called in `dispatchConversationUpdateActivity()` to trigger the `'TeamsMembersRemoved'` handlers. * Override this in a derived class to provide logic for when members other than the bot * leave the channel, such as your bot's good-bye logic. + * * @remarks * If no handlers are registered for the `'TeamsMembersRemoved'` event, the `'MembersRemoved'` handlers will run instead. * @param context A context object for this turn. @@ -642,6 +672,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Channel Created event activity is received from the connector. * Channel Created corresponds to the user creating a new channel. * Override this in a derived class to provide logic for when a channel is created. + * * @param context A context object for this turn. * @returns A promise that represents the work queued. */ @@ -653,6 +684,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Channel Deleted event activity is received from the connector. * Channel Deleted corresponds to the user deleting a channel. * Override this in a derived class to provide logic for when a channel is deleted. + * * @param context A context object for this turn. * @returns A promise that represents the work queued. */ @@ -664,6 +696,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Channel Renamed event activity is received from the connector. * Channel Renamed corresponds to the user renaming a new channel. * Override this in a derived class to provide logic for when a channel is renamed. + * * @param context A context object for this turn. * @returns A promise that represents the work queued. */ @@ -675,6 +708,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Team Archived event activity is received from the connector. * Team Archived corresponds to the user archiving a team. * Override this in a derived class to provide logic for when a team is archived. + * * @param context The context for this turn. * @returns A promise that represents the work queued. */ @@ -686,6 +720,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Team Deleted event activity is received from the connector. * Team Deleted corresponds to the user deleting a team. * Override this in a derived class to provide logic for when a team is deleted. + * * @param context The context for this turn. * @returns A promise that represents the work queued. */ @@ -697,6 +732,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Team Hard Deleted event activity is received from the connector. * Team Hard Deleted corresponds to the user hard-deleting a team. * Override this in a derived class to provide logic for when a team is hard-deleted. + * * @param context The context for this turn. * @returns A promise that represents the work queued. */ @@ -706,10 +742,10 @@ export class TeamsActivityHandler extends ActivityHandler { /** * - * @param context * Invoked when a Channel Restored event activity is received from the connector. * Channel Restored corresponds to the user restoring a previously deleted channel. * Override this in a derived class to provide logic for when a channel is restored. + * * @param context The context for this turn. * @returns A promise that represents the work queued. */ @@ -721,6 +757,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Team Renamed event activity is received from the connector. * Team Renamed corresponds to the user renaming a team. * Override this in a derived class to provide logic for when a team is renamed. + * * @param context The context for this turn. * @returns A promise that represents the work queued. */ @@ -732,6 +769,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Team Restored event activity is received from the connector. * Team Restored corresponds to the user restoring a team. * Override this in a derived class to provide logic for when a team is restored. + * * @param context The context for this turn. * @returns A promise that represents the work queued. */ @@ -743,6 +781,7 @@ export class TeamsActivityHandler extends ActivityHandler { * Invoked when a Team Unarchived event activity is received from the connector. * Team Unarchived corresponds to the user unarchiving a team. * Override this in a derived class to provide logic for when a team is unarchived. + * * @param context The context for this turn. * @returns A promise that represents the work queued. */ @@ -753,7 +792,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsMembersAdded events, such as for when members other than the bot * join the channel, such as your bot's welcome logic. - * @param handler + * + * @param handler A callback to handle the teams members added event. * @returns A promise that represents the work queued. */ public onTeamsMembersAddedEvent( @@ -773,7 +813,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsMembersRemoved events, such as for when members other than the bot * leave the channel, such as your bot's good-bye logic. - * @param handler + * + * @param handler A callback to handle the teams members removed event. * @returns A promise that represents the work queued. */ public onTeamsMembersRemovedEvent( @@ -792,7 +833,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsChannelCreated events, such as for when a channel is created. - * @param handler + * + * @param handler A callback to handle the teams channel created event. * @returns A promise that represents the work queued. */ public onTeamsChannelCreatedEvent( @@ -811,7 +853,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsChannelDeleted events, such as for when a channel is deleted. - * @param handler + * + * @param handler A callback to handle the teams channel deleted event. * @returns A promise that represents the work queued. */ public onTeamsChannelDeletedEvent( @@ -830,7 +873,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsChannelRenamed events, such as for when a channel is renamed. - * @param handler + * + * @param handler A callback to handle the teams channel renamed event. * @returns A promise that represents the work queued. */ public onTeamsChannelRenamedEvent( @@ -849,7 +893,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsTeamArchived events, such as for when a team is archived. - * @param handler + * + * @param handler A callback to handle the teams team archived event. * @returns A promise that represents the work queued. */ public onTeamsTeamArchivedEvent( @@ -863,7 +908,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsTeamDeleted events, such as for when a team is deleted. - * @param handler + * + * @param handler A callback to handle the teams team deleted event. * @returns A promise that represents the work queued. */ public onTeamsTeamDeletedEvent( @@ -877,7 +923,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsTeamHardDeleted events, such as for when a team is hard-deleted. - * @param handler + * + * @param handler A callback to handle the teams team hard deleted event. * @returns A promise that represents the work queued. */ public onTeamsTeamHardDeletedEvent( @@ -891,7 +938,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsChannelRestored events, such as for when a channel is restored. - * @param handler + * + * @param handler A callback to handle the teams channel restored event. * @returns A promise that represents the work queued. */ public onTeamsChannelRestoredEvent( @@ -910,7 +958,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsTeamRenamed events, such as for when a team is renamed. - * @param handler + * + * @param handler A callback to handle the teams team renamed event. * @returns A promise that represents the work queued. */ public onTeamsTeamRenamedEvent( @@ -924,7 +973,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsTeamRestored events, such as for when a team is restored. - * @param handler + * + * @param handler A callback to handle the teams team restored event. * @returns A promise that represents the work queued. */ public onTeamsTeamRestoredEvent( @@ -938,7 +988,8 @@ export class TeamsActivityHandler extends ActivityHandler { /** * Registers a handler for TeamsTeamUnarchived events, such as for when a team is unarchived. - * @param handler + * + * @param handler A callback to handle the teams team unarchived event. * @returns A promise that represents the work queued. */ public onTeamsTeamUnarchivedEvent( diff --git a/libraries/botbuilder/src/teamsActivityHelpers.ts b/libraries/botbuilder/src/teamsActivityHelpers.ts index caf6ba3ccf..24939186f5 100644 --- a/libraries/botbuilder/src/teamsActivityHelpers.ts +++ b/libraries/botbuilder/src/teamsActivityHelpers.ts @@ -20,6 +20,7 @@ function validateActivity(activity: Activity): void { /** * Gets the TeamsMeetingInfo object from the current [Activity](xref:botframework-schema.Activity). + * * @param activity The current [Activity](xref:botframework-schema.Activity). * @returns The current [Activity](xref:botframework-schema.Activity)'s team meeting info, or null. */ @@ -35,6 +36,7 @@ export function teamsGetTeamMeetingInfo(activity: Activity): TeamsMeetingInfo | /** * Gets the TenantInfo object from the current [Activity](xref:botframework-schema.Activity). + * * @param activity The current [Activity](xref:botframework-schema.Activity). * @returns The current [Activity](xref:botframework-schema.Activity)'s tenant info, or null. */ @@ -50,6 +52,7 @@ export function teamsGetTenant(activity: Activity): TenantInfo | null { /** * Gets the TeamsInfo object from the current [Activity](xref:botframework-schema.Activity). + * * @param activity The current [Activity](xref:botframework-schema.Activity). * @returns The current [Activity](xref:botframework-schema.Activity)'s team's info, or null. */ @@ -67,6 +70,7 @@ export function teamsGetTeamInfo(activity: Activity): TeamInfo | null { /** * Gets the Team Id from the current [Activity](xref:botframework-schema.Activity). + * * @param activity The current [Activity](xref:botframework-schema.Activity). * @returns The current [Activity](xref:botframework-schema.Activity)'s team's Id, or null. */ @@ -76,7 +80,10 @@ export function teamsGetTeamId(activity: Activity): string | null { } /** - * Activity helper methods for Teams. * Activity helper methods for Teams. + * Activity helper methods for Teams. + * + * @param activity The current [Activity](xref:botframework-schema.Activity). + * @returns The current [Activity](xref:botframework-schema.Activity)'s team's channel id, or null. */ export function teamsGetChannelId(activity: Activity): string | null { validateActivity(activity); @@ -92,7 +99,10 @@ export function teamsGetChannelId(activity: Activity): string | null { /** * Configures the current [Activity](xref:botframework-schema.Activity) to generate a notification within Teams. + * * @param activity The current [Activity](xref:botframework-schema.Activity). + * @param alertInMeeting Sent to a meeting chat, this will cause the Teams client to render it in a notification popup as well as in the chat thread. + * @param externalResourceUrl Url to external resource. Must be included in manifest's valid domains. */ export function teamsNotifyUser(activity: Activity, alertInMeeting?: boolean, externalResourceUrl?: string): void { validateActivity(activity); diff --git a/libraries/botbuilder/src/teamsInfo.ts b/libraries/botbuilder/src/teamsInfo.ts index 835d8adb8b..82b5d400a3 100644 --- a/libraries/botbuilder/src/teamsInfo.ts +++ b/libraries/botbuilder/src/teamsInfo.ts @@ -36,6 +36,7 @@ export class TeamsInfo { /** * Gets the meeting participant for the given meeting id and participant id. This only works in * teams scoped meeting conversations. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param meetingId The meeting ID to fetch * @param participantId The participant ID to fetch @@ -86,6 +87,7 @@ export class TeamsInfo { /** * Gets the information for the given meeting id. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param meetingId The BASE64-encoded id of the Teams meeting. * @returns The [TeamsMeetingInfo](xref:botbuilder-core.TeamsMeetingInfo) fetched @@ -111,6 +113,7 @@ export class TeamsInfo { /** * Gets the details for the given team id. This only works in teams scoped conversations. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param teamId The id of the Teams team. * @returns The [TeamDetails](xref:botbuilder-core.TeamDetails) fetched @@ -126,6 +129,7 @@ export class TeamsInfo { /** * Creates a new thread in a Teams chat and sends an [Activity](xref:botframework-schema.Activity) to that new thread. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param activity The [Activity](xref:botframework-schema.Activity) to send. * @param teamsChannelId The Team's Channel ID, note this is distinct from the Bot Framework activity property with same name. @@ -190,6 +194,7 @@ export class TeamsInfo { /** * Returns a list of channels in a Team. This only works in teams scoped conversations. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param teamId ID of the Teams team. * @returns The list of [ChannelInfo](xref:botframework-schema.ChannelInfo) objects with the conversations. @@ -206,6 +211,7 @@ export class TeamsInfo { /** * Gets the conversation members of a one-on-one or group chat. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @returns The list of [TeamsChannelAccount](xref:botframework-schema.TeamsChannelAccount). */ @@ -222,6 +228,7 @@ export class TeamsInfo { /** * Gets a pagined list of members of one-on-one, group, or team conversation. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param pageSize Suggested number of entries on a page. * @param continuationToken A continuation token. @@ -248,6 +255,7 @@ export class TeamsInfo { /** * Gets the account of a single conversation member. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param userId ID of the user in question. * @returns The [TeamsChannelAccount](xref:botframework-schema.TeamsChannelAccount) of the member. @@ -265,6 +273,7 @@ export class TeamsInfo { /** * Gets the list of [TeamsChannelAccount](xref:botframework-schema.TeamsChannelAccount) within a team. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param teamId ID of the Teams team. * @returns The list of [TeamsChannelAccount](xref:botframework-schema.TeamsChannelAccount) of the members. @@ -279,6 +288,7 @@ export class TeamsInfo { /** * Gets a paginated list of members of a team. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param teamId ID of the Teams team. * @param pageSize The number of entries on the page. @@ -305,6 +315,7 @@ export class TeamsInfo { /** * Gets the account of a member in a teams scoped conversation. + * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param teamId ID of the Teams team. * @param userId ID of the Teams user. diff --git a/libraries/botbuilder/src/zod.ts b/libraries/botbuilder/src/zod.ts index 5e7be57c83..5a90ebd52a 100644 --- a/libraries/botbuilder/src/zod.ts +++ b/libraries/botbuilder/src/zod.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable @typescript-eslint/no-explicit-any */ - import * as z from 'zod'; import { INodeBuffer, INodeSocket } from 'botframework-streaming'; import { TurnContext } from 'botbuilder-core'; diff --git a/libraries/botbuilder/tests/activityValidator.test.js b/libraries/botbuilder/tests/activityValidator.test.js index 4dfddf3935..2a68b57280 100644 --- a/libraries/botbuilder/tests/activityValidator.test.js +++ b/libraries/botbuilder/tests/activityValidator.test.js @@ -1,52 +1,52 @@ const assert = require('assert'); const { validateAndFixActivity } = require('../lib/activityValidator'); -describe(`activityValidator`, function() { +describe('activityValidator', function () { this.timeout(5000); const timestamp = '2020-03-17T14:42:39.3692591-07:00'; - it(`should preserve original localTimestamp in rawLocalTimestamp.`, () => { + it('should preserve original localTimestamp in rawLocalTimestamp.', function () { const activity = validateAndFixActivity({ type: 'message', localTimestamp: timestamp }); assert.strictEqual(activity.rawLocalTimestamp, timestamp); }); - it(`should preserve original expiration in rawExpiration.`, () => { + it('should preserve original expiration in rawExpiration.', function () { const activity = validateAndFixActivity({ type: 'message', expiration: timestamp }); assert.strictEqual(activity.rawExpiration, timestamp); }); - it(`should preserve original timestamp in rawTimestamp.`, () => { + it('should preserve original timestamp in rawTimestamp.', function () { const activity = validateAndFixActivity({ type: 'message', timestamp: timestamp }); assert.strictEqual(activity.rawTimestamp, timestamp); }); - it(`should not fail when missing localTimestamp.`, () => { + it('should not fail when missing localTimestamp.', function () { const activity = validateAndFixActivity({ type: 'message' }); - assert.strictEqual(typeof(activity.rawLocalTimestamp), 'undefined'); + assert.strictEqual(typeof activity.rawLocalTimestamp, 'undefined'); }); - it(`should not fail when missing expiration.`, () => { + it('should not fail when missing expiration.', function () { const activity = validateAndFixActivity({ type: 'message' }); - assert.strictEqual(typeof(activity.rawExpiration), 'undefined'); + assert.strictEqual(typeof activity.rawExpiration, 'undefined'); }); - it(`should not fail when missing timestamp.`, () => { + it('should not fail when missing timestamp.', function () { const activity = validateAndFixActivity({ type: 'message' }); - assert.strictEqual(typeof(activity.rawTimestamp), 'undefined'); + assert.strictEqual(typeof activity.rawTimestamp, 'undefined'); }); - it(`should convert timestamp string to Date.`, () => { + it('should convert timestamp string to Date.', function () { const activity = validateAndFixActivity({ type: 'message', timestamp: timestamp }); assert.equal(activity.timestamp.valueOf(), new Date(timestamp).valueOf()); }); - it(`should convert localTimestamp string to Date.`, () => { + it('should convert localTimestamp string to Date.', function () { const activity = validateAndFixActivity({ type: 'message', localTimestamp: timestamp }); assert.equal(activity.localTimestamp.valueOf(), new Date(timestamp).valueOf()); }); - it(`should convert expiration string to Date.`, () => { + it('should convert expiration string to Date.', function () { const activity = validateAndFixActivity({ type: 'message', expiration: timestamp }); assert.equal(activity.expiration.valueOf(), new Date(timestamp).valueOf()); }); diff --git a/libraries/botbuilder/tests/botFrameworkAdapter.test.js b/libraries/botbuilder/tests/botFrameworkAdapter.test.js index 9e9c97ce7d..8b3e4efdad 100644 --- a/libraries/botbuilder/tests/botFrameworkAdapter.test.js +++ b/libraries/botbuilder/tests/botFrameworkAdapter.test.js @@ -85,35 +85,35 @@ class AdapterUnderTest extends BotFrameworkAdapter { } authenticateRequestInternal(request, authHeader) { - assert(request, `authenticateRequestInternal() not passed request.`); + assert(request, 'authenticateRequestInternal() not passed request.'); assert.strictEqual( authHeader, this.expectAuthHeader, - `authenticateRequestInternal() not passed expected authHeader.` + 'authenticateRequestInternal() not passed expected authHeader.' ); return this.failAuth ? Promise.reject(new Error('failed auth')) : Promise.resolve({ claims: [] }); } createConnectorClient(serviceUrl) { - assert(serviceUrl, `createConnectorClient() not passed serviceUrl.`); + assert(serviceUrl, 'createConnectorClient() not passed serviceUrl.'); return this.mockConnectorClient.bind(this)(); } createConnectorClientWithIdentity(serviceUrl, identity) { - assert(serviceUrl, `createConnectorClientWithIdentity() not passed serviceUrl.`); - assert(identity, `createConnectorClientWithIdentity() not passed identity.`); + assert(serviceUrl, 'createConnectorClientWithIdentity() not passed serviceUrl.'); + assert(identity, 'createConnectorClientWithIdentity() not passed identity.'); return this.mockConnectorClient.bind(this)(); } createConnectorClientInternal(serviceUrl, credentials) { - assert(serviceUrl, `createConnectorClientInternal() not passed serviceUrl.`); - assert(credentials, `createConnectorClientInternal() not passed credentials.`); + assert(serviceUrl, 'createConnectorClientInternal() not passed serviceUrl.'); + assert(credentials, 'createConnectorClientInternal() not passed credentials.'); return this.mockConnectorClient.bind(this)(); } getOrCreateConnectorClient(context, serviceUrl, credentials) { - assert(context, `createConnectorClient() not passed context.`); - assert(serviceUrl, `createConnectorClient() not passed serviceUrl.`); - assert(credentials, `createConnectorClient() not passed credentials.`); + assert(context, 'createConnectorClient() not passed context.'); + assert(serviceUrl, 'createConnectorClient() not passed serviceUrl.'); + assert(credentials, 'createConnectorClient() not passed credentials.'); return this.mockConnectorClient.bind(this)(); } @@ -121,31 +121,31 @@ class AdapterUnderTest extends BotFrameworkAdapter { return { conversations: { replyToActivity: (conversationId, activityId, activity) => { - assert(conversationId, `replyToActivity() not passed conversationId.`); - assert(activityId, `replyToActivity() not passed activityId.`); - assert(activity, `replyToActivity() not passed activity.`); - return this.failOperation ? Promise.reject(new Error(`failed`)) : Promise.resolve({ id: '5678' }); + assert(conversationId, 'replyToActivity() not passed conversationId.'); + assert(activityId, 'replyToActivity() not passed activityId.'); + assert(activity, 'replyToActivity() not passed activity.'); + return this.failOperation ? Promise.reject(new Error('failed')) : Promise.resolve({ id: '5678' }); }, sendToConversation: (conversationId, activity) => { - assert(conversationId, `sendToConversation() not passed conversationId.`); - assert(activity, `sendToConversation() not passed activity.`); - return this.failOperation ? Promise.reject(new Error(`failed`)) : Promise.resolve({ id: '5678' }); + assert(conversationId, 'sendToConversation() not passed conversationId.'); + assert(activity, 'sendToConversation() not passed activity.'); + return this.failOperation ? Promise.reject(new Error('failed')) : Promise.resolve({ id: '5678' }); }, updateActivity: (conversationId, activityId, activity) => { - assert(conversationId, `updateActivity() not passed conversationId.`); - assert(activityId, `updateActivity() not passed activityId.`); - assert(activity, `updateActivity() not passed activity.`); - return this.failOperation ? Promise.reject(new Error(`failed`)) : Promise.resolve({ id: '5678' }); + assert(conversationId, 'updateActivity() not passed conversationId.'); + assert(activityId, 'updateActivity() not passed activityId.'); + assert(activity, 'updateActivity() not passed activity.'); + return this.failOperation ? Promise.reject(new Error('failed')) : Promise.resolve({ id: '5678' }); }, deleteActivity: (conversationId, activityId) => { - assert(conversationId, `deleteActivity() not passed conversationId.`); - assert(activityId, `deleteActivity() not passed activityId.`); - return this.failOperation ? Promise.reject(new Error(`failed`)) : Promise.resolve(); + assert(conversationId, 'deleteActivity() not passed conversationId.'); + assert(activityId, 'deleteActivity() not passed activityId.'); + return this.failOperation ? Promise.reject(new Error('failed')) : Promise.resolve(); }, createConversation: (parameters) => { - assert(parameters, `createConversation() not passed parameters.`); + assert(parameters, 'createConversation() not passed parameters.'); return this.failOperation - ? Promise.reject(new Error(`failed`)) + ? Promise.reject(new Error('failed')) : Promise.resolve({ id: 'convo2', serviceUrl: this.newServiceUrl }); }, }, @@ -194,13 +194,13 @@ class MockResponse { } send(body) { - assert(!this.ended, `response.send() called after response.end().`); + assert(!this.ended, 'response.send() called after response.end().'); this.body = body; } end() { - assert(!this.ended, `response.end() called twice.`); - assert.notStrictEqual(this.statusCode, undefined, `response.end() called before response.send().`); + assert(!this.ended, 'response.end() called twice.'); + assert.notStrictEqual(this.statusCode, undefined, 'response.end() called before response.send().'); this.ended = true; } } @@ -287,7 +287,7 @@ describe('BotFrameworkAdapter', function () { }; describe('constructor()', function () { - it(`should use CertificateAppCredentials when certificateThumbprint and certificatePrivateKey are provided`, function () { + it('should use CertificateAppCredentials when certificateThumbprint and certificatePrivateKey are provided', function () { const certificatePrivateKey = 'key'; const certificateThumbprint = 'thumbprint'; const appId = '11111111-7777-8888-9999-333333333333'; @@ -302,7 +302,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual(adapter.settings.appPassword, ''); }); - it(`should use CertificateAppCredentials over MicrosoftAppCredentials when certificateThumbprint and certificatePrivateKey are provided`, function () { + it('should use CertificateAppCredentials over MicrosoftAppCredentials when certificateThumbprint and certificatePrivateKey are provided', function () { const certificatePrivateKey = 'key'; const certificateThumbprint = 'thumbprint'; const appId = '11111111-7777-8888-9999-333333333333'; @@ -327,7 +327,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual(adapter.settings.appPassword, appPassword); }); - it(`should read ChannelService and BotOpenIdMetadata env var if they exist`, function () { + it('should read ChannelService and BotOpenIdMetadata env var if they exist', function () { process.env.ChannelService = 'https://botframework.azure.us'; process.env.BotOpenIdMetadata = 'https://someEndpoint.com'; @@ -339,18 +339,18 @@ describe('BotFrameworkAdapter', function () { delete process.env.BotOpenIdMetadata; }); - it(`should read webSocketFactory from the settings if it exists`, function () { + it('should read webSocketFactory from the settings if it exists', function () { const adapter = new AdapterUnderTest({ webSocketFactory: 'test-web-socket' }); assert.strictEqual( adapter.webSocketFactory, 'test-web-socket', - `Adapter should have read settings.webSocketFactory` + 'Adapter should have read settings.webSocketFactory' ); }); }); describe('authenticateRequest()', function () { - it(`should work if no appId or appPassword.`, async function () { + it('should work if no appId or appPassword.', async function () { mockReturns(JwtTokenValidation, 'authenticateRequest', new ClaimsIdentity([], true)); const req = new MockRequest(incomingMessage); @@ -402,7 +402,7 @@ describe('BotFrameworkAdapter', function () { sandbox.verify(); }); - it(`should fail if appId+appPassword and no headers.`, async function () { + it('should fail if appId+appPassword and no headers.', async function () { const req = new MockRequest(incomingMessage); const adapter = new AdapterUnderTest({ appId: 'bogusApp', appPassword: 'bogusPassword' }); await assert.rejects( @@ -436,11 +436,11 @@ describe('BotFrameworkAdapter', function () { }); describe('get/create ConnectorClient methods', function () { - it(`should createConnectorClient().`, function () { + it('should createConnectorClient().', function () { const adapter = new AdapterUnderTest(); const client = adapter.testCreateConnectorClient(reference.serviceUrl); - assert(client, `client not returned.`); - assert(client.conversations, `invalid client returned.`); + assert(client, 'client not returned.'); + assert(client.conversations, 'invalid client returned.'); }); it('getOrCreateConnectorClient should create a new client if the cached serviceUrl does not match the provided one', function () { @@ -527,23 +527,22 @@ describe('BotFrameworkAdapter', function () { it('ConnectorClient should add requestPolicyFactory for accept header', async function () { let hasAcceptHeader = false; const mockNextPolicy = { - create: (innerPolicy) => ({ - }), - sendRequest: (httpRequest) => { + create: () => ({}), + sendRequest: () => { return {}; - } + }, }; - const client = new BotFrameworkAdapter().createConnectorClient('https://localhost') - var length = client._requestPolicyFactories.length; - for (var i = 0; i < length; i++) { - var mockHttp = { - headers: new HttpHeaders() + const client = new BotFrameworkAdapter().createConnectorClient('https://localhost'); + const length = client._requestPolicyFactories.length; + for (let i = 0; i < length; i++) { + const mockHttp = { + headers: new HttpHeaders(), }; - var result = client._requestPolicyFactories[i].create(mockNextPolicy); + const result = client._requestPolicyFactories[i].create(mockNextPolicy); result.sendRequest(mockHttp); - if(mockHttp.headers.get("accept") == "*/*") { + if (mockHttp.headers.get('accept') == '*/*') { hasAcceptHeader = true; break; } @@ -648,7 +647,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual(client.credentials.oAuthScope, AuthenticationConstants.ToChannelFromBotOAuthScope); }); - it(`createConnectorClientWithIdentity should create a ConnectorClient with CertificateAppCredentials when certificateThumbprint and certificatePrivatekey are provided`, async function () { + it('createConnectorClientWithIdentity should create a ConnectorClient with CertificateAppCredentials when certificateThumbprint and certificatePrivatekey are provided', async function () { const appId = '01234567-4242-aaaa-bbbb-cccccccccccc'; const certificatePrivateKey = 'key'; const certificateThumbprint = 'thumbprint'; @@ -666,7 +665,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual(credentials.certificateThumbprint, certificateThumbprint); }); - it(`createConnectorClientWithIdentity should create a ConnectorClient with MicrosoftAppCredentials when certificateThumbprint and certificatePrivatekey are absent and ClaimsIdenity has AppIdClaim`, async function () { + it('createConnectorClientWithIdentity should create a ConnectorClient with MicrosoftAppCredentials when certificateThumbprint and certificatePrivatekey are absent and ClaimsIdenity has AppIdClaim', async function () { const appId = '01234567-4242-aaaa-bbbb-cccccccccccc'; // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="This is a fake password.")] const appPassword = 'password123'; @@ -685,7 +684,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual(credentials.certificateThumbprint, undefined); }); - it(`createConnectorClientWithIdentity should create a ConnectorClient with MicrosoftAppCredentials when certificateThumbprint and certificatePrivatekey are absent and ClaimsIdenity has AudienceClaim`, async function () { + it('createConnectorClientWithIdentity should create a ConnectorClient with MicrosoftAppCredentials when certificateThumbprint and certificatePrivatekey are absent and ClaimsIdenity has AudienceClaim', async function () { const appId = '01234567-4242-aaaa-bbbb-cccccccccccc'; // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="This is a fake password.")] const appPassword = 'password123'; @@ -705,7 +704,7 @@ describe('BotFrameworkAdapter', function () { }); }); - it(`processActivity() should respect expectReplies if it's set via logic`, async function () { + it("processActivity() should respect expectReplies if it's set via logic", async function () { const { response, verify } = await processActivity(async (context) => { context.activity.deliveryMode = 'expectReplies'; await context.sendActivity({ type: 'message', text: 'Hello Buffered World!' }); @@ -715,7 +714,7 @@ describe('BotFrameworkAdapter', function () { verify(); }); - it(`processActivity() should send only bufferedActivities when both expectReplies and invoke are set`, async function () { + it('processActivity() should send only bufferedActivities when both expectReplies and invoke are set', async function () { const activity = { ...JSON.parse(JSON.stringify(incomingMessage)), type: ActivityTypes.Invoke, @@ -748,7 +747,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should remove trace activities from bufferedReplyActivities if request.channelId !== Channels.Emulator`, async function () { + it('should remove trace activities from bufferedReplyActivities if request.channelId !== Channels.Emulator', async function () { const activity = { ...JSON.parse(JSON.stringify(incomingMessage)), type: ActivityTypes.Invoke, @@ -778,7 +777,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should keep trace activities from bufferedReplyActivities if request.channelId === Channels.Emulator`, async function () { + it('should keep trace activities from bufferedReplyActivities if request.channelId === Channels.Emulator', async function () { const activity = { ...JSON.parse(JSON.stringify(incomingMessage)), type: ActivityTypes.Invoke, @@ -803,7 +802,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`processActivity() should not respect invokeResponses if the incoming request wasn't of type "invoke"`, async function () { + it('processActivity() should not respect invokeResponses if the incoming request wasn\'t of type "invoke"', async function () { const { response, verify } = await processActivity(async (context) => { await context.sendActivity({ type: 'invokeResponse', text: 'InvokeResponse Test' }); }); @@ -812,25 +811,25 @@ describe('BotFrameworkAdapter', function () { verify(); }); - it(`should processActivity().`, async function () { + it('should processActivity().', async function () { const { response, verify } = await processActivity((context) => { - assert(context, `context not passed.`); + assert(context, 'context not passed.'); }); assertResponse(response, StatusCodes.OK); verify(); }); - it(`should processActivity() sent as body.`, async function () { + it('should processActivity() sent as body.', async function () { const { response, verify } = await processActivity((context) => { - assert(context, `context not passed.`); + assert(context, 'context not passed.'); }); assertResponse(response, StatusCodes.OK); verify(); }); - it(`should check timestamp in processActivity() sent as body.`, async function () { + it('should check timestamp in processActivity() sent as body.', async function () { const activity = { ...incomingMessage, timestamp: '2018-10-01T14:14:54.790Z', @@ -839,25 +838,25 @@ describe('BotFrameworkAdapter', function () { const { response, verify } = await processActivity( (context) => { - assert(context, `context not passed.`); + assert(context, 'context not passed.'); assert.strictEqual( typeof context.activity.timestamp, 'object', - `'context.activity.timestamp' is not a date` + "'context.activity.timestamp' is not a date" ); - assert(context.activity.timestamp instanceof Date, `'context.activity.timestamp' is not a date`); + assert(context.activity.timestamp instanceof Date, "'context.activity.timestamp' is not a date"); assert.strictEqual( typeof context.activity.localTimestamp, 'object', - `'context.activity.localTimestamp' is not a date` + "'context.activity.localTimestamp' is not a date" ); assert( context.activity.localTimestamp instanceof Date, - `'context.activity.localTimestamp' is not a date` + "'context.activity.localTimestamp' is not a date" ); }, { activity } @@ -867,7 +866,7 @@ describe('BotFrameworkAdapter', function () { verify(); }); - it(`should reject a bogus request sent to processActivity().`, async function () { + it('should reject a bogus request sent to processActivity().', async function () { await assert.rejects( processActivity(() => null, { activity: 'bogus' }), (err) => { @@ -879,7 +878,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should reject a request without activity type sent to processActivity().`, async function () { + it('should reject a request without activity type sent to processActivity().', async function () { await assert.rejects( processActivity(() => null, { activity: { text: 'foo' } }), (err) => { @@ -891,7 +890,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should migrate location of tenantId for MS Teams processActivity().`, async function () { + it('should migrate location of tenantId for MS Teams processActivity().', async function () { const activity = TurnContext.applyConversationReference( { type: 'message', text: 'foo', channelData: { tenant: { id: '1234' } } }, reference, @@ -904,7 +903,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.activity.conversation.tenantId, '1234', - `should have copied tenant id from channelData to conversation address` + 'should have copied tenant id from channelData to conversation address' ); }, { activity } @@ -914,7 +913,7 @@ describe('BotFrameworkAdapter', function () { verify(); }); - it(`receive a semanticAction with a state property on the activity in processActivity().`, async function () { + it('receive a semanticAction with a state property on the activity in processActivity().', async function () { const activity = TurnContext.applyConversationReference( { type: 'message', text: 'foo', semanticAction: { state: 'start' } }, reference, @@ -962,7 +961,7 @@ describe('BotFrameworkAdapter', function () { assert(fake.called, 'bot handler was not called'); }; - it(`should ignore received and generate callerId on parsed activity in processActivity()`, async function () { + it('should ignore received and generate callerId on parsed activity in processActivity()', async function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, @@ -975,7 +974,7 @@ describe('BotFrameworkAdapter', function () { }); }); - it(`should generate a skill callerId property on the activity in processActivity()`, async function () { + it('should generate a skill callerId property on the activity in processActivity()', async function () { const skillAppId = '00000000-0000-0000-0000-000000000000'; const skillConsumerAppId = '00000000-0000-0000-0000-000000000001'; @@ -1000,7 +999,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should discard & not generate callerId on the parsed activity with disabledAuth`, async function () { + it('should discard & not generate callerId on the parsed activity with disabledAuth', async function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, @@ -1017,7 +1016,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should generate a US Gov cloud callerId property on the activity in processActivity()`, async function () { + it('should generate a US Gov cloud callerId property on the activity in processActivity()', async function () { const skillAppId = '00000000-0000-0000-0000-000000000000'; const incoming = TurnContext.applyConversationReference({ type: 'message', text: 'foo' }, reference, true); @@ -1039,7 +1038,7 @@ describe('BotFrameworkAdapter', function () { }); }); - it(`should receive a properties property on the conversation object in processActivity().`, async function () { + it('should receive a properties property on the conversation object in processActivity().', async function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, @@ -1055,7 +1054,7 @@ describe('BotFrameworkAdapter', function () { verify(); }); - it(`should fail to auth on call to processActivity().`, async function () { + it('should fail to auth on call to processActivity().', async function () { await assert.rejects( processActivity(() => null, { testAdapterArgs: { failAuth: true } }), (err) => { @@ -1068,7 +1067,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should return 500 error on bot logic exception during processActivity().`, async function () { + it('should return 500 error on bot logic exception during processActivity().', async function () { await assert.rejects( processActivity(() => { throw new Error('bot exception'); @@ -1104,42 +1103,42 @@ describe('BotFrameworkAdapter', function () { assert(fake.called); }; - it(`should createConversation().`, async function () { + it('should createConversation().', async function () { await createConversation(reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); - assert.strictEqual(context.activity.conversation.id, 'convo2', `request has invalid conversation.id.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); + assert.strictEqual(context.activity.conversation.id, 'convo2', 'request has invalid conversation.id.'); }); }); - it(`should createConversation() with parameters.`, async function () { + it('should createConversation() with parameters.', async function () { await createConversation( reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); - assert(context.activity.conversation, `activity has no conversation`); - assert(context.activity.conversation.isGroup, `activity isGroup is not true`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); + assert(context.activity.conversation, 'activity has no conversation'); + assert(context.activity.conversation.isGroup, 'activity isGroup is not true'); }, { createConversationParams: { isGroup: true } } ); }); - it(`should createConversation() and assign new serviceUrl.`, async function () { + it('should createConversation() and assign new serviceUrl.', async function () { await createConversation( reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); assert.strictEqual( context.activity.conversation.id, 'convo2', - `request has invalid conversation.id.` + 'request has invalid conversation.id.' ); assert.strictEqual( context.activity.serviceUrl, 'https://example.org/channel2', - `request has invalid conversation.id.` + 'request has invalid conversation.id.' ); }, { @@ -1148,7 +1147,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should fail to createConversation() if serviceUrl missing.`, async function () { + it('should fail to createConversation() if serviceUrl missing.', async function () { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { serviceUrl, ...bogusReference } = Object.assign({}, reference); @@ -1163,7 +1162,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should createConversation() for Teams.`, async function () { + it('should createConversation() for Teams.', async function () { const tenantReference = { ...reference, channelId: 'msteams', @@ -1171,29 +1170,29 @@ describe('BotFrameworkAdapter', function () { }; await createConversation(tenantReference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); - assert(context.activity.conversation, `request has invalid conversation.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); + assert(context.activity.conversation, 'request has invalid conversation.'); - assert.strictEqual(context.activity.conversation.id, 'convo2', `request has invalid conversation.id.`); + assert.strictEqual(context.activity.conversation.id, 'convo2', 'request has invalid conversation.id.'); assert.strictEqual( context.activity.conversation.tenantId, tenantReference.conversation.tenantId, - `request has invalid tenantId on conversation.` + 'request has invalid tenantId on conversation.' ); assert.strictEqual( context.activity.channelData.tenant.id, tenantReference.conversation.tenantId, - `request has invalid tenantId in channelData.` + 'request has invalid tenantId in channelData.' ); }); }); }); describe('sendActivities()', function () { - it(`should deliver a single activity using sendActivities().`, async function () { + it('should deliver a single activity using sendActivities().', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const responses = await adapter.sendActivities(context, [outgoingMessage]); @@ -1203,17 +1202,17 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should deliver multiple activities using sendActivities().`, async function () { + it('should deliver multiple activities using sendActivities().', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const responses = await adapter.sendActivities(context, [outgoingMessage, outgoingMessage]); - assert(responses.length === 2, `invalid number of responses returned.`); + assert(responses.length === 2, 'invalid number of responses returned.'); }); describe('with delay', function () { this.timeout(1500); - it(`should wait for a 'delay' using sendActivities().`, async function () { + it("should wait for a 'delay' using sendActivities().", async function () { const start = new Date().getTime(); const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); @@ -1226,11 +1225,11 @@ describe('BotFrameworkAdapter', function () { const end = new Date().getTime(); - assert(responses.length === 3, `invalid number of responses returned.`); - assert(end - start >= 500, `didn't pause for delay.`); + assert(responses.length === 3, 'invalid number of responses returned.'); + assert(end - start >= 500, "didn't pause for delay."); }); - it(`should wait for a 'delay' withut a value using sendActivities().`, async function () { + it("should wait for a 'delay' withut a value using sendActivities().", async function () { const start = new Date().getTime(); const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); @@ -1243,13 +1242,13 @@ describe('BotFrameworkAdapter', function () { const end = new Date().getTime(); - assert(responses.length === 3, `invalid number of responses returned.`); - assert(end - start >= 500, `didn't pause for delay.`); + assert(responses.length === 3, 'invalid number of responses returned.'); + assert(end - start >= 500, "didn't pause for delay."); }); }); }); - it(`should return bots invokeResponse`, async function () { + it('should return bots invokeResponse', async function () { const { response, verify } = await processActivity( (context) => context.sendActivity({ type: 'invokeResponse', value: { status: 200, body: 'body' } }), { activity: incomingInvoke } @@ -1258,7 +1257,7 @@ describe('BotFrameworkAdapter', function () { verify(); }); - it(`should return 501 error if bot fails to return an 'invokeResponse'.`, async function () { + it("should return 501 error if bot fails to return an 'invokeResponse'.", async function () { await assert.rejects( processActivity(() => undefined, { activity: incomingInvoke }), (err) => { @@ -1271,28 +1270,28 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should fail to sendActivities().`, async function () { + it('should fail to sendActivities().', async function () { const adapter = new AdapterUnderTest(undefined, { failOperation: true }); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, outgoingMessage); await assert.rejects(adapter.sendActivities(context, [copy])); }); - it(`should fail to sendActivities() without a serviceUrl.`, async function () { + it('should fail to sendActivities() without a serviceUrl.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, outgoingMessage, { serviceUrl: undefined }); await assert.rejects(adapter.sendActivities(context, [copy])); }); - it(`should fail to sendActivities() without a conversation.id.`, async function () { + it('should fail to sendActivities() without a conversation.id.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, outgoingMessage, { conversation: undefined }); await assert.rejects(adapter.sendActivities(context, [copy])); }); - it(`should post to a whole conversation using sendActivities() if replyToId missing.`, async function () { + it('should post to a whole conversation using sendActivities() if replyToId missing.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, outgoingMessage, { replyToId: undefined }); @@ -1303,55 +1302,55 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should updateActivity().`, async function () { + it('should updateActivity().', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const result = await adapter.updateActivity(context, incomingMessage); assert.deepStrictEqual(result, { id: '5678' }, 'result is expected'); }); - it(`should fail to updateActivity() if serviceUrl missing.`, async function () { + it('should fail to updateActivity() if serviceUrl missing.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, incomingMessage, { serviceUrl: undefined }); await assert.rejects(adapter.updateActivity(context, copy)); }); - it(`should fail to updateActivity() if conversation missing.`, async function () { + it('should fail to updateActivity() if conversation missing.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, incomingMessage, { conversation: undefined }); await assert.rejects(adapter.updateActivity(context, copy)); }); - it(`should fail to updateActivity() if activity.id missing.`, async function () { + it('should fail to updateActivity() if activity.id missing.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, incomingMessage, { id: undefined }); await assert.rejects(adapter.updateActivity(context, copy)); }); - it(`should deleteActivity().`, async function () { + it('should deleteActivity().', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); await adapter.deleteActivity(context, reference); }); - it(`should fail to deleteActivity() if serviceUrl missing.`, async function () { + it('should fail to deleteActivity() if serviceUrl missing.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, reference, { serviceUrl: undefined }); await assert.rejects(adapter.deleteActivity(context, copy)); }); - it(`should fail to deleteActivity() if conversation missing.`, async function () { + it('should fail to deleteActivity() if conversation missing.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, reference, { conversation: undefined }); await assert.rejects(adapter.deleteActivity(context, copy)); }); - it(`should fail to deleteActivity() if activityId missing.`, async function () { + it('should fail to deleteActivity() if activityId missing.', async function () { const adapter = new AdapterUnderTest(); const context = new TurnContext(adapter, incomingMessage); const copy = Object.assign({}, reference, { activityId: undefined }); @@ -1362,7 +1361,7 @@ describe('BotFrameworkAdapter', function () { process.version }; ${os.type()} ${os.release()}; ${os.arch()})`; - it(`should create a User-Agent header with the same info as the host machine.`, async function () { + it('should create a User-Agent header with the same info as the host machine.', async function () { nock(reference.serviceUrl) .matchHeader('user-agent', (val) => val.endsWith(userAgent)) .post('/v3/conversations/convo1/activities/1234') @@ -1375,7 +1374,7 @@ describe('BotFrameworkAdapter', function () { }); }); - it(`should still add Botbuilder User-Agent header when custom requestPolicyFactories are provided.`, async function () { + it('should still add Botbuilder User-Agent header when custom requestPolicyFactories are provided.', async function () { nock(reference.serviceUrl) .matchHeader('user-agent', (val) => val.endsWith(userAgent)) .post('/v3/conversations/convo1/activities/1234') @@ -1397,7 +1396,7 @@ describe('BotFrameworkAdapter', function () { connector.GovernmentChannelValidation.OpenIdMetadataEndpoint = govChannelValidationOidMetadataEndpoint; }); - it(`should set openIdMetadata property on ChannelValidation`, function () { + it('should set openIdMetadata property on ChannelValidation', function () { const testEndpoint = 'http://rainbows.com'; new BotFrameworkAdapter({ openIdMetadata: testEndpoint }); @@ -1405,30 +1404,30 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( testEndpoint, connector.ChannelValidation.OpenIdMetadataEndpoint, - `ChannelValidation.OpenIdMetadataEndpoint was not set.` + 'ChannelValidation.OpenIdMetadataEndpoint was not set.' ); }); - it(`should set openIdMetadata property on GovernmentChannelValidation`, function () { + it('should set openIdMetadata property on GovernmentChannelValidation', function () { const testEndpoint = 'http://azure.com/configuration'; new BotFrameworkAdapter({ openIdMetadata: testEndpoint }); assert.strictEqual( testEndpoint, connector.GovernmentChannelValidation.OpenIdMetadataEndpoint, - `GovernmentChannelValidation.OpenIdMetadataEndpoint was not set.` + 'GovernmentChannelValidation.OpenIdMetadataEndpoint was not set.' ); }); }); - it(`should set oAuthEndpoint property on connector client`, function () { + it('should set oAuthEndpoint property on connector client', function () { const testEndpoint = 'http://rainbows.com'; const adapter = new BotFrameworkAdapter({ oAuthEndpoint: testEndpoint }); const url = adapter.oauthApiUrl(); - assert.strictEqual(testEndpoint, url, `adapter.oauthApiUrl is incorrect.`); + assert.strictEqual(testEndpoint, url, 'adapter.oauthApiUrl is incorrect.'); }); - it(`should throw error if missing serviceUrl in deleteConversationMember()`, async function () { + it('should throw error if missing serviceUrl in deleteConversationMember()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.deleteConversationMember({ activity: {} }), @@ -1436,7 +1435,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing conversation in deleteConversationMember()`, async function () { + it('should throw error if missing conversation in deleteConversationMember()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.deleteConversationMember({ activity: { serviceUrl: 'https://test.com' } }), @@ -1444,7 +1443,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing conversation.id in deleteConversationMember()`, async function () { + it('should throw error if missing conversation.id in deleteConversationMember()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.deleteConversationMember({ activity: { serviceUrl: 'https://test.com', conversation: {} } }), @@ -1452,7 +1451,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should call client.conversations deleteConversationMember()`, async function () { + it('should call client.conversations deleteConversationMember()', async function () { const conversations = new Conversations({ id: 'convo1' }); mockResponse(conversations, 'deleteConversationMember', 200); @@ -1468,7 +1467,7 @@ describe('BotFrameworkAdapter', function () { sandbox.verify(); }); - it(`should throw error if missing serviceUrl in getActivityMembers()`, async function () { + it('should throw error if missing serviceUrl in getActivityMembers()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getActivityMembers({ activity: {} }), @@ -1476,7 +1475,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing conversation in getActivityMembers()`, async function () { + it('should throw error if missing conversation in getActivityMembers()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getActivityMembers({ activity: { serviceUrl: 'https://test.com' } }), @@ -1484,7 +1483,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing conversation.id in getActivityMembers()`, async function () { + it('should throw error if missing conversation.id in getActivityMembers()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getActivityMembers({ activity: { serviceUrl: 'https://test.com', conversation: {} } }), @@ -1492,7 +1491,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing activityId in getActivityMembers()`, async function () { + it('should throw error if missing activityId in getActivityMembers()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getActivityMembers({ @@ -1502,7 +1501,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should call client.conversations getActivityMembers()`, async function () { + it('should call client.conversations getActivityMembers()', async function () { const conversations = new Conversations({ id: 'convo1' }); mockResponse(conversations, 'getActivityMembers', 200); @@ -1519,7 +1518,7 @@ describe('BotFrameworkAdapter', function () { sandbox.verify(); }); - it(`should throw error if missing serviceUrl in getConversationMembers()`, async function () { + it('should throw error if missing serviceUrl in getConversationMembers()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getConversationMembers({ activity: {} }), @@ -1527,7 +1526,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing conversation in getConversationMembers()`, async function () { + it('should throw error if missing conversation in getConversationMembers()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getConversationMembers({ activity: { serviceUrl: 'https://test.com' } }), @@ -1535,7 +1534,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing conversation.id in getConversationMembers()`, async function () { + it('should throw error if missing conversation.id in getConversationMembers()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getConversationMembers({ activity: { serviceUrl: 'https://test.com', conversation: {} } }), @@ -1543,7 +1542,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should call client.conversations getConversationMembers()`, async function () { + it('should call client.conversations getConversationMembers()', async function () { const conversations = new Conversations({ id: 'convo1' }); mockResponse(conversations, 'getConversationMembers', 200); @@ -1558,7 +1557,7 @@ describe('BotFrameworkAdapter', function () { sandbox.verify(); }); - it(`should throw error if missing from in getUserToken()`, async function () { + it('should throw error if missing from in getUserToken()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getUserToken({ activity: {}, turnState: new Map() }), @@ -1566,7 +1565,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing from.id in getUserToken()`, async function () { + it('should throw error if missing from.id in getUserToken()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getUserToken({ activity: { from: {} }, turnState: new Map() }), @@ -1574,7 +1573,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing connectionName`, async function () { + it('should throw error if missing connectionName', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getUserToken({ activity: { from: { id: 'some id' } }, turnState: new Map() }), @@ -1582,7 +1581,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should get the user token when all params are provided`, async function () { + it('should get the user token when all params are provided', async function () { const expectedToken = { token: 'yay! a token!', _response: { status: 200 } }; const getToken = sandbox.fake(() => Promise.resolve(expectedToken)); @@ -1605,7 +1604,7 @@ describe('BotFrameworkAdapter', function () { assert.deepStrictEqual(channelData, { channelId: 'The Facebook', code: undefined }); }); - it(`should throw error if missing from in signOutUser()`, async function () { + it('should throw error if missing from in signOutUser()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.signOutUser({ activity: {}, turnState: new Map() }), @@ -1613,7 +1612,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing from.id in signOutUser()`, async function () { + it('should throw error if missing from.id in signOutUser()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.signOutUser({ activity: { from: {} }, turnState: new Map() }), @@ -1621,7 +1620,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should call client.userToken signOut()`, async function () { + it('should call client.userToken signOut()', async function () { const userToken = new UserToken('token'); mockResponse(userToken, 'signOut', 200); @@ -1634,7 +1633,7 @@ describe('BotFrameworkAdapter', function () { sandbox.verify(); }); - it(`should throw error if missing from in getAadTokens()`, async function () { + it('should throw error if missing from in getAadTokens()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getAadTokens({ activity: {}, turnState: new Map() }), @@ -1642,7 +1641,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing from.id in getAadTokens()`, async function () { + it('should throw error if missing from.id in getAadTokens()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getAadTokens({ activity: { from: {} }, turnState: new Map() }), @@ -1650,7 +1649,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should call client.userToken getAadTokens()`, async function () { + it('should call client.userToken getAadTokens()', async function () { const userToken = new UserToken('token'); mockResponse(userToken, 'getAadTokens', 200); @@ -1686,7 +1685,7 @@ describe('BotFrameworkAdapter', function () { }; }; - it(`should throw if userName != from.id`, async function () { + it('should throw if userName != from.id', async function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( @@ -1696,18 +1695,18 @@ describe('BotFrameworkAdapter', function () { new MicrosoftAppCredentials('abc', 'abc'), 'invalidId' ), - ReferenceError(`cannot retrieve OAuth signin link for a user that's different from the conversation`) + ReferenceError("cannot retrieve OAuth signin link for a user that's different from the conversation") ); }); - it(`should return return a sign-in URL with context and connectionName`, async function () { + it('should return return a sign-in URL with context and connectionName', async function () { const { adapter, context, verify } = getMockedAdapter(); const response = await adapter.getSignInLink(context, 'aConnectionName'); assert(response, mockedUrl); verify(); }); - it(`should return return a sign-in URL with context connectionName, oauthAppCredentials`, async function () { + it('should return return a sign-in URL with context connectionName, oauthAppCredentials', async function () { const { adapter, context, verify } = getMockedAdapter(); const response = await adapter.getSignInLink( context, @@ -1718,7 +1717,7 @@ describe('BotFrameworkAdapter', function () { verify(); }); - it(`should return return a sign-in URL with context connectionName, oauthAppCredentials, userId, finalRedirect`, async function () { + it('should return return a sign-in URL with context connectionName, oauthAppCredentials, userId, finalRedirect', async function () { const { adapter, context, verify } = getMockedAdapter(); const response = await adapter.getSignInLink( context, @@ -1752,37 +1751,37 @@ describe('BotFrameworkAdapter', function () { }; }; - it(`should throw error if missingConnectionName in getSignInResource`, async function () { + it('should throw error if missingConnectionName in getSignInResource', async function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.getSignInResource(context), - new Error(`getUserToken() requires a connectionName but none was provided.`) + new Error('getUserToken() requires a connectionName but none was provided.') ); }); - it(`should throw error if missing Activity.from in getSignInResource`, async function () { + it('should throw error if missing Activity.from in getSignInResource', async function () { const activity = createActivity(); activity.from = undefined; const { adapter, context } = getMockedAdapter(activity); await assert.rejects( adapter.getSignInResource(context, 'TestConnectionName'), - new Error(`BotFrameworkAdapter.getSignInResource(): missing from or from.id`) + new Error('BotFrameworkAdapter.getSignInResource(): missing from or from.id') ); }); - it(`should throw error if missing Activity.from.id in getSignInResource`, async function () { + it('should throw error if missing Activity.from.id in getSignInResource', async function () { const activity = createActivity(); activity.from.id = undefined; const { adapter, context } = getMockedAdapter(activity); await assert.rejects( adapter.getSignInResource(context, 'TestConnectionName'), - new Error(`BotFrameworkAdapter.getSignInResource(): missing from or from.id`) + new Error('BotFrameworkAdapter.getSignInResource(): missing from or from.id') ); }); - it(`should throw error if userId does not match Activity.from.id in getSignInResource`, async function () { + it('should throw error if userId does not match Activity.from.id in getSignInResource', async function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.getSignInResource(context, 'TestConnectionName', 'OtherUserId'), @@ -1792,7 +1791,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should call client.botSignIn getSignInResource()`, async function () { + it('should call client.botSignIn getSignInResource()', async function () { const { adapter, context, verify } = getMockedAdapter(); await adapter.getSignInResource(context, 'TestConnectionName', 'ChannelAccount_Id_1'); verify(); @@ -1812,33 +1811,33 @@ describe('BotFrameworkAdapter', function () { return { adapter, context, verify: () => sandbox.verify() }; }; - it(`should throw error if missing ConnectionName in exchangeToken`, async function () { + it('should throw error if missing ConnectionName in exchangeToken', async function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.exchangeToken(context), - new Error(`exchangeToken() requires a connectionName but none was provided.`) + new Error('exchangeToken() requires a connectionName but none was provided.') ); }); - it(`should throw error if missing userId in exchangeToken`, async function () { + it('should throw error if missing userId in exchangeToken', async function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.exchangeToken(context, 'TestConnectionName'), - new Error(`exchangeToken() requires an userId but none was provided.`) + new Error('exchangeToken() requires an userId but none was provided.') ); }); - it(`should throw error if missing Uri and Token properties of TokenExchangeRequest in exchangeToken`, async function () { + it('should throw error if missing Uri and Token properties of TokenExchangeRequest in exchangeToken', async function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.exchangeToken(context, 'TestConnectionName', 'TestUser', {}), new Error( - `BotFrameworkAdapter.exchangeToken(): Either a Token or Uri property is required on the TokenExchangeRequest` + 'BotFrameworkAdapter.exchangeToken(): Either a Token or Uri property is required on the TokenExchangeRequest' ) ); }); - it(`should call client.userToken exchangeAsync()`, async function () { + it('should call client.userToken exchangeAsync()', async function () { const { adapter, context, verify } = getMockedAdapter(); await adapter.exchangeToken(context, 'TestConnectionName', 'userId', { uri: 'http://test' }); verify(); @@ -1865,20 +1864,20 @@ describe('BotFrameworkAdapter', function () { return { adapter, context, tokenStatus, verify: () => sandbox.verify() }; }; - it(`should return the status of every connection the user has`, async function () { + it('should return the status of every connection the user has', async function () { const { adapter, context, tokenStatus, verify } = getMockedAdapter(); const responses = await adapter.getTokenStatus(context, 'userId'); verify(); assert.deepStrictEqual(responses, [tokenStatus]); }); - it(`should call client.userToken getTokenStatus()`, async function () { + it('should call client.userToken getTokenStatus()', async function () { const { adapter, context, verify } = getMockedAdapter(); await adapter.getTokenStatus(context, 'userId'); verify(); }); - it(`should throw error if missing from in getTokenStatus()`, async function () { + it('should throw error if missing from in getTokenStatus()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getTokenStatus({ activity: {}, turnState: new Map() }), @@ -1886,7 +1885,7 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should throw error if missing from.id in getTokenStatus()`, async function () { + it('should throw error if missing from.id in getTokenStatus()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getTokenStatus({ activity: { from: {} }, turnState: new Map() }), @@ -1952,56 +1951,56 @@ describe('BotFrameworkAdapter', function () { assert(fake.called); }; - it(`should succeed.`, async function () { + it('should succeed.', async function () { await continueConversation(reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); - assert.strictEqual(context.activity.type, 'event', `request has invalid type.`); - assert.strictEqual(context.activity.from.id, reference.user.id, `request has invalid from.id.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); + assert.strictEqual(context.activity.type, 'event', 'request has invalid type.'); + assert.strictEqual(context.activity.from.id, reference.user.id, 'request has invalid from.id.'); assert.strictEqual( context.activity.recipient.id, reference.bot.id, - `request has invalid recipient.id.` + 'request has invalid recipient.id.' ); }); }); - it(`should not trust reference.serviceUrl if there is no AppId on the credentials.`, async function () { + it('should not trust reference.serviceUrl if there is no AppId on the credentials.', async function () { await continueConversation(reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); - assert.strictEqual(context.activity.type, 'event', `request has invalid type.`); - assert.strictEqual(context.activity.from.id, reference.user.id, `request has invalid from.id.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); + assert.strictEqual(context.activity.type, 'event', 'request has invalid type.'); + assert.strictEqual(context.activity.from.id, reference.user.id, 'request has invalid from.id.'); assert.strictEqual( context.activity.recipient.id, reference.bot.id, - `request has invalid recipient.id.` + 'request has invalid recipient.id.' ); }); }); - it(`should trust reference.serviceUrl if there is an AppId on the credentials.`, async function () { + it('should trust reference.serviceUrl if there is an AppId on the credentials.', async function () { await continueConversation(reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); - assert.strictEqual(context.activity.type, 'event', `request has invalid type.`); - assert.strictEqual(context.activity.from.id, reference.user.id, `request has invalid from.id.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); + assert.strictEqual(context.activity.type, 'event', 'request has invalid type.'); + assert.strictEqual(context.activity.from.id, reference.user.id, 'request has invalid from.id.'); assert.strictEqual( context.activity.recipient.id, reference.bot.id, - `request has invalid recipient.id.` + 'request has invalid recipient.id.' ); }); }); - it(`should work with oAuthScope and logic passed in.`, async function () { + it('should work with oAuthScope and logic passed in.', async function () { const oauthScope = 'TestTest'; await continueConversation( reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); assert.strictEqual(context.activity.type, 'event'); assert.strictEqual(context.activity.from.id, reference.user.id); assert.strictEqual(context.activity.recipient.id, reference.bot.id); @@ -2011,12 +2010,12 @@ describe('BotFrameworkAdapter', function () { ); }); - it(`should work with Gov cloud and only logic passed in.`, async function () { + it('should work with Gov cloud and only logic passed in.', async function () { await continueConversation( reference, (context) => { - assert(context, `context not passed.`); - assert(context.activity, `context has no request.`); + assert(context, 'context not passed.'); + assert(context.activity, 'context has no request.'); assert.strictEqual(context.activity.type, 'event'); assert.strictEqual(context.activity.from.id, reference.user.id); @@ -2035,21 +2034,21 @@ describe('BotFrameworkAdapter', function () { }); describe('getConversations', function () { - it(`should throw error if missing serviceUrl parameter in getConversations()`, async function () { + it('should throw error if missing serviceUrl parameter in getConversations()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects(adapter.getConversations(), { message: 'createConnectorClient() not passed serviceUrl.', }); }); - it(`should throw error if missing Activity.serviceUrl in getConversations()`, async function () { + it('should throw error if missing Activity.serviceUrl in getConversations()', async function () { const adapter = new AdapterUnderTest(); await assert.rejects(adapter.getConversations({ activity: {} }), { message: 'createConnectorClient() not passed serviceUrl.', }); }); - it(`should call client.conversations getConversations after getOrCreateConnectorClient`, async function () { + it('should call client.conversations getConversations after getOrCreateConnectorClient', async function () { const conversations = new Conversations({ id: 'convo1' }); mockResponse(conversations, 'getConversations', 200); @@ -2065,7 +2064,7 @@ describe('BotFrameworkAdapter', function () { sandbox.verify(); }); - it(`should call client.conversations getConversations after createConnectorClient`, async function () { + it('should call client.conversations getConversations after createConnectorClient', async function () { const conversations = new Conversations({ id: 'convo1' }); mockResponse(conversations, 'getConversations', 200); @@ -2081,7 +2080,7 @@ describe('BotFrameworkAdapter', function () { }); describe('processActivityDirect', function () { - it(`should throw error with stack when runMiddleware() fails`, async function () { + it('should throw error with stack when runMiddleware() fails', async function () { const adapter = new BotFrameworkAdapter(); sandbox.stub(adapter, 'runMiddleware').throws({ stack: 'test-error' }); @@ -2093,7 +2092,7 @@ describe('BotFrameworkAdapter', function () { sandbox.verify(); }); - it(`should throw generic error when runMiddleware() fails`, async function () { + it('should throw generic error when runMiddleware() fails', async function () { const adapter = new BotFrameworkAdapter(); sandbox.stub(adapter, 'runMiddleware').throws({ message: 'test-error' }); diff --git a/libraries/botbuilder/tests/botFrameworkHttpClient.test.js b/libraries/botbuilder/tests/botFrameworkHttpClient.test.js index 562f062b4f..e7068ff9ff 100644 --- a/libraries/botbuilder/tests/botFrameworkHttpClient.test.js +++ b/libraries/botbuilder/tests/botFrameworkHttpClient.test.js @@ -203,7 +203,7 @@ describe('BotFrameworkHttpClient', function () { assert.strictEqual(activity.recipient, undefined); }); - it(`should restore sent activity's relatesTo to original value`, async function () { + it("should restore sent activity's relatesTo to original value", async function () { nock('http://skillUrl') .post('/api/good') .matchHeader(ConversationConstants.ConversationIdHttpHeaderName, 'conversationId') diff --git a/libraries/botbuilder/tests/channelServiceHandler.test.js b/libraries/botbuilder/tests/channelServiceHandler.test.js index d7023a42f9..97de7039b9 100644 --- a/libraries/botbuilder/tests/channelServiceHandler.test.js +++ b/libraries/botbuilder/tests/channelServiceHandler.test.js @@ -2,7 +2,7 @@ const assert = require('assert'); const sinon = require('sinon'); const { ActivityTypes, StatusCodes } = require('botbuilder-core'); const { ChannelServiceHandler } = require('../'); -const { isEmpty } = require('lodash'); +const isEmpty = require('lodash/isEmpty'); const { AuthenticationConfiguration, diff --git a/libraries/botbuilder/tests/channelServiceRoutes.test.js b/libraries/botbuilder/tests/channelServiceRoutes.test.js index 8f2ae52bac..cea8dc830e 100644 --- a/libraries/botbuilder/tests/channelServiceRoutes.test.js +++ b/libraries/botbuilder/tests/channelServiceRoutes.test.js @@ -31,16 +31,16 @@ class MockResponse { describe('channelServiceRoutes', function () { let sandbox; - beforeEach(() => { + beforeEach(function () { sandbox = sinon.createSandbox(); }); - afterEach(() => { + afterEach(function () { sandbox.restore(); }); - describe('constructor()', () => { - it('should succeed with correct parameters', () => { + describe('constructor()', function () { + it('should succeed with correct parameters', function () { const testHandler = sandbox.mock(ChannelServiceHandler); const channelServiceRoutes = new ChannelServiceRoutes(testHandler); @@ -48,9 +48,9 @@ describe('channelServiceRoutes', function () { }); }); - describe('register()', () => { + describe('register()', function () { let channel, server; - beforeEach(() => { + beforeEach(function () { const testHandler = sandbox.mock(ChannelServiceHandler); channel = new ChannelServiceRoutes(testHandler); server = { @@ -61,7 +61,7 @@ describe('channelServiceRoutes', function () { }; }); - it('should register webservers', () => { + it('should register webservers', function () { channel.register(server, 'test'); assert(server.post.calledWith('test/v3/conversations/:conversationId/activities')); @@ -79,7 +79,7 @@ describe('channelServiceRoutes', function () { }); }); - describe('private functions', () => { + describe('private functions', function () { const handlers = {}; const req = { body: { @@ -102,18 +102,18 @@ describe('channelServiceRoutes', function () { let readActivityStub; let readBodyStub; - afterEach(() => { + afterEach(function () { ChannelServiceRoutes.handleError = errorHandler; - if (!!readActivityStub) { + if (readActivityStub) { readActivityStub.restore(); } - if (!!readBodyStub) { + if (readBodyStub) { readBodyStub.restore(); } }); - describe('processSendToConversation()', () => { - it('should end successfully', (done) => { + describe('processSendToConversation()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -133,7 +133,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleSendToConversation error', (done) => { + it('should throw a handleSendToConversation error', function (done) { try { const resourceResponse = { error: 'handleSendToConversation error' }; const res = new MockResponse( @@ -162,7 +162,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a readActivity error', (done) => { + it('should throw a readActivity error', function (done) { try { const resourceResponse = { error: 'readActivity error' }; const res = new MockResponse( @@ -195,8 +195,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processReplyToActivity()', () => { - it('should end successfully', (done) => { + describe('processReplyToActivity()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -216,7 +216,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleReplyToActivity error', (done) => { + it('should throw a handleReplyToActivity error', function (done) { try { const resourceResponse = { error: 'handleReplyToActivity error' }; const res = new MockResponse( @@ -246,7 +246,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a readActivity error', (done) => { + it('should throw a readActivity error', function (done) { try { const resourceResponse = { error: 'readActivity error' }; const res = new MockResponse( @@ -279,8 +279,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processUpdateActivity()', () => { - it('should end successfully', (done) => { + describe('processUpdateActivity()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -300,7 +300,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleUpdateActivity error', (done) => { + it('should throw a handleUpdateActivity error', function (done) { try { const resourceResponse = { error: 'handleUpdateActivity error' }; const res = new MockResponse( @@ -330,7 +330,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a readActivity error', (done) => { + it('should throw a readActivity error', function (done) { try { const resourceResponse = { error: 'readActivity error' }; const res = new MockResponse( @@ -363,8 +363,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processDeleteActivity()', () => { - it('should end successfully', (done) => { + describe('processDeleteActivity()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -384,7 +384,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleDeleteActivity error', (done) => { + it('should throw a handleDeleteActivity error', function (done) { try { const resourceResponse = { error: 'handleDeleteActivity error' }; const res = new MockResponse( @@ -415,8 +415,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processGetActivityMembers()', () => { - it('should end successfully', (done) => { + describe('processGetActivityMembers()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -436,7 +436,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleGetActivityMembers error', (done) => { + it('should throw a handleGetActivityMembers error', function (done) { try { const resourceResponse = { error: 'handleGetActivityMembers error' }; const res = new MockResponse( @@ -467,8 +467,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processCreateConversation()', () => { - it('should end successfully', (done) => { + describe('processCreateConversation()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -488,7 +488,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleCreateConversation error', (done) => { + it('should throw a handleCreateConversation error', function (done) { try { const resourceResponse = { error: 'handleCreateConversation error' }; const res = new MockResponse( @@ -519,8 +519,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processGetConversations()', () => { - it('should end successfully', (done) => { + describe('processGetConversations()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -540,7 +540,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleGetConversations error', (done) => { + it('should throw a handleGetConversations error', function (done) { try { const resourceResponse = { error: 'handleGetConversations error' }; const res = new MockResponse( @@ -571,8 +571,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processGetConversationMembers()', () => { - it('should end successfully', (done) => { + describe('processGetConversationMembers()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -592,7 +592,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleGetConversationMembers error', (done) => { + it('should throw a handleGetConversationMembers error', function (done) { try { const resourceResponse = { error: 'handleGetConversationMembers error' }; const res = new MockResponse( @@ -623,8 +623,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processGetConversationPagedMembers()', () => { - it('should end successfully', (done) => { + describe('processGetConversationPagedMembers()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -644,7 +644,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleGetConversationPagedMembers error', (done) => { + it('should throw a handleGetConversationPagedMembers error', function (done) { try { const resourceResponse = { error: 'handleGetConversationPagedMembers error' }; const res = new MockResponse( @@ -675,8 +675,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processDeleteConversationMember()', () => { - it('should end successfully', (done) => { + describe('processDeleteConversationMember()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -696,7 +696,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleDeleteConversationMember error', (done) => { + it('should throw a handleDeleteConversationMember error', function (done) { try { const resourceResponse = { error: 'handleDeleteConversationMember error' }; const res = new MockResponse( @@ -727,8 +727,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processSendConversationHistory()', () => { - it('should end successfully', (done) => { + describe('processSendConversationHistory()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -748,7 +748,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleSendConversationHistory error', (done) => { + it('should throw a handleSendConversationHistory error', function (done) { try { const resourceResponse = { error: 'handleSendConversationHistory error' }; const res = new MockResponse( @@ -778,7 +778,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a readBody error', (done) => { + it('should throw a readBody error', function (done) { try { const resourceResponse = { error: 'readBody error' }; const res = new MockResponse( @@ -811,8 +811,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('processUploadAttachment()', () => { - it('should end successfully', (done) => { + describe('processUploadAttachment()', function () { + it('should end successfully', function (done) { try { const res = new MockResponse( { @@ -832,7 +832,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a handleUploadAttachment error', (done) => { + it('should throw a handleUploadAttachment error', function (done) { try { const resourceResponse = { error: 'handleUploadAttachment error' }; const res = new MockResponse( @@ -862,7 +862,7 @@ describe('channelServiceRoutes', function () { } }); - it('should throw a readBody error', (done) => { + it('should throw a readBody error', function (done) { try { const resourceResponse = { error: 'readBody error' }; const res = new MockResponse( @@ -895,8 +895,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('readActivity()', async () => { - it('should throw with invalid body', async () => { + describe('readActivity()', function () { + it('should throw with invalid body', async function () { const req = sandbox.mock(WebRequest); req.body = {}; @@ -905,7 +905,7 @@ describe('channelServiceRoutes', function () { }); }); - it('should return activity', async () => { + it('should return activity', async function () { const req = sandbox.mock(WebRequest); req.body = { type: 'testactivity', @@ -920,8 +920,8 @@ describe('channelServiceRoutes', function () { }); }); - describe('readBody()', () => { - it('should return request.body from "on" events', (done) => { + describe('readBody()', function () { + it('should return request.body from "on" events', function (done) { const source = { test: true }; const request = { diff --git a/libraries/botbuilder/tests/eventFactoryTests.test.js b/libraries/botbuilder/tests/eventFactoryTests.test.js index f198b3467a..eab0c29322 100644 --- a/libraries/botbuilder/tests/eventFactoryTests.test.js +++ b/libraries/botbuilder/tests/eventFactoryTests.test.js @@ -8,7 +8,7 @@ describe('EventFactory', function () { describe('createHandoffInitiation', function () { it('should succeed', function () { - const adapter = new TestAdapter(async (context) => { + const adapter = new TestAdapter(async () => { /* no op */ }); const fromId = 'test'; @@ -62,7 +62,7 @@ describe('EventFactory', function () { strictEqual(messageFormEvent, message); const status = JSON.stringify(handoffEvent.value); - strictEqual(status, `{\"state\":\"${state}\",\"message\":\"${message}\"}`); + strictEqual(status, `{"state":"${state}","message":"${message}"}`); assert(handoffEvent.attachments, 'handoffEvent.attachments should not be undefined.'); assert(handoffEvent.id, 'handoffEvent.id should not be undefined.'); strictEqual(handoffEvent.localTimezone, dayjs.tz.guess()); diff --git a/libraries/botbuilder/tests/fileTranscriptStore.test.js b/libraries/botbuilder/tests/fileTranscriptStore.test.js index 4f80db2209..79979e1089 100644 --- a/libraries/botbuilder/tests/fileTranscriptStore.test.js +++ b/libraries/botbuilder/tests/fileTranscriptStore.test.js @@ -53,7 +53,7 @@ describe('The FileTranscriptStore', function () { describe('should log activities', function () { const conversationId = 'logActivitySpec'; let activities; - before(async function () { + before(function () { activities = createActivities(conversationId, startDate); return Promise.all(activities.map((activity) => storage.logActivity(activity))); }); @@ -156,7 +156,7 @@ describe('The FileTranscriptStore', function () { describe('should retrieve activities', function () { const conversationId = 'retrieveActivitiesSpec'; let activities; - before(async function () { + before(function () { activities = createActivities(conversationId, startDate, 60); storage = new FileTranscriptStore(workingFolder); return Promise.all(activities.map((activity) => storage.logActivity(activity))); @@ -182,7 +182,6 @@ describe('The FileTranscriptStore', function () { it('as expected when a startDate is provided', async function () { let pagedResult = {}; - const i = activities.length / FileTranscriptStore.PageSize; let continuationToken; const seen = new Proxy( {}, @@ -246,7 +245,7 @@ describe('The FileTranscriptStore', function () { describe('should list transcripts', function () { let activities; - before(async function () { + before(function () { activities = []; let ct = 100; while (ct--) { diff --git a/libraries/botbuilder/tests/inspectionMiddleware.test.js b/libraries/botbuilder/tests/inspectionMiddleware.test.js index e481fc919a..fcd1b00dff 100644 --- a/libraries/botbuilder/tests/inspectionMiddleware.test.js +++ b/libraries/botbuilder/tests/inspectionMiddleware.test.js @@ -37,7 +37,7 @@ describe('InspectionMiddleware', function () { assert(adapter.activityBuffer.length === 1, 'expected a single adapter response'); assert(adapter.activityBuffer[0].type === 'message', 'expected a message activity'); - assert(adapter.activityBuffer[0].text === 'hi', `expected text saying 'hi'`); + assert(adapter.activityBuffer[0].text === 'hi', "expected text saying 'hi'"); }); it('should replicate activity data to listening emulator following open and attach', async function () { // set up our expectations in nock - each corresponds to a trace message we expect to receive in the emulator @@ -423,8 +423,8 @@ describe('InspectionMiddleware', function () { assert.strictEqual(adapter.activityBuffer.length, 2); await adapter.receiveActivity(activity); - assert.strictEqual(adapter.activityBuffer.length, 2, `no activities updated.`); - assert.strictEqual(adapter.activityBuffer[1].text, activity.text, `invalid update activity text.`); + assert.strictEqual(adapter.activityBuffer.length, 2, 'no activities updated.'); + assert.strictEqual(adapter.activityBuffer[1].text, activity.text, 'invalid update activity text.'); }); it('should delete activity to trigger turnContext.onDeleteActivity', async function () { @@ -504,7 +504,7 @@ describe('InspectionMiddleware', function () { assert.strictEqual(adapter.activityBuffer.length, 2); await adapter.receiveActivity(activity); - assert.strictEqual(adapter.activityBuffer.length, 1, `no activities deleted.`); + assert.strictEqual(adapter.activityBuffer.length, 1, 'no activities deleted.'); }); it('should throw an error when onTurn next parameter is null', async function () { diff --git a/libraries/botbuilder/tests/skills/conversationIdFactory.js b/libraries/botbuilder/tests/skills/conversationIdFactory.js index c463c89948..69034200bd 100644 --- a/libraries/botbuilder/tests/skills/conversationIdFactory.js +++ b/libraries/botbuilder/tests/skills/conversationIdFactory.js @@ -13,7 +13,7 @@ class ConversationIdFactory extends SkillConversationIdFactoryBase { if (this.disableCreateWithOptions) super.createSkillConversationIdWithOptions(); this.refs[this.skillId] = { conversationReference: TurnContext.getConversationReference(options.activity), - oAuthScope: options.fromBotOAuthScope + oAuthScope: options.fromBotOAuthScope, }; return this.skillId; } @@ -24,7 +24,7 @@ class ConversationIdFactory extends SkillConversationIdFactoryBase { } // Deprecated method - async createSkillConversationId(convRef = { conversation: { id: undefined }}) { + async createSkillConversationId(convRef = { conversation: { id: undefined } }) { this.refs[this.skillId] = convRef; return this.skillId; } @@ -39,4 +39,4 @@ class ConversationIdFactory extends SkillConversationIdFactoryBase { } } -module.exports.ConversationIdFactory = ConversationIdFactory; \ No newline at end of file +module.exports.ConversationIdFactory = ConversationIdFactory; diff --git a/libraries/botbuilder/tests/skills/skillHandler.test.js b/libraries/botbuilder/tests/skills/skillHandler.test.js index 00ac6707f6..1a50be399f 100644 --- a/libraries/botbuilder/tests/skills/skillHandler.test.js +++ b/libraries/botbuilder/tests/skills/skillHandler.test.js @@ -279,7 +279,7 @@ describe('SkillHandler', function () { sandbox.verify(); }); - it(`should use the skill's appId to set the callback's activity.callerId`, async function () { + it("should use the skill's appId to set the callback's activity.callerId", async function () { const skillAppId = '00000000-0000-0000-0000-000000000000'; const skillConsumerAppId = '00000000-0000-0000-0000-000000000001'; diff --git a/libraries/botbuilder/tests/statusCodeError.test.js b/libraries/botbuilder/tests/statusCodeError.test.js index b16dbf7235..e0e132ec96 100644 --- a/libraries/botbuilder/tests/statusCodeError.test.js +++ b/libraries/botbuilder/tests/statusCodeError.test.js @@ -7,9 +7,9 @@ const assert = require('assert'); const { StatusCodeError } = require('../'); const { StatusCodes } = require('botbuilder-core'); -describe(`StatusCodeError`, function () { - describe('constructor()', () => { - it(`should work with a message.`, function () { +describe('StatusCodeError', function () { + describe('constructor()', function () { + it('should work with a message.', function () { const message = 'This is an error message'; const error = new StatusCodeError(StatusCodes.NOT_FOUND, message); @@ -21,7 +21,7 @@ describe(`StatusCodeError`, function () { ); }); - it(`should work without a message.`, function () { + it('should work without a message.', function () { const error = new StatusCodeError(StatusCodes.NOT_FOUND); assert.strictEqual(error.message, '', 'message should be empty.'); @@ -32,7 +32,7 @@ describe(`StatusCodeError`, function () { ); }); - it(`should statusCode be undefined if not passed as a parameter.`, function () { + it('should statusCode be undefined if not passed as a parameter.', function () { const error = new StatusCodeError(); assert.strictEqual(error.statusCode, undefined, 'statusCode should be undefined.'); diff --git a/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js b/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js index c9caca3e5b..e0a7961231 100644 --- a/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js +++ b/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js @@ -55,7 +55,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { expect(adapter.streamingServer.disconnect()).to.not.throw; }); - it(`throws exception when trying to connect to a different named pipe than it's connected to`, async function () { + it("throws exception when trying to connect to a different named pipe than it's connected to", async function () { const adapter = new ConnectionTestAdapter(); await adapter.useNamedPipe(async (_) => {}, 'NamedPipeTest'); @@ -70,7 +70,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { ); }); - it(`doesn't throw while trying to connect to named pipe it's connected to`, async function () { + it("doesn't throw while trying to connect to named pipe it's connected to", async function () { const adapter = new ConnectionTestAdapter(); const namedPipeName = 'NamedPipeTest'; @@ -101,7 +101,9 @@ describe('BotFrameworkAdapter Streaming tests', function () { await assert.rejects( adapter.sendActivities(new TurnContext(adapter, activity), [reply]), - new Error('BotFrameworkAdapter.sendActivities(): Unable to send activity as Streaming connection is closed.') + new Error( + 'BotFrameworkAdapter.sendActivities(): Unable to send activity as Streaming connection is closed.' + ) ); }); diff --git a/libraries/botbuilder/tests/streaming/mockHttpRequest.js b/libraries/botbuilder/tests/streaming/mockHttpRequest.js index c118b24591..b97aad8300 100644 --- a/libraries/botbuilder/tests/streaming/mockHttpRequest.js +++ b/libraries/botbuilder/tests/streaming/mockHttpRequest.js @@ -2,15 +2,18 @@ const { randomBytes } = require('crypto'); class MockHttpRequest { constructor(options = {}) { - const config = Object.assign({ - method: 'GET', - headers: { - 'upgrade': 'websocket', - 'sec-websocket-key': randomBytes(16).toString('base64'), - 'sec-websocket-version': '13', - 'sec-websocket-protocol': '' - } - }, options); + const config = Object.assign( + { + method: 'GET', + headers: { + upgrade: 'websocket', + 'sec-websocket-key': randomBytes(16).toString('base64'), + 'sec-websocket-version': '13', + 'sec-websocket-protocol': '', + }, + }, + options + ); this.method = config.method; this.headers = config.headers; @@ -24,6 +27,7 @@ class MockHttpRequest { this.streamsVal = value; } + // eslint-disable-next-line no-dupe-class-members streams() { return this.streamsVal; } diff --git a/libraries/botbuilder/tests/streaming/mockNetSocket.js b/libraries/botbuilder/tests/streaming/mockNetSocket.js index 25447c5111..14b42c67fd 100644 --- a/libraries/botbuilder/tests/streaming/mockNetSocket.js +++ b/libraries/botbuilder/tests/streaming/mockNetSocket.js @@ -1,5 +1,4 @@ -const { STATUS_CODES } = require('http'); -const { AuthenticationError, StatusCodes } = require('botbuilder-core'); +const { StatusCodes } = require('botbuilder-core'); class MockNetSocket { constructor(readable = true, writable = true) { @@ -7,14 +6,13 @@ class MockNetSocket { this.writable = writable; } - write(response) { } + write(_response) {} - destroy(err) { } + destroy(_err) {} } MockNetSocket.createNonSuccessResponse = (code, message) => { return `HTTP/1.1 ${code} ${StatusCodes[code]}\r\n${message}\r\nConnection: 'close'\r\n\r\n`; }; - module.exports.MockNetSocket = MockNetSocket; diff --git a/libraries/botbuilder/tests/streaming/mockStreamingRequest.js b/libraries/botbuilder/tests/streaming/mockStreamingRequest.js index 6cdbdad6e8..ac65f92c07 100644 --- a/libraries/botbuilder/tests/streaming/mockStreamingRequest.js +++ b/libraries/botbuilder/tests/streaming/mockStreamingRequest.js @@ -3,9 +3,12 @@ const { ActivityTypes } = require('botbuilder-core'); // Mock of botframework-streaming/src/ContentStream class MockContentStream { constructor(options = {}) { - const config = Object.assign({ - readAsJson: async () => ({ type: ActivityTypes.Invoke, serviceUrl: 'somewhere/', channelId: 'test' }) - }, options); + const config = Object.assign( + { + readAsJson: async () => ({ type: ActivityTypes.Invoke, serviceUrl: 'somewhere/', channelId: 'test' }), + }, + options + ); this.readAsJson = config.readAsJson; } @@ -14,11 +17,14 @@ class MockContentStream { // Mock of botframework-streaming/src/interfaces/IReceiveRequest class MockStreamingRequest { constructor(options = {}) { - const config = Object.assign({ - verb: 'POST', - path: '/api/messages', - streams: [new MockContentStream()] - }, options); + const config = Object.assign( + { + verb: 'POST', + path: '/api/messages', + streams: [new MockContentStream()], + }, + options + ); this.verb = config.verb; this.path = config.path; diff --git a/libraries/botbuilder/tests/streaming/tokenResolver.test.js b/libraries/botbuilder/tests/streaming/tokenResolver.test.js index de9a74e42f..489cbf5b7d 100644 --- a/libraries/botbuilder/tests/streaming/tokenResolver.test.js +++ b/libraries/botbuilder/tests/streaming/tokenResolver.test.js @@ -18,7 +18,7 @@ class MockAdapter extends BotFrameworkAdapter { return context; } - getUserToken(context, connectionName, magicCode, oAuthAppCredentials) { + getUserToken(_context, _connectionName, _magicCode, _oAuthAppCredentials) { return Promise.resolve(this.getUserTokenCallback()); } } @@ -42,8 +42,9 @@ function createOAuthCardActivity() { return activity; } -describe(`TokenResolver`, function () { - it(`should throw on empty connectionName`, async function () { +describe('TokenResolver', function () { + it('should throw on empty connectionName', async function () { + let gotToken = false; const returnTokenResponse = () => { return { token: '1234', connectionName: 'foo' }; }; @@ -57,19 +58,20 @@ describe(`TokenResolver`, function () { activity.attachments[0].content.connectionName = undefined; const context = adapter.createTurnContext(activity); + assert(!gotToken, 'did not receive token'); await assert.throws( () => TokenResolver.checkForOAuthCards(adapter, context, activity), new Error("The OAuthPrompt's ConnectionName property is missing a value.", 'did not receive token') ); }); - it(`no attachments is a no-op`, async function () { + it('no attachments is a no-op', async function () { let fail = false; const returnTokenResponse = () => { fail = true; return { token: '1234', connectionName: 'foo' }; }; - const botLogic = (ctx) => { + const botLogic = () => { fail = true; }; const adapter = new MockAdapter(botLogic, returnTokenResponse); @@ -84,7 +86,7 @@ describe(`TokenResolver`, function () { assert(log.length === 0, 'logged actions, should be zero'); }); - it(`should get the token`, async function () { + it('should get the token', async function () { let gotToken = false; const returnTokenResponse = () => { return { token: '1234', connectionName: 'foo' }; @@ -114,7 +116,7 @@ describe(`TokenResolver`, function () { assert(gotToken, 'did not receive token'); }); - it(`should call onTurnError with process throw Error`, async function () { + it('should call onTurnError with process throw Error', async function () { let calledOnTurnError = false; const returnTokenResponse = () => { return { token: '1234', connectionName: 'foo' }; @@ -132,7 +134,7 @@ describe(`TokenResolver`, function () { } }; const adapter = new MockAdapter(botLogic, returnTokenResponse); - adapter.onTurnError = async (context, error) => { + adapter.onTurnError = async () => { calledOnTurnError = true; doneResolve('done'); }; @@ -147,7 +149,7 @@ describe(`TokenResolver`, function () { assert(calledOnTurnError, 'did not receive error'); }); - it(`should call onTurnError with process throw other`, async function () { + it('should call onTurnError with process throw other', async function () { let calledOnTurnError = false; const returnTokenResponse = () => { return { token: '1234', connectionName: 'foo' }; @@ -165,7 +167,7 @@ describe(`TokenResolver`, function () { } }; const adapter = new MockAdapter(botLogic, returnTokenResponse); - adapter.onTurnError = async (context, error) => { + adapter.onTurnError = async () => { calledOnTurnError = true; doneResolve('done'); }; @@ -180,7 +182,7 @@ describe(`TokenResolver`, function () { assert(calledOnTurnError, 'did not receive error'); }); - it(`should get the token on the second try`, async function () { + it('should get the token on the second try', async function () { this.timeout(10000); let gotToken = false; @@ -214,18 +216,17 @@ describe(`TokenResolver`, function () { assert(gotToken, 'did not receive token'); }); - it(`should end polling`, async function () { - let doneResolve, doneReject; - const done = new Promise((resolve, reject) => { + it('should end polling', async function () { + let doneResolve; + const done = new Promise((resolve) => { doneResolve = resolve; - doneReject = reject; }); const returnTokenResponse = () => { // Give token code 100ms to run setTimeout(() => doneResolve('done'), 100); return { properties: { tokenPollingSettings: { timeout: 0 } } }; }; - const botLogic = (ctx) => {}; + const botLogic = () => {}; const adapter = new MockAdapter(botLogic, returnTokenResponse); const activity = createOAuthCardActivity(); const context = adapter.createTurnContext(activity); @@ -238,11 +239,10 @@ describe(`TokenResolver`, function () { assert(log.indexOf('End polling') !== -1, 'did not end polling'); }); - it(`should change interval polling`, async function () { - let doneResolve, doneReject; - const done = new Promise((resolve, reject) => { + it('should change interval polling', async function () { + let doneResolve; + const done = new Promise((resolve) => { doneResolve = resolve; - doneReject = reject; }); let i = 0; const returnTokenResponse = () => { @@ -255,7 +255,7 @@ describe(`TokenResolver`, function () { return { properties: { tokenPollingSettings: { timeout: 0 } } }; } }; - const botLogic = (ctx) => {}; + const botLogic = () => {}; const adapter = new MockAdapter(botLogic, returnTokenResponse); const activity = createOAuthCardActivity(); const context = adapter.createTurnContext(activity); diff --git a/libraries/botbuilder/tests/teamsActivityHandler.test.js b/libraries/botbuilder/tests/teamsActivityHandler.test.js index 70969976b4..2fe8ea061a 100644 --- a/libraries/botbuilder/tests/teamsActivityHandler.test.js +++ b/libraries/botbuilder/tests/teamsActivityHandler.test.js @@ -13,14 +13,14 @@ function createInvokeActivity(name, value = {}, channelData = {}) { } describe('TeamsActivityHandler', function () { - describe('onTurnActivity()', () => { + describe('onTurnActivity()', function () { it('should not override the InvokeResponse on the context.turnState if it is set', async function () { class InvokeHandler extends TeamsActivityHandler { async onInvokeActivity(context) { assert(context, 'context not found'); await context.sendActivity({ type: 'invokeResponse', - value: { status: 200, body: `I'm a teapot.` }, + value: { status: 200, body: "I'm a teapot." }, }); return { status: 418 }; } @@ -37,7 +37,7 @@ describe('TeamsActivityHandler', function () { assert.strictEqual(activity.type, 'invokeResponse'); assert(activity.value, 'activity.value not found'); assert.strictEqual(activity.value.status, 200); - assert.strictEqual(activity.value.body, `I'm a teapot.`); + assert.strictEqual(activity.value.body, "I'm a teapot."); }) .startTest(); }); @@ -63,7 +63,7 @@ describe('TeamsActivityHandler', function () { }); }); - describe('onInvokeActivity()', () => { + describe('onInvokeActivity()', function () { class InvokeActivityEmptyHandlers extends TeamsActivityHandler { constructor() { super(); @@ -270,20 +270,24 @@ describe('TeamsActivityHandler', function () { .startTest(); }); - it('should call the base ActivityHandler\'s onInvokeActivity if activity.name is unrecognized', async function () { + it("should call the base ActivityHandler's onInvokeActivity if activity.name is unrecognized", async function () { const bot = new InvokeActivityEmptyHandlers(); const mockedResponse = { statusCode: 200, value: 'called' }; bot.onAdaptiveCardInvoke = () => { return mockedResponse; - } + }; const adapter = new TestAdapter(async (context) => { await bot.run(context); }); - const activity = { type: ActivityTypes.Invoke, name: 'adaptiveCard/action', value: { action: { type: 'Action.Execute' }}}; + const activity = { + type: ActivityTypes.Invoke, + name: 'adaptiveCard/action', + value: { action: { type: 'Action.Execute' } }, + }; await adapter .send(activity) @@ -295,7 +299,7 @@ describe('TeamsActivityHandler', function () { }); }); - describe('should send a BadRequest status code if', () => { + describe('should send a BadRequest status code if', function () { it('a bad BotMessagePreview.action is received by the bot', async function () { const bot = new TeamsActivityHandler(); @@ -359,7 +363,7 @@ describe('TeamsActivityHandler', function () { }); }); - describe('should send a NotImplemented status code if', () => { + describe('should send a NotImplemented status code if', function () { it('handleTeamsMessagingExtensionSubmitAction is not overridden', async function () { const bot = new TeamsActivityHandler(); @@ -785,7 +789,7 @@ describe('TeamsActivityHandler', function () { }); }); - describe('should send an OK status code', () => { + describe('should send an OK status code', function () { class OKFileConsent extends TeamsActivityHandler { async handleTeamsFileConsentAccept(context, fileConsentCardResponse) { assert(context, 'context not found'); @@ -891,7 +895,7 @@ describe('TeamsActivityHandler', function () { .startTest(); }); - describe('and the return value from', () => { + describe('and the return value from', function () { class TaskHandler extends TeamsActivityHandler { constructor() { super(); @@ -1025,7 +1029,7 @@ describe('TeamsActivityHandler', function () { }); }); - describe('should send a BadRequest status code when', () => { + describe('should send a BadRequest status code when', function () { it('handleTeamsFileConsent() receives an unexpected action value', async function () { const bot = new TeamsActivityHandler(); const adapter = new TestAdapter(async (context) => { @@ -1063,7 +1067,7 @@ describe('TeamsActivityHandler', function () { }); }); - describe('should dispatch through a registered', () => { + describe('should dispatch through a registered', function () { let fileConsentAcceptCalled = false; let fileConsentDeclineCalled = false; let fileConsentCalled = false; @@ -1097,13 +1101,13 @@ describe('TeamsActivityHandler', function () { } } - beforeEach(() => { + beforeEach(function () { fileConsentAcceptCalled = false; fileConsentDeclineCalled = false; fileConsentCalled = false; }); - afterEach(() => { + afterEach(function () { fileConsentAcceptCalled = false; fileConsentDeclineCalled = false; fileConsentCalled = false; @@ -1174,7 +1178,7 @@ describe('TeamsActivityHandler', function () { }); }); - describe('should call onDialog handlers after successfully handling an activity', () => { + describe('should call onDialog handlers after successfully handling an activity', function () { function createConvUpdateActivity(channelData) { const activity = { type: ActivityTypes.ConversationUpdate, @@ -1205,12 +1209,12 @@ describe('TeamsActivityHandler', function () { let onConversationUpdateCalled = false; let onDialogCalled = false; - beforeEach(() => { + beforeEach(function () { onConversationUpdateCalled = false; onDialogCalled = false; }); - afterEach(() => { + afterEach(function () { onConversationUpdateCalled = true; onDialogCalled = true; }); diff --git a/libraries/botbuilder/tests/teamsHelpers.test.js b/libraries/botbuilder/tests/teamsHelpers.test.js index 2ebc3fdc41..58d030efa5 100644 --- a/libraries/botbuilder/tests/teamsHelpers.test.js +++ b/libraries/botbuilder/tests/teamsHelpers.test.js @@ -13,7 +13,7 @@ function createActivityTeamId() { id: 1, text: 'testMessage', channelId: 'teams', - from: { id: `User1` }, + from: { id: 'User1' }, channelData: { team: { id: 'myId', aadGroupId: 'myaadGroupId' } }, conversation: { id: 'conversationId' }, recipient: { id: 'Bot1', name: '2' }, @@ -28,7 +28,7 @@ function createActivityNoTeamId() { id: 1, text: 'testMessage', channelId: 'teams', - from: { id: `User1` }, + from: { id: 'User1' }, channelData: { team: 'myTeams' }, conversation: { id: 'conversationId' }, recipient: { id: 'Bot1', name: '2' }, @@ -43,7 +43,7 @@ function createActivityNoChannelData() { id: 1, text: 'testMessage', channelId: 'teams', - from: { id: `User1` }, + from: { id: 'User1' }, conversation: { id: 'conversationId' }, recipient: { id: 'Bot1', name: '2' }, serviceUrl: 'http://foo.com/api/messages', diff --git a/libraries/botbuilder/tests/teamsInfo.test.js b/libraries/botbuilder/tests/teamsInfo.test.js index 4a73ffd061..5c4a5b6517 100644 --- a/libraries/botbuilder/tests/teamsInfo.test.js +++ b/libraries/botbuilder/tests/teamsInfo.test.js @@ -3,8 +3,8 @@ const nock = require('nock'); const sinon = require('sinon'); const { BotFrameworkAdapter, TeamsInfo, CloudAdapter } = require('../'); const { Conversations } = require('botframework-connector/lib/connectorApi/operations'); -const { MicrosoftAppCredentials, ConnectorClient, ServiceClientCredentialsFactory, PasswordServiceClientCredentialFactory } = require('botframework-connector'); -const { TurnContext, MessageFactory, ActionTypes, BotAdapter, Channels } = require('botbuilder-core'); +const { MicrosoftAppCredentials, ConnectorClient } = require('botframework-connector'); +const { TurnContext, MessageFactory, ActionTypes, Channels } = require('botbuilder-core'); class TeamsInfoAdapter extends BotFrameworkAdapter { constructor() { @@ -836,7 +836,10 @@ describe('TeamsInfo', function () { }); it('should throw error for missing meetingId', async function () { - await assert.rejects(TeamsInfo.getMeetingInfo({ activity: {} }), Error('meetingId or TurnContext containing meetingId is required.')); + await assert.rejects( + TeamsInfo.getMeetingInfo({ activity: {} }), + Error('meetingId or TurnContext containing meetingId is required.') + ); }); }); @@ -950,14 +953,14 @@ describe('TeamsInfo', function () { describe('private methods', function () { describe('getConnectorClient()', function () { - it(`should error if the context doesn't have an adapter`, function () { + it("should error if the context doesn't have an adapter", function () { assert.throws( () => TeamsInfo.getConnectorClient({}), new Error('This method requires a connector client.') ); }); - it(`should fallback to the connectorClient on turnState if adapter doesn't exist in context.adapter`, function () { + it("should fallback to the connectorClient on turnState if adapter doesn't exist in context.adapter", function () { const context = new TurnContext({}); context.turnState.set(context.adapter.ConnectorClientKey, connectorClient); const result = TeamsInfo.getConnectorClient(context); @@ -966,21 +969,21 @@ describe('TeamsInfo', function () { }); describe('getMembersInternal()', function () { - it(`should error if an invalid conversationId is passed in.`, async function () { + it('should error if an invalid conversationId is passed in.', async function () { await assert.rejects( TeamsInfo.getMembersInternal({}, undefined), new Error('The getMembers operation needs a valid conversationId.') ); }); - it(`should error if an invalid conversationId is passed in.`, async function () { + it('should error if an invalid conversationId is passed in.', async function () { await assert.rejects( TeamsInfo.getMemberInternal({}, undefined), new Error('The getMember operation needs a valid conversationId.') ); }); - it(`should error if an invalid userId is passed in.`, async function () { + it('should error if an invalid userId is passed in.', async function () { await assert.rejects( TeamsInfo.getMemberInternal({}, 'conversationId', undefined), new Error('The getMember operation needs a valid userId.') @@ -998,14 +1001,14 @@ describe('TeamsInfo', function () { sandbox.restore(); }); - it(`should error if an invalid conversationId is passed in.`, async function () { + it('should error if an invalid conversationId is passed in.', async function () { await assert.rejects( TeamsInfo.getPagedMembersInternal({}, undefined, 'options'), new Error('The getPagedMembers operation needs a valid conversationId.') ); }); - it(`should call connectorClient.conversations.getConversationPagedMembers()`, async function () { + it('should call connectorClient.conversations.getConversationPagedMembers()', async function () { const members = [ { id: '29:User-One-Id', @@ -1039,17 +1042,17 @@ describe('TeamsInfo', function () { assert.strictEqual( getPagedMembers.calledOnce, true, - `should have called conversations.getConversationPagedMembers` + 'should have called conversations.getConversationPagedMembers' ); }); }); describe('getTeamId()', function () { - it(`should error if an invalid context is passed in.`, function () { + it('should error if an invalid context is passed in.', function () { assert.throws(() => TeamsInfo.getTeamId(undefined), Error('Missing context parameter')); }); - it(`should error if an invalid activity is passed in.`, function () { + it('should error if an invalid activity is passed in.', function () { assert.throws(() => TeamsInfo.getTeamId({ activity: undefined }), Error('Missing activity on context')); }); });