UNPKG

botbuilder

Version:

Bot Builder is a framework for building rich bots on virtually any platform.

146 lines • 6.96 kB
"use strict"; /** * @module botbuilder */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SharePointActivityHandler = void 0; const botbuilder_core_1 = require("botbuilder-core"); /** * The SharePointActivityHandler is derived from ActivityHandler. It adds support for * the SharePoint specific events and interactions */ class SharePointActivityHandler extends botbuilder_core_1.ActivityHandler { /** * Invoked when an invoke activity is received from the connector. * Invoke activities can be used to communicate many different things. * Invoke activities communicate programmatic commands from a client or channel to a bot. * * @param context A strongly-typed context object for this turn * @returns A task that represents the work queued to execute */ onInvokeActivity(context) { const _super = Object.create(null, { onInvokeActivity: { get: () => super.onInvokeActivity } }); return __awaiter(this, void 0, void 0, function* () { try { if (!context.activity.name && context.activity.channelId === 'sharepoint') { throw new Error('NotImplemented'); } else { switch (context.activity.name) { case 'cardExtension/getCardView': return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskGetCardViewAsync(context, context.activity.value)); case 'cardExtension/getQuickView': return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskGetQuickViewAsync(context, context.activity.value)); case 'cardExtension/getPropertyPaneConfiguration': return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskGetPropertyPaneConfigurationAsync(context, context.activity.value)); case 'cardExtension/setPropertyPaneConfiguration': return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskSetPropertyPaneConfigurationAsync(context, context.activity.value)); case 'cardExtension/handleAction': return botbuilder_core_1.ActivityHandler.createInvokeResponse(yield this.onSharePointTaskHandleActionAsync(context, context.activity.value)); case 'cardExtension/token': yield this.onSignInInvoke(context); return botbuilder_core_1.ActivityHandler.createInvokeResponse(); default: return _super.onInvokeActivity.call(this, context); } } } catch (err) { if (err.message === 'NotImplemented') { return { status: 501 }; } else if (err.message === 'BadRequest') { return { status: 400 }; } throw err; } }); } /** * Override this in a derived class to provide logic for when a card view is fetched * * @param _context - A strongly-typed context object for this turn * @param _aceRequest - The Ace invoke request value payload * @returns A Card View Response for the request */ onSharePointTaskGetCardViewAsync(_context, _aceRequest) { return __awaiter(this, void 0, void 0, function* () { throw new Error('NotImplemented'); }); } /** * Override this in a derived class to provide logic for when a quick view is fetched * * @param _context - A strongly-typed context object for this turn * @param _aceRequest - The Ace invoke request value payload * @returns A Quick View Response for the request */ onSharePointTaskGetQuickViewAsync(_context, _aceRequest) { return __awaiter(this, void 0, void 0, function* () { throw new Error('NotImplemented'); }); } /** * Override this in a derived class to provide logic for getting configuration pane properties. * * @param _context - A strongly-typed context object for this turn * @param _aceRequest - The Ace invoke request value payload * @returns A Property Pane Configuration Response for the request */ onSharePointTaskGetPropertyPaneConfigurationAsync(_context, _aceRequest) { return __awaiter(this, void 0, void 0, function* () { throw new Error('NotImplemented'); }); } /** * Override this in a derived class to provide logic for setting configuration pane properties. * * @param _context - A strongly-typed context object for this turn * @param _aceRequest - The Ace invoke request value payload * @returns A Card view or no-op action response */ onSharePointTaskSetPropertyPaneConfigurationAsync(_context, _aceRequest) { return __awaiter(this, void 0, void 0, function* () { throw new Error('NotImplemented'); }); } /** * Override this in a derived class to provide logic for handling ACE action. * * @param _context - A strongly-typed context object for this turn * @param _aceRequest - The Ace invoke request value payload * @returns A handle action response */ onSharePointTaskHandleActionAsync(_context, _aceRequest) { return __awaiter(this, void 0, void 0, function* () { throw new Error('NotImplemented'); }); } /** * Override this method to support channel-specific behavior across multiple channels. * * @param _context - A strongly-typed context object for this turn */ onSignInInvoke(_context) { return __awaiter(this, void 0, void 0, function* () { throw new Error('NotImplemented'); }); } } exports.SharePointActivityHandler = SharePointActivityHandler; //# sourceMappingURL=sharePointActivityHandler.js.map