botbuilder-core
Advanced tools
Comparing version 4.0.0-m2.2 to 4.0.0-m3.0
@@ -10,3 +10,3 @@ /** | ||
import { Activity, ResourceResponse, ConversationReference } from 'botframework-schema'; | ||
import { BotContext } from './botContext'; | ||
import { TurnContext } from './turnContext'; | ||
/** | ||
@@ -28,16 +28,25 @@ * :package: **botbuilder-core** | ||
* returned. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param activities Set of activities being sent. | ||
*/ | ||
abstract sendActivity(activities: Partial<Activity>[]): Promise<ResourceResponse[]>; | ||
abstract sendActivities(context: TurnContext, activities: Partial<Activity>[]): Promise<ResourceResponse[]>; | ||
/** | ||
* Replaces an existing activity. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param activity New replacement activity. The activity should already have it's ID information populated. | ||
*/ | ||
abstract updateActivity(activity: Partial<Activity>): Promise<void>; | ||
abstract updateActivity(context: TurnContext, activity: Partial<Activity>): Promise<void>; | ||
/** | ||
* Deletes an existing activity. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param reference Conversation reference of the activity being deleted. | ||
*/ | ||
abstract deleteActivity(reference: Partial<ConversationReference>): Promise<void>; | ||
abstract deleteActivity(context: TurnContext, reference: Partial<ConversationReference>): Promise<void>; | ||
/** | ||
* Proactively continues an existing conversation. | ||
* @param reference Conversation reference of the conversation being continued. | ||
* @param logic Function to execute for performing the bots logic. | ||
*/ | ||
abstract continueConversation(reference: Partial<ConversationReference>, logic: (revocableContext: TurnContext) => Promiseable<void>): Promise<void>; | ||
/** | ||
* Registers middleware handlers(s) with the adapter. | ||
@@ -57,3 +66,3 @@ * @param middleware One or more middleware handlers(s) to register. | ||
*/ | ||
protected runMiddleware(context: BotContext, next: (revocableContext: BotContext) => Promiseable<void>): Promise<void>; | ||
protected runMiddleware(context: TurnContext, next: (revocableContext: TurnContext) => Promiseable<void>): Promise<void>; | ||
} |
@@ -10,3 +10,3 @@ /** | ||
export * from './middlewareSet'; | ||
export * from './botContext'; | ||
export * from './turnContext'; | ||
export * from 'botframework-schema'; |
@@ -15,4 +15,4 @@ "use strict"; | ||
__export(require("./middlewareSet")); | ||
__export(require("./botContext")); | ||
__export(require("./turnContext")); | ||
__export(require("botframework-schema")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { BotContext } from './botContext'; | ||
import { TurnContext } from './turnContext'; | ||
/** | ||
@@ -16,3 +16,3 @@ * :package: **botbuilder-core** | ||
export interface Middleware { | ||
onProcessRequest(context: BotContext, next: () => Promise<void>): Promiseable<void>; | ||
onTurn(context: TurnContext, next: () => Promise<void>): Promiseable<void>; | ||
} | ||
@@ -24,3 +24,3 @@ /** | ||
*/ | ||
export declare type MiddlewareHandler = (context: BotContext, next: () => Promise<void>) => Promiseable<void>; | ||
export declare type MiddlewareHandler = (context: TurnContext, next: () => Promise<void>) => Promiseable<void>; | ||
/** | ||
@@ -40,3 +40,3 @@ * :package: **botbuilder-core** | ||
constructor(...middleware: (MiddlewareHandler | Middleware)[]); | ||
onProcessRequest(context: BotContext, next: () => Promise<void>): Promise<void>; | ||
onTurn(context: TurnContext, next: () => Promise<void>): Promise<void>; | ||
/** | ||
@@ -52,3 +52,3 @@ * Registers middleware handlers(s) with the set. | ||
*/ | ||
run(context: BotContext, next: () => Promiseable<void>): Promise<void>; | ||
run(context: TurnContext, next: () => Promiseable<void>): Promise<void>; | ||
} |
@@ -19,3 +19,3 @@ "use strict"; | ||
} | ||
onProcessRequest(context, next) { | ||
onTurn(context, next) { | ||
return this.run(context, next); | ||
@@ -32,4 +32,4 @@ } | ||
} | ||
else if (typeof plugin === 'object' && plugin.onProcessRequest) { | ||
this.middleware.push((context, next) => plugin.onProcessRequest(context, next)); | ||
else if (typeof plugin === 'object' && plugin.onTurn) { | ||
this.middleware.push((context, next) => plugin.onTurn(context, next)); | ||
} | ||
@@ -36,0 +36,0 @@ else { |
@@ -5,3 +5,3 @@ { | ||
"description": "Bot Builder core library. Bot Builder is a toolkit for building rich bots on virtually any platform.", | ||
"version": "4.0.0-m2.2", | ||
"version": "4.0.0-m3.0", | ||
"license": "MIT", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"@types/node": "^9.3.0", | ||
"botframework-schema": "4.0.0-m2.2", | ||
"botframework-schema": "4.0.0-m3.0", | ||
"assert": "^1.4.1" | ||
@@ -28,0 +28,0 @@ }, |
@@ -10,3 +10,3 @@ /** | ||
import { ActivityTypes, Activity, ResourceResponse, ConversationReference } from 'botframework-schema'; | ||
import { BotContext } from './botContext'; | ||
import { TurnContext } from './turnContext'; | ||
import { makeRevocable } from './internal'; | ||
@@ -31,19 +31,29 @@ | ||
* returned. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param activities Set of activities being sent. | ||
*/ | ||
public abstract sendActivity(activities: Partial<Activity>[]): Promise<ResourceResponse[]>; | ||
public abstract sendActivities(context: TurnContext, activities: Partial<Activity>[]): Promise<ResourceResponse[]>; | ||
/** | ||
* Replaces an existing activity. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param activity New replacement activity. The activity should already have it's ID information populated. | ||
*/ | ||
public abstract updateActivity(activity: Partial<Activity>): Promise<void>; | ||
public abstract updateActivity(context: TurnContext, activity: Partial<Activity>): Promise<void>; | ||
/** | ||
* Deletes an existing activity. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param reference Conversation reference of the activity being deleted. | ||
*/ | ||
public abstract deleteActivity(reference: Partial<ConversationReference>): Promise<void>; | ||
public abstract deleteActivity(context: TurnContext, reference: Partial<ConversationReference>): Promise<void>; | ||
/** | ||
* Proactively continues an existing conversation. | ||
* @param reference Conversation reference of the conversation being continued. | ||
* @param logic Function to execute for performing the bots logic. | ||
*/ | ||
public abstract continueConversation(reference: Partial<ConversationReference>, logic: (revocableContext: TurnContext) => Promiseable<void>): Promise<void>; | ||
/** | ||
* Registers middleware handlers(s) with the adapter. | ||
@@ -67,3 +77,3 @@ * @param middleware One or more middleware handlers(s) to register. | ||
*/ | ||
protected runMiddleware(context: BotContext, next: (revocableContext: BotContext) => Promiseable<void>): Promise<void> { | ||
protected runMiddleware(context: TurnContext, next: (revocableContext: TurnContext) => Promiseable<void>): Promise<void> { | ||
// Wrap context with revocable proxy | ||
@@ -70,0 +80,0 @@ const pContext = makeRevocable(context); |
@@ -11,3 +11,3 @@ /** | ||
export * from './middlewareSet'; | ||
export * from './botContext'; | ||
export * from './turnContext'; | ||
export * from 'botframework-schema'; |
@@ -9,3 +9,3 @@ /** | ||
import { Activity, ResourceResponse } from 'botframework-schema'; | ||
import { BotContext } from './botContext'; | ||
import { TurnContext } from './turnContext'; | ||
@@ -27,3 +27,3 @@ /** | ||
export interface Middleware { | ||
onProcessRequest(context: BotContext, next: () => Promise<void>): Promiseable<void>; | ||
onTurn(context: TurnContext, next: () => Promise<void>): Promiseable<void>; | ||
} | ||
@@ -36,3 +36,3 @@ | ||
*/ | ||
export type MiddlewareHandler = (context: BotContext, next: () => Promise<void>) => Promiseable<void>; | ||
export type MiddlewareHandler = (context: TurnContext, next: () => Promise<void>) => Promiseable<void>; | ||
@@ -57,3 +57,3 @@ /** | ||
public onProcessRequest(context: BotContext, next: () => Promise<void>): Promise<void> { | ||
public onTurn(context: TurnContext, next: () => Promise<void>): Promise<void> { | ||
return this.run(context, next); | ||
@@ -70,4 +70,4 @@ } | ||
this.middleware.push(plugin); | ||
} else if (typeof plugin === 'object' && plugin.onProcessRequest) { | ||
this.middleware.push((context, next) => plugin.onProcessRequest(context, next)); | ||
} else if (typeof plugin === 'object' && plugin.onTurn) { | ||
this.middleware.push((context, next) => plugin.onTurn(context, next)); | ||
} else { | ||
@@ -85,3 +85,3 @@ throw new Error(`MiddlewareSet.use(): invalid plugin type being added.`); | ||
*/ | ||
public run(context: BotContext, next: () => Promiseable<void>): Promise<void> { | ||
public run(context: TurnContext, next: () => Promiseable<void>): Promise<void> { | ||
const handlers = this.middleware.slice(); | ||
@@ -88,0 +88,0 @@ function runNext(i: number): Promise<void> { |
const assert = require('assert'); | ||
const { BotAdapter, BotContext } = require('../'); | ||
const { BotAdapter, TurnContext } = require('../'); | ||
@@ -8,3 +8,3 @@ const testMessage = { text: 'test', type: 'message' }; | ||
processRequest(activity, handler) { | ||
const context = new BotContext(this, activity); | ||
const context = new TurnContext(this, activity); | ||
return this.runMiddleware(context, handler); | ||
@@ -11,0 +11,0 @@ } |
const assert = require('assert'); | ||
const { BotAdapter, MiddlewareSet, BotContext } = require('../'); | ||
const { BotAdapter, MiddlewareSet, TurnContext } = require('../'); | ||
@@ -37,3 +37,3 @@ const testMessage = { text: 'test', type: 'message' }; | ||
order = ''; | ||
const context = new BotContext(new SimpleAdapter(), testMessage); | ||
const context = new TurnContext(new SimpleAdapter(), testMessage); | ||
set.run(context, () => { | ||
@@ -48,3 +48,3 @@ assert(calls === 5, `only "${calls} of 5" middleware called.`); | ||
order = ''; | ||
const context = new BotContext(new SimpleAdapter(), testMessage); | ||
const context = new TurnContext(new SimpleAdapter(), testMessage); | ||
const set2 = new MiddlewareSet(set); | ||
@@ -59,3 +59,3 @@ set2.run(context, () => { | ||
let edge = ''; | ||
const context = new BotContext(new SimpleAdapter(), testMessage); | ||
const context = new TurnContext(new SimpleAdapter(), testMessage); | ||
new MiddlewareSet() | ||
@@ -79,6 +79,6 @@ .use((context, next) => { | ||
let called = false; | ||
const context = new BotContext(new SimpleAdapter(), testMessage); | ||
const context = new TurnContext(new SimpleAdapter(), testMessage); | ||
new MiddlewareSet() | ||
.use({ | ||
onProcessRequest: (context, next) => { | ||
onTurn: (context, next) => { | ||
called = true; | ||
@@ -96,3 +96,3 @@ return next(); | ||
let called = false; | ||
const context = new BotContext(new SimpleAdapter(), testMessage); | ||
const context = new TurnContext(new SimpleAdapter(), testMessage); | ||
new MiddlewareSet() | ||
@@ -116,3 +116,3 @@ .use(() => { | ||
it(`should map an exception within middleware to a rejection.`, function (done) { | ||
const context = new BotContext(new SimpleAdapter(), testMessage); | ||
const context = new TurnContext(new SimpleAdapter(), testMessage); | ||
new MiddlewareSet() | ||
@@ -144,3 +144,3 @@ .use(() => { | ||
let called = false; | ||
const context = new BotContext(new SimpleAdapter(), testMessage); | ||
const context = new TurnContext(new SimpleAdapter(), testMessage); | ||
new MiddlewareSet((context, next) => { | ||
@@ -147,0 +147,0 @@ called = true; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106452
30
2041
+ Addedbotframework-schema@4.0.0-m3.0(transitive)
- Removedbotframework-schema@4.0.0-m2.2(transitive)