1 | ;
|
2 | // Copyright (c) Microsoft Corporation.
|
3 | // Licensed under the MIT License.
|
4 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
5 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
6 | return new (P || (P = Promise))(function (resolve, reject) {
|
7 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
8 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
9 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
10 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
11 | });
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.CloudSkillHandler = void 0;
|
15 | const cloudChannelServiceHandler_1 = require("../cloudChannelServiceHandler");
|
16 | const skillHandlerImpl_1 = require("./skillHandlerImpl");
|
17 | const botbuilder_core_1 = require("botbuilder-core");
|
18 | class CloudSkillHandler extends cloudChannelServiceHandler_1.CloudChannelServiceHandler {
|
19 | /**
|
20 | * Initializes a new instance of the CloudSkillHandler class.
|
21 | *
|
22 | * @param adapter An instance of the BotAdapter that will handle the request.
|
23 | * @param logic The Bot logic function
|
24 | * @param conversationIdFactory A SkillConversationIdFactoryBase to unpack the conversation ID and map it to the calling bot.
|
25 | * @param auth Bot Framework Authentication to use
|
26 | */
|
27 | constructor(adapter, logic, conversationIdFactory, auth) {
|
28 | super(auth);
|
29 | /**
|
30 | * Used to access the CovnersationReference sent from the Skill to the Parent.
|
31 | */
|
32 | this.SkillConversationReferenceKey = botbuilder_core_1.SkillConversationReferenceKey;
|
33 | if (!adapter) {
|
34 | throw new Error('missing adapter.');
|
35 | }
|
36 | if (!logic) {
|
37 | throw new Error('missing logic.');
|
38 | }
|
39 | if (!conversationIdFactory) {
|
40 | throw new Error('missing conversationIdFactory.');
|
41 | }
|
42 | this.inner = new skillHandlerImpl_1.SkillHandlerImpl(this.SkillConversationReferenceKey, adapter, logic, conversationIdFactory, () => auth.getOriginatingAudience());
|
43 | }
|
44 | /**
|
45 | * sendToConversation() API for Skill.
|
46 | *
|
47 | * @remarks
|
48 | * This method allows you to send an activity to the end of a conversation.
|
49 | *
|
50 | * This is slightly different from replyToActivity().
|
51 | * * sendToConversation(conversationId) - will append the activity to the end
|
52 | * of the conversation according to the timestamp or semantics of the channel.
|
53 | * * replyToActivity(conversationId,ActivityId) - adds the activity as a reply
|
54 | * to another activity, if the channel supports it. If the channel does not
|
55 | * support nested replies, replyToActivity falls back to sendToConversation.
|
56 | *
|
57 | * Use replyToActivity when replying to a specific activity in the conversation.
|
58 | *
|
59 | * Use sendToConversation in all other cases.
|
60 | * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
|
61 | * @param conversationId Conversation ID.
|
62 | * @param activity Activity to send.
|
63 | * @returns A Promise with a ResourceResponse.
|
64 | */
|
65 | onSendToConversation(claimsIdentity, conversationId, activity) {
|
66 | return this.inner.onSendToConversation(claimsIdentity, conversationId, activity);
|
67 | }
|
68 | /**
|
69 | * replyToActivity() API for Skill.
|
70 | *
|
71 | * @remarks
|
72 | * This method allows you to reply to an activity.
|
73 | *
|
74 | * This is slightly different from sendToConversation().
|
75 | * * sendToConversation(conversationId) - will append the activity to the end
|
76 | * of the conversation according to the timestamp or semantics of the channel.
|
77 | * * replyToActivity(conversationId,ActivityId) - adds the activity as a reply
|
78 | * to another activity, if the channel supports it. If the channel does not
|
79 | * support nested replies, replyToActivity falls back to sendToConversation.
|
80 | *
|
81 | * Use replyToActivity when replying to a specific activity in the conversation.
|
82 | *
|
83 | * Use sendToConversation in all other cases.
|
84 | * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
|
85 | * @param conversationId Conversation ID.
|
86 | * @param activityId activityId the reply is to.
|
87 | * @param activity Activity to send.
|
88 | * @returns A Promise with a ResourceResponse.
|
89 | */
|
90 | onReplyToActivity(claimsIdentity, conversationId, activityId, activity) {
|
91 | return this.inner.onReplyToActivity(claimsIdentity, conversationId, activityId, activity);
|
92 | }
|
93 | /**
|
94 | *
|
95 | * UpdateActivity() API for Skill.
|
96 | *
|
97 | * @remarks
|
98 | * Edit an existing activity.
|
99 | *
|
100 | * Some channels allow you to edit an existing activity to reflect the new
|
101 | * state of a bot conversation.
|
102 | *
|
103 | * For example, you can remove buttons after someone has clicked "Approve" button.
|
104 | * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
|
105 | * @param conversationId Conversation ID.
|
106 | * @param activityId activityId to update.
|
107 | * @param activity replacement Activity.
|
108 | * @returns a promise resolving to the underlying resource response
|
109 | */
|
110 | onUpdateActivity(claimsIdentity, conversationId, activityId, activity) {
|
111 | return this.inner.onUpdateActivity(claimsIdentity, conversationId, activityId, activity);
|
112 | }
|
113 | /**
|
114 | * DeleteActivity() API for Skill.
|
115 | *
|
116 | * @remarks
|
117 | * Delete an existing activity.
|
118 | *
|
119 | * Some channels allow you to delete an existing activity, and if successful
|
120 | * this method will remove the specified activity.
|
121 | *
|
122 | *
|
123 | * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.
|
124 | * @param conversationId Conversation ID.
|
125 | * @param activityId activityId to delete.
|
126 | * @returns a promise representing the async operation
|
127 | */
|
128 | onDeleteActivity(claimsIdentity, conversationId, activityId) {
|
129 | return __awaiter(this, void 0, void 0, function* () {
|
130 | return this.inner.onDeleteActivity(claimsIdentity, conversationId, activityId);
|
131 | });
|
132 | }
|
133 | }
|
134 | exports.CloudSkillHandler = CloudSkillHandler;
|
135 | //# sourceMappingURL=cloudSkillHandler.js.map |
\ | No newline at end of file |