Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

botbuilder-dialogs

Package Overview
Dependencies
Maintainers
1
Versions
543
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botbuilder-dialogs - npm Package Compare versions

Comparing version 4.10.0-dev.20200807.b574691 to 4.10.0-dev.20200808.17e26d0

10

lib/dialogContainer.d.ts

@@ -9,3 +9,3 @@ /**

import { BotTelemetryClient } from 'botbuilder-core';
import { Dialog } from './dialog';
import { Dialog, DialogEvent } from './dialog';
import { DialogSet } from './dialogSet';

@@ -30,2 +30,10 @@ import { DialogContext } from './dialogContext';

/**
* Called when an event has been raised, using `DialogContext.emitEvent()`,
* by either the current dialog or a dialog that the current dialog started.
*
* @param dc The dialog context for the current turn of conversation.
* @param e The event being raised.
*/
onDialogEvent(dc: DialogContext, e: DialogEvent): Promise<boolean>;
/**
* Returns internal version identifier for this container.

@@ -32,0 +40,0 @@ *

@@ -38,2 +38,26 @@ "use strict";

/**
* Called when an event has been raised, using `DialogContext.emitEvent()`,
* by either the current dialog or a dialog that the current dialog started.
*
* @param dc The dialog context for the current turn of conversation.
* @param e The event being raised.
*/
onDialogEvent(dc, e) {
const _super = Object.create(null, {
onDialogEvent: { get: () => super.onDialogEvent }
});
return __awaiter(this, void 0, void 0, function* () {
const handled = yield _super.onDialogEvent.call(this, dc, e);
if (!handled && e.name === dialogEvents_1.DialogEvents.versionChanged) {
const traceMessage = `Unhandled dialog event: ${e.name}. Active Dialog: ${dc.activeDialog.id}`;
dc.dialogs.telemetryClient.trackTrace({
message: traceMessage,
severityLevel: botbuilder_core_1.Severity.Warning
});
yield dc.context.sendTraceActivity(traceMessage);
}
return handled;
});
}
/**
* Returns internal version identifier for this container.

@@ -40,0 +64,0 @@ *

@@ -16,2 +16,3 @@ /**

private readonly DeliveryModeStateKey;
private readonly SkillConversationIdStateKey;
/**

@@ -64,3 +65,4 @@ * A sample dialog that can wrap remote calls to a skill.

private createSkillConversationId;
private getSkillConversationIdFromInstance;
}
//# sourceMappingURL=skillDialog.d.ts.map

24

lib/skillDialog.js

@@ -36,2 +36,3 @@ "use strict";

this.DeliveryModeStateKey = 'SkillDialog.deliveryMode';
this.SkillConversationIdStateKey = 'SkillDialog.skillConversationId';
if (!dialogOptions) {

@@ -52,4 +53,7 @@ throw new TypeError('Missing dialogOptions parameter');

dc.activeDialog.state[this.DeliveryModeStateKey] = dialogArgs.activity.deliveryMode;
// Create the conversationId and store it in the dialog context state so we can use it later.
const skillConversationId = yield this.createSkillConversationId(dc.context, dc.context.activity);
dc.activeDialog.state[this.SkillConversationIdStateKey] = skillConversationId;
// Send the activity to the skill.
const eocActivity = yield this.sendToSkill(dc.context, skillActivity);
const eocActivity = yield this.sendToSkill(dc.context, skillActivity, skillConversationId);
if (eocActivity) {

@@ -75,4 +79,5 @@ return yield dc.endDialog(eocActivity.value);

skillActivity.deliveryMode = dc.activeDialog.state[this.DeliveryModeStateKey];
const skillConversationId = dc.activeDialog.state[this.SkillConversationIdStateKey];
// Just forward to the remote skill
const eocActivity = yield this.sendToSkill(dc.context, skillActivity);
const eocActivity = yield this.sendToSkill(dc.context, skillActivity, skillConversationId);
if (eocActivity) {

@@ -96,4 +101,5 @@ return yield dc.endDialog(eocActivity.value);

activity.channelData = context.activity.channelData;
const skillConversationId = this.getSkillConversationIdFromInstance(instance);
// connectionName is not applicable during endDialog as we don't expect an OAuthCard in response.
yield this.sendToSkill(context, activity);
yield this.sendToSkill(context, activity, skillConversationId);
}

@@ -110,4 +116,5 @@ yield _super.endDialog.call(this, context, instance, reason);

const activity = botbuilder_core_1.TurnContext.applyConversationReference(repromptEvent, reference, true);
const skillConversationId = this.getSkillConversationIdFromInstance(instance);
// connectionName is not applicable for a reprompt as we don't expect an OAuthCard in response.
yield this.sendToSkill(context, activity);
yield this.sendToSkill(context, activity, skillConversationId);
});

@@ -150,3 +157,3 @@ }

}
sendToSkill(context, activity) {
sendToSkill(context, activity, skillConversationId) {
return __awaiter(this, void 0, void 0, function* () {

@@ -158,3 +165,2 @@ if (activity.type === botbuilder_core_1.ActivityTypes.Invoke) {

}
const skillConversationId = yield this.createSkillConversationId(context, activity);
// Always save state before forwarding

@@ -267,2 +273,8 @@ // (the dialog stack won't get updated with the skillDialog and things won't work if you don't)

}
getSkillConversationIdFromInstance(instance) {
if (instance && instance.state) {
return instance.state[this.SkillConversationIdStateKey];
}
return null;
}
}

@@ -269,0 +281,0 @@ exports.SkillDialog = SkillDialog;

@@ -5,3 +5,3 @@ {

"description": "A dialog stack based conversation manager for Microsoft BotBuilder.",
"version": "4.10.0-dev.20200807.b574691",
"version": "4.10.0-dev.20200808.17e26d0",
"license": "MIT",

@@ -29,3 +29,3 @@ "keywords": [

"@types/node": "^10.17.27",
"botbuilder-core": "4.10.0-dev.20200807.b574691",
"botbuilder-core": "4.10.0-dev.20200808.17e26d0",
"globalize": "^1.4.2"

@@ -48,3 +48,3 @@ },

"clean": "erase /q /s .\\lib",
"set-version": "npm version --allow-same-version 4.10.0-dev.20200807.b574691",
"set-version": "npm version --allow-same-version 4.10.0-dev.20200808.17e26d0",
"test": "tsc && nyc mocha tests/",

@@ -51,0 +51,0 @@ "test:compat": "api-extractor run --verbose"

@@ -8,4 +8,4 @@ /**

*/
import { BotTelemetryClient, NullTelemetryClient } from 'botbuilder-core';
import { Dialog } from './dialog';
import { BotTelemetryClient, NullTelemetryClient, Severity } from 'botbuilder-core';
import { Dialog, DialogEvent } from './dialog';
import { DialogSet } from './dialogSet';

@@ -37,2 +37,22 @@ import { DialogContext } from './dialogContext';

/**
* Called when an event has been raised, using `DialogContext.emitEvent()`,
* by either the current dialog or a dialog that the current dialog started.
*
* @param dc The dialog context for the current turn of conversation.
* @param e The event being raised.
*/
public async onDialogEvent(dc: DialogContext, e: DialogEvent): Promise<boolean> {
const handled = await super.onDialogEvent(dc, e);
if (!handled && e.name === DialogEvents.versionChanged) {
const traceMessage = `Unhandled dialog event: ${ e.name }. Active Dialog: ${ dc.activeDialog.id }`;
dc.dialogs.telemetryClient.trackTrace({
message: traceMessage,
severityLevel: Severity.Warning
});
await dc.context.sendTraceActivity(traceMessage);
}
return handled;
}
/**
* Returns internal version identifier for this container.

@@ -39,0 +59,0 @@ *

@@ -42,2 +42,3 @@ /**

private readonly DeliveryModeStateKey: string = 'SkillDialog.deliveryMode';
private readonly SkillConversationIdStateKey: string = 'SkillDialog.skillConversationId';

@@ -76,4 +77,8 @@ /**

// Create the conversationId and store it in the dialog context state so we can use it later.
const skillConversationId = await this.createSkillConversationId(dc.context, dc.context.activity);
dc.activeDialog.state[this.SkillConversationIdStateKey] = skillConversationId;
// Send the activity to the skill.
const eocActivity = await this.sendToSkill(dc.context, skillActivity);
const eocActivity = await this.sendToSkill(dc.context, skillActivity, skillConversationId);
if (eocActivity) {

@@ -103,4 +108,6 @@ return await dc.endDialog(eocActivity.value);

const skillConversationId: string = dc.activeDialog.state[this.SkillConversationIdStateKey];
// Just forward to the remote skill
const eocActivity = await this.sendToSkill(dc.context, skillActivity);
const eocActivity = await this.sendToSkill(dc.context, skillActivity, skillConversationId);
if (eocActivity) {

@@ -123,4 +130,6 @@ return await dc.endDialog(eocActivity.value);

const skillConversationId: string = this.getSkillConversationIdFromInstance(instance);
// connectionName is not applicable during endDialog as we don't expect an OAuthCard in response.
await this.sendToSkill(context, activity as Activity);
await this.sendToSkill(context, activity as Activity, skillConversationId);
}

@@ -138,5 +147,7 @@

const activity: Activity = TurnContext.applyConversationReference(repromptEvent, reference, true) as Activity;
const skillConversationId: string = this.getSkillConversationIdFromInstance(instance);
// connectionName is not applicable for a reprompt as we don't expect an OAuthCard in response.
await this.sendToSkill(context, activity);
await this.sendToSkill(context, activity, skillConversationId);
}

@@ -183,3 +194,3 @@

private async sendToSkill(context: TurnContext, activity: Activity): Promise<Activity> {
private async sendToSkill(context: TurnContext, activity: Activity, skillConversationId: string): Promise<Activity> {
if (activity.type === ActivityTypes.Invoke) {

@@ -191,4 +202,2 @@ // Force ExpectReplies for invoke activities so we can get the replies right away and send them back to the channel if needed.

const skillConversationId = await this.createSkillConversationId(context, activity);
// Always save state before forwarding

@@ -305,2 +314,10 @@ // (the dialog stack won't get updated with the skillDialog and things won't work if you don't)

}
private getSkillConversationIdFromInstance(instance: DialogInstance): string {
if (instance && instance.state) {
return instance.state[this.SkillConversationIdStateKey];
}
return null;
}
}

@@ -307,0 +324,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc