UNPKG

6.43 kBJavaScriptView Raw
1"use strict";
2/**
3 * @module botbuilder
4 */
5/**
6 * Copyright (c) Microsoft Corporation. All rights reserved.
7 * Licensed under the MIT License.
8 */
9var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11 return new (P || (P = Promise))(function (resolve, reject) {
12 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15 step((generator = generator.apply(thisArg, _arguments || [])).next());
16 });
17};
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.SharePointActivityHandler = void 0;
20const botbuilder_core_1 = require("botbuilder-core");
21/**
22 * The SharePointActivityHandler is derived from ActivityHandler. It adds support for
23 * the SharePoint specific events and interactions
24 */
25class SharePointActivityHandler extends botbuilder_core_1.ActivityHandler {
26 /**
27 * Invoked when an invoke activity is received from the connector.
28 * Invoke activities can be used to communicate many different things.
29 * * Invoke activities communicate programmatic commands from a client or channel to a bot.
30 *
31 * @param context A strongly-typed context object for this turn
32 * @returns A task that represents the work queued to execute
33 */
34 onInvokeActivity(context) {
35 const _super = Object.create(null, {
36 onInvokeActivity: { get: () => super.onInvokeActivity }
37 });
38 return __awaiter(this, void 0, void 0, function* () {
39 try {
40 if (!context.activity.name && context.activity.channelId === 'sharepoint') {
41 throw new Error('NotImplemented');
42 }
43 else {
44 switch (context.activity.name) {
45 case 'cardExtension/getCardView':
46 return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskGetCardViewAsync(context, context.activity.value));
47 case 'cardExtension/getQuickView':
48 return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskGetQuickViewAsync(context, context.activity.value));
49 case 'cardExtension/getPropertyPaneConfiguration':
50 return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskGetPropertyPaneConfigurationAsync(context, context.activity.value));
51 case 'cardExtension/setPropertyPaneConfiguration':
52 return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskSetPropertyPaneConfigurationAsync(context, context.activity.value));
53 case 'cardExtension/handleAction':
54 return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskHandleActionAsync(context, context.activity.value));
55 default:
56 return _super.onInvokeActivity.call(this, context);
57 }
58 }
59 }
60 catch (err) {
61 if (err.message === 'NotImplemented') {
62 return { status: 501 };
63 }
64 else if (err.message === 'BadRequest') {
65 return { status: 400 };
66 }
67 throw err;
68 }
69 });
70 }
71 /**
72 * Override this in a derived class to provide logic for when a card view is fetched
73 *
74 * @param _context - A strongly-typed context object for this turn
75 * @param _aceRequest - The Ace invoke request value payload
76 * @returns A Card View Response for the request
77 */
78 onSharePointTaskGetCardViewAsync(_context, _aceRequest) {
79 return __awaiter(this, void 0, void 0, function* () {
80 throw new Error('NotImplemented');
81 });
82 }
83 /**
84 * Override this in a derived class to provide logic for when a quick view is fetched
85 *
86 * @param _context - A strongly-typed context object for this turn
87 * @param _aceRequest - The Ace invoke request value payload
88 * @returns A Quick View Response for the request
89 */
90 onSharePointTaskGetQuickViewAsync(_context, _aceRequest) {
91 return __awaiter(this, void 0, void 0, function* () {
92 throw new Error('NotImplemented');
93 });
94 }
95 /**
96 * Override this in a derived class to provide logic for getting configuration pane properties.
97 *
98 * @param _context - A strongly-typed context object for this turn
99 * @param _aceRequest - The Ace invoke request value payload
100 * @returns A Property Pane Configuration Response for the request
101 */
102 onSharePointTaskGetPropertyPaneConfigurationAsync(_context, _aceRequest) {
103 return __awaiter(this, void 0, void 0, function* () {
104 throw new Error('NotImplemented');
105 });
106 }
107 /**
108 * Override this in a derived class to provide logic for setting configuration pane properties.
109 *
110 * @param _context - A strongly-typed context object for this turn
111 * @param _aceRequest - The Ace invoke request value payload
112 * @returns A Card view or no-op action response
113 */
114 onSharePointTaskSetPropertyPaneConfigurationAsync(_context, _aceRequest) {
115 return __awaiter(this, void 0, void 0, function* () {
116 throw new Error('NotImplemented');
117 });
118 }
119 /**
120 * Override this in a derived class to provide logic for setting configuration pane properties.
121 *
122 * @param _context - A strongly-typed context object for this turn
123 * @param _aceRequest - The Ace invoke request value payload
124 * @returns A handle action response
125 */
126 onSharePointTaskHandleActionAsync(_context, _aceRequest) {
127 return __awaiter(this, void 0, void 0, function* () {
128 throw new Error('NotImplemented');
129 });
130 }
131}
132exports.SharePointActivityHandler = SharePointActivityHandler;
133//# sourceMappingURL=sharePointActivityHandler.js.map
\No newline at end of file