Skip to content

Commit

Permalink
move InvokeResponse, WebRequest, WebResponse interfaces into separate…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
stevengum committed Dec 16, 2019
1 parent 05e8d9f commit 1380be6
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 113 deletions.
104 changes: 2 additions & 102 deletions libraries/botbuilder/src/botFrameworkAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Activity, ActivityTypes, BotAdapter, BotCallbackHandlerKey, ChannelAcco
import { AuthenticationConfiguration, AuthenticationConstants, ChannelValidation, ClaimsIdentity, ConnectorClient, EmulatorApiClient, GovernmentConstants, GovernmentChannelValidation, JwtTokenValidation, MicrosoftAppCredentials, AppCredentials, CertificateAppCredentials, SimpleCredentialProvider, TokenApiClient, TokenStatus, TokenApiModels, SkillValidation } from 'botframework-connector';
import { INodeBuffer, INodeSocket, IReceiveRequest, ISocket, IStreamingTransportServer, NamedPipeServer, NodeWebSocketFactory, NodeWebSocketFactoryBase, RequestHandler, StreamingResponse, WebSocketServer } from 'botframework-streaming';

import { InvokeResponse, WebRequest, WebResponse } from './interfaces';
import { StreamingHttpClient, TokenResolver } from './streaming';

export enum StatusCodes {
Expand All @@ -33,90 +34,6 @@ export class StatusCodeError extends Error {
}
}

/**
* Represents an Express or Restify request object.
*
* This interface supports the framework and is not intended to be called directly for your code.
*/
export interface WebRequest {
/**
* Optional. The request body.
*/
body?: any;

/***
* Optional. The request headers.
*/
headers: any;

/***
* Optional. The request method.
*/
method?: any;

/***
* Optional. The request parameters from the url.
*/
params?: any;

/***
* Optional. The values from the query string.
*/
query?: any;

/**
* When implemented in a derived class, adds a listener for an event.
* The framework uses this method to retrieve the request body when the
* [body](xref:botbuilder.WebRequest.body) property is `null` or `undefined`.
*
* @param event The event name.
* @param args Arguments used to handle the event.
*
* @returns A reference to the request object.
*/
on(event: string, ...args: any[]): any;
}

/**
* Represents an Express or Restify response object.
*
* This interface supports the framework and is not intended to be called directly for your code.
*/
export interface WebResponse {
/**
*
* Optional. The underlying socket.
*/
socket?: any;

/**
* When implemented in a derived class, sends a FIN packet.
*
* @param args The arguments for the end event.
*
* @returns A reference to the response object.
*/
end(...args: any[]): any;

/**
* When implemented in a derived class, sends the response.
*
* @param body The response payload.
*
* @returns A reference to the response object.
*/
send(body: any): any;

/**
* When implemented in a derived class, sets the HTTP status code for the response.
*
* @param status The status code to use.
*
* @returns The status code.
*/
status(status: number): any;
}

/**
* Contains settings used to configure a [BotFrameworkAdapter](xref:botbuilder.BotFrameworkAdapter) instance.
*/
Expand Down Expand Up @@ -172,23 +89,6 @@ export interface BotFrameworkAdapterSettings {
authConfig?: AuthenticationConfiguration;
}

/**
* Represents a response returned by a bot when it receives an `invoke` activity.
*
* This interface supports the framework and is not intended to be called directly for your code.
*/
export interface InvokeResponse {
/**
* The HTTP status code of the response.
*/
status: number;

/**
* Optional. The body of the response.
*/
body?: any;
}

// Retrieve additional information, i.e., host operating system, host OS release, architecture, Node.js version
const ARCHITECTURE: any = os.arch();
const TYPE: any = os.type();
Expand Down Expand Up @@ -1459,4 +1359,4 @@ function abortWebSocketUpgrade(socket: INodeSocket, code: number) {
}

socket.destroy();
}
}
3 changes: 2 additions & 1 deletion libraries/botbuilder/src/botFrameworkHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
MicrosoftAppCredentials
} from 'botframework-connector';

import { InvokeResponse, USER_AGENT } from './botFrameworkAdapter';
import { USER_AGENT } from './botFrameworkAdapter';
import { InvokeResponse } from './interfaces';

/**
* HttpClient for calling skills from a Node.js BotBuilder V4 SDK bot.
Expand Down
6 changes: 4 additions & 2 deletions libraries/botbuilder/src/channelServiceRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* Licensed under the MIT License.
*/

import { ChannelServiceHandler } from './channelServiceHandler';
import { Activity, ConversationParameters, Transcript, AttachmentData } from 'botbuilder-core';
import { WebRequest, WebResponse, StatusCodeError, StatusCodes } from './botFrameworkAdapter';

import { ChannelServiceHandler } from './channelServiceHandler';
import { StatusCodeError, StatusCodes } from './botFrameworkAdapter';
import { WebRequest, WebResponse } from './interfaces';

export type RouteHandler = (request: WebRequest, response: WebResponse) => void;

Expand Down
8 changes: 5 additions & 3 deletions libraries/botbuilder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
export {
BotFrameworkAdapter,
BotFrameworkAdapterSettings,
InvokeResponse,
INVOKE_RESPONSE_KEY,
StatusCodes,
StatusCodeError,
WebRequest,
WebResponse
} from './botFrameworkAdapter';
export { BotFrameworkHttpClient } from './botFrameworkHttpClient';
export { ChannelServiceHandler } from './channelServiceHandler';
export { ChannelServiceRoutes, RouteHandler, WebServer } from './channelServiceRoutes';
export * from './fileTranscriptStore';
export * from './inspectionMiddleware';
export {
InvokeResponse,
WebRequest,
WebResponse
} from './interfaces';
export * from './skills';
export * from './streaming';
export * from './teamsActivityHandler';
Expand Down
11 changes: 11 additions & 0 deletions libraries/botbuilder/src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @module botbuilder
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

export * from './invokeResponse';
export * from './webRequest';
export * from './webResponse';
24 changes: 24 additions & 0 deletions libraries/botbuilder/src/interfaces/invokeResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @module botbuilder
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

/**
* Represents a response returned by a bot when it receives an `invoke` activity.
*
* This interface supports the framework and is not intended to be called directly for your code.
*/
export interface InvokeResponse {
/**
* The HTTP status code of the response.
*/
status: number;

/**
* Optional. The body of the response.
*/
body?: any;
}
51 changes: 51 additions & 0 deletions libraries/botbuilder/src/interfaces/webRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @module botbuilder
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

/**
* Represents an Express or Restify request object.
*
* This interface supports the framework and is not intended to be called directly for your code.
*/
export interface WebRequest {
/**
* Optional. The request body.
*/
body?: any;

/***
* Optional. The request headers.
*/
headers: any;

/***
* Optional. The request method.
*/
method?: any;

/***
* Optional. The request parameters from the url.
*/
params?: any;

/***
* Optional. The values from the query string.
*/
query?: any;

/**
* When implemented in a derived class, adds a listener for an event.
* The framework uses this method to retrieve the request body when the
* [body](xref:botbuilder.WebRequest.body) property is `null` or `undefined`.
*
* @param event The event name.
* @param args Arguments used to handle the event.
*
* @returns A reference to the request object.
*/
on(event: string, ...args: any[]): any;
}
47 changes: 47 additions & 0 deletions libraries/botbuilder/src/interfaces/webResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @module botbuilder
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

/**
* Represents an Express or Restify response object.
*
* This interface supports the framework and is not intended to be called directly for your code.
*/
export interface WebResponse {
/**
*
* Optional. The underlying socket.
*/
socket?: any;

/**
* When implemented in a derived class, sends a FIN packet.
*
* @param args The arguments for the end event.
*
* @returns A reference to the response object.
*/
end(...args: any[]): any;

/**
* When implemented in a derived class, sends the response.
*
* @param body The response payload.
*
* @returns A reference to the response object.
*/
send(body: any): any;

/**
* When implemented in a derived class, sets the HTTP status code for the response.
*
* @param status The status code to use.
*
* @returns The status code.
*/
status(status: number): any;
}
2 changes: 1 addition & 1 deletion libraries/botbuilder/src/skills/skillHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/
import { Activity, ConversationReference, TurnContext } from 'botbuilder-core';
import { ICredentialProvider } from 'botframework-connector';
import { InvokeResponse } from '../botFrameworkAdapter';
import { BotFrameworkHttpClient } from '../botFrameworkHttpClient';
import { BotFrameworkSkill } from './botFrameworkSkill';
import { InvokeResponse } from '../interfaces';
import { SkillConversationIdFactoryBase } from './skillConversationIdFactoryBase';

/**
Expand Down
6 changes: 2 additions & 4 deletions libraries/botbuilder/src/teamsActivityHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
* Licensed under the MIT License.
*/

import { InvokeResponse, INVOKE_RESPONSE_KEY } from './botFrameworkAdapter';
import { INVOKE_RESPONSE_KEY } from './botFrameworkAdapter';

import {
ActivityHandler,
ActivityTypes,
AppBasedLinkQuery,
ChannelAccount,
ChannelInfo,
FileConsentCardResponse,
MessagingExtensionAction,
Expand All @@ -21,15 +20,14 @@ import {
MessagingExtensionResponse,
O365ConnectorCardActionQuery,
SigninStateVerificationQuery,
TaskModuleTaskInfo,
TaskModuleRequest,
TaskModuleResponse,
TaskModuleResponseBase,
TeamsChannelData,
TeamsChannelAccount,
TeamInfo,
TurnContext
} from 'botbuilder-core';
import { InvokeResponse } from './interfaces';
import { TeamsInfo } from './teamsInfo';

export class TeamsActivityHandler extends ActivityHandler {
Expand Down

0 comments on commit 1380be6

Please sign in to comment.