forked from microsoft/botbuilder-js
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into southworks/update/zod…
…-botbuilder-core
- Loading branch information
Showing
52 changed files
with
3,805 additions
and
1,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/** | ||
* @module botbuilder | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { | ||
ActivityHandler, | ||
InvokeResponse, | ||
AceRequest, | ||
TurnContext, | ||
CardViewResponse, | ||
QuickViewResponse, | ||
GetPropertyPaneConfigurationResponse, | ||
SetPropertyPaneConfigurationResponse, | ||
HandleActionResponse, | ||
} from 'botbuilder-core'; | ||
|
||
/** | ||
* The SharePointActivityHandler is derived from ActivityHandler. It adds support for | ||
* the SharePoint specific events and interactions | ||
*/ | ||
export class SharePointActivityHandler extends 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 | ||
*/ | ||
protected async onInvokeActivity(context: TurnContext): Promise<InvokeResponse> { | ||
try { | ||
if (!context.activity.name && context.activity.channelId === 'sharepoint') { | ||
throw new Error('NotImplemented'); | ||
} else { | ||
switch (context.activity.name) { | ||
case 'cardExtension/getCardView': | ||
return ActivityHandler.createInvokeResponse( | ||
await this.onSharePointTaskGetCardViewAsync(context, context.activity.value as AceRequest) | ||
); | ||
|
||
case 'cardExtension/getQuickView': | ||
return ActivityHandler.createInvokeResponse( | ||
await this.onSharePointTaskGetQuickViewAsync(context, context.activity.value as AceRequest) | ||
); | ||
|
||
case 'cardExtension/getPropertyPaneConfiguration': | ||
return ActivityHandler.createInvokeResponse( | ||
await this.onSharePointTaskGetPropertyPaneConfigurationAsync( | ||
context, | ||
context.activity.value as AceRequest | ||
) | ||
); | ||
|
||
case 'cardExtension/setPropertyPaneConfiguration': | ||
return ActivityHandler.createInvokeResponse( | ||
await this.onSharePointTaskSetPropertyPaneConfigurationAsync( | ||
context, | ||
context.activity.value as AceRequest | ||
) | ||
); | ||
case 'cardExtension/handleAction': | ||
return ActivityHandler.createInvokeResponse( | ||
await this.onSharePointTaskHandleActionAsync(context, context.activity.value as AceRequest) | ||
); | ||
default: | ||
return super.onInvokeActivity(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 | ||
*/ | ||
protected async onSharePointTaskGetCardViewAsync( | ||
_context: TurnContext, | ||
_aceRequest: AceRequest | ||
): Promise<CardViewResponse> { | ||
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 | ||
*/ | ||
protected async onSharePointTaskGetQuickViewAsync( | ||
_context: TurnContext, | ||
_aceRequest: AceRequest | ||
): Promise<QuickViewResponse> { | ||
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 | ||
*/ | ||
protected async onSharePointTaskGetPropertyPaneConfigurationAsync( | ||
_context: TurnContext, | ||
_aceRequest: AceRequest | ||
): Promise<GetPropertyPaneConfigurationResponse> { | ||
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 | ||
*/ | ||
protected async onSharePointTaskSetPropertyPaneConfigurationAsync( | ||
_context: TurnContext, | ||
_aceRequest: AceRequest | ||
): Promise<SetPropertyPaneConfigurationResponse> { | ||
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 handle action response | ||
*/ | ||
protected async onSharePointTaskHandleActionAsync( | ||
_context: TurnContext, | ||
_aceRequest: AceRequest | ||
): Promise<HandleActionResponse> { | ||
throw new Error('NotImplemented'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
/** | ||
* SharePoint ACE Data object | ||
*/ | ||
export interface AceData { | ||
/** | ||
* The card size. | ||
*/ | ||
cardSize: AceCardSize; | ||
/** | ||
* The value of this property is stored in the serialized data of the Adaptive Card Extension. | ||
* It can be used to manage versioning of the Adaptive Card Extension. | ||
* | ||
* @remarks - although there is no restriction on the format of this property, it is recommended to use semantic versioning. | ||
*/ | ||
dataVersion: string; | ||
/** | ||
* The unique id (Guid) of the ACE. | ||
*/ | ||
id: string; | ||
/** | ||
* The title of the ACE. | ||
*/ | ||
title: string; | ||
/** | ||
* The icon of the ACE. | ||
*/ | ||
iconProperty: string; | ||
/** | ||
* The description of the ACE. | ||
*/ | ||
description: string; | ||
/** | ||
* The properties of the ACE. | ||
*/ | ||
properties: any; | ||
} | ||
|
||
/** | ||
* SharePoint ACE Card Size | ||
*/ | ||
export type AceCardSize = 'Medium' | 'Large'; |
16 changes: 16 additions & 0 deletions
16
libraries/botframework-schema/src/sharepoint/aceRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
/** | ||
* ACE invoke request payload. | ||
*/ | ||
export interface AceRequest { | ||
/** | ||
* User ACE request data. Free payload with key-value pairs. | ||
*/ | ||
data?: any; | ||
/** | ||
* ACE properties data. | ||
*/ | ||
properties?: any; | ||
} |
Oops, something went wrong.