@microsoft/agents-hosting-extensions-msteams 1.7.0-beta.8.gc2b086aef6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -0
- package/dist/package.json +46 -0
- package/dist/src/activity-extensions/index.d.ts +1 -0
- package/dist/src/activity-extensions/index.js +8 -0
- package/dist/src/activity-extensions/index.js.map +1 -0
- package/dist/src/activity-extensions/teamsChannelData.d.ts +12 -0
- package/dist/src/activity-extensions/teamsChannelData.js +29 -0
- package/dist/src/activity-extensions/teamsChannelData.js.map +1 -0
- package/dist/src/app/index.d.ts +1 -0
- package/dist/src/app/index.js +20 -0
- package/dist/src/app/index.js.map +1 -0
- package/dist/src/app/teamsAppExtensions.d.ts +145 -0
- package/dist/src/app/teamsAppExtensions.js +201 -0
- package/dist/src/app/teamsAppExtensions.js.map +1 -0
- package/dist/src/channels/index.d.ts +1 -0
- package/dist/src/channels/index.js +20 -0
- package/dist/src/channels/index.js.map +1 -0
- package/dist/src/channels/teamsChannel.d.ts +100 -0
- package/dist/src/channels/teamsChannel.js +210 -0
- package/dist/src/channels/teamsChannel.js.map +1 -0
- package/dist/src/config/config.d.ts +37 -0
- package/dist/src/config/config.js +71 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/index.d.ts +1 -0
- package/dist/src/config/index.js +20 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/errorHelper.d.ts +19 -0
- package/dist/src/errorHelper.js +96 -0
- package/dist/src/errorHelper.js.map +1 -0
- package/dist/src/fileConsents/fileConsent.d.ts +37 -0
- package/dist/src/fileConsents/fileConsent.js +79 -0
- package/dist/src/fileConsents/fileConsent.js.map +1 -0
- package/dist/src/fileConsents/index.d.ts +1 -0
- package/dist/src/fileConsents/index.js +20 -0
- package/dist/src/fileConsents/index.js.map +1 -0
- package/dist/src/graphClientFactory.d.ts +10 -0
- package/dist/src/graphClientFactory.js +98 -0
- package/dist/src/graphClientFactory.js.map +1 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/index.js +39 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/meetings/index.d.ts +1 -0
- package/dist/src/meetings/index.js +20 -0
- package/dist/src/meetings/index.js.map +1 -0
- package/dist/src/meetings/meeting.d.ts +84 -0
- package/dist/src/meetings/meeting.js +107 -0
- package/dist/src/meetings/meeting.js.map +1 -0
- package/dist/src/messageExtensions/index.d.ts +2 -0
- package/dist/src/messageExtensions/index.js +24 -0
- package/dist/src/messageExtensions/index.js.map +1 -0
- package/dist/src/messageExtensions/messageExtension.d.ts +133 -0
- package/dist/src/messageExtensions/messageExtension.js +326 -0
- package/dist/src/messageExtensions/messageExtension.js.map +1 -0
- package/dist/src/messageExtensions/messagingExtensionQuery.d.ts +87 -0
- package/dist/src/messageExtensions/messagingExtensionQuery.js +35 -0
- package/dist/src/messageExtensions/messagingExtensionQuery.js.map +1 -0
- package/dist/src/messages/index.d.ts +1 -0
- package/dist/src/messages/index.js +20 -0
- package/dist/src/messages/index.js.map +1 -0
- package/dist/src/messages/message.d.ts +67 -0
- package/dist/src/messages/message.js +129 -0
- package/dist/src/messages/message.js.map +1 -0
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/models/index.js +20 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/models/readReceiptInfo.d.ts +27 -0
- package/dist/src/models/readReceiptInfo.js +44 -0
- package/dist/src/models/readReceiptInfo.js.map +1 -0
- package/dist/src/taskModules/index.d.ts +1 -0
- package/dist/src/taskModules/index.js +20 -0
- package/dist/src/taskModules/index.js.map +1 -0
- package/dist/src/taskModules/taskModule.d.ts +42 -0
- package/dist/src/taskModules/taskModule.js +102 -0
- package/dist/src/taskModules/taskModule.js.map +1 -0
- package/dist/src/teams/index.d.ts +1 -0
- package/dist/src/teams/index.js +20 -0
- package/dist/src/teams/index.js.map +1 -0
- package/dist/src/teams/teamsTeam.d.ts +82 -0
- package/dist/src/teams/teamsTeam.js +172 -0
- package/dist/src/teams/teamsTeam.js.map +1 -0
- package/dist/src/teamsActivity.d.ts +15 -0
- package/dist/src/teamsActivity.js +5 -0
- package/dist/src/teamsActivity.js.map +1 -0
- package/dist/src/teamsActivityExtensions.d.ts +53 -0
- package/dist/src/teamsActivityExtensions.js +101 -0
- package/dist/src/teamsActivityExtensions.js.map +1 -0
- package/dist/src/teamsAgentExtension.d.ts +105 -0
- package/dist/src/teamsAgentExtension.js +178 -0
- package/dist/src/teamsAgentExtension.js.map +1 -0
- package/dist/src/teamsApiClientExtensions.d.ts +13 -0
- package/dist/src/teamsApiClientExtensions.js +41 -0
- package/dist/src/teamsApiClientExtensions.js.map +1 -0
- package/dist/src/teamsHeaderPropagation.d.ts +14 -0
- package/dist/src/teamsHeaderPropagation.js +35 -0
- package/dist/src/teamsHeaderPropagation.js.map +1 -0
- package/dist/src/teamsModelExtensions.d.ts +19 -0
- package/dist/src/teamsModelExtensions.js +38 -0
- package/dist/src/teamsModelExtensions.js.map +1 -0
- package/dist/src/teamsProactiveServiceEndpoints.d.ts +15 -0
- package/dist/src/teamsProactiveServiceEndpoints.js +21 -0
- package/dist/src/teamsProactiveServiceEndpoints.js.map +1 -0
- package/dist/src/teamsRouteHandler.d.ts +13 -0
- package/dist/src/teamsRouteHandler.js +18 -0
- package/dist/src/teamsRouteHandler.js.map +1 -0
- package/dist/src/teamsTurnContext.d.ts +64 -0
- package/dist/src/teamsTurnContext.js +113 -0
- package/dist/src/teamsTurnContext.js.map +1 -0
- package/package.json +46 -0
- package/src/activity-extensions/index.ts +4 -0
- package/src/activity-extensions/teamsChannelData.ts +30 -0
- package/src/app/index.ts +4 -0
- package/src/app/teamsAppExtensions.ts +369 -0
- package/src/channels/index.ts +4 -0
- package/src/channels/teamsChannel.ts +229 -0
- package/src/config/config.ts +79 -0
- package/src/config/index.ts +4 -0
- package/src/errorHelper.ts +104 -0
- package/src/fileConsents/fileConsent.ts +85 -0
- package/src/fileConsents/index.ts +4 -0
- package/src/graphClientFactory.ts +127 -0
- package/src/index.ts +23 -0
- package/src/meetings/index.ts +4 -0
- package/src/meetings/meeting.ts +146 -0
- package/src/messageExtensions/index.ts +5 -0
- package/src/messageExtensions/messageExtension.ts +370 -0
- package/src/messageExtensions/messagingExtensionQuery.ts +34 -0
- package/src/messages/index.ts +4 -0
- package/src/messages/message.ts +148 -0
- package/src/models/index.ts +4 -0
- package/src/models/readReceiptInfo.ts +50 -0
- package/src/taskModules/index.ts +4 -0
- package/src/taskModules/taskModule.ts +113 -0
- package/src/teams/index.ts +4 -0
- package/src/teams/teamsTeam.ts +189 -0
- package/src/teamsActivity.ts +19 -0
- package/src/teamsActivityExtensions.ts +99 -0
- package/src/teamsAgentExtension.ts +205 -0
- package/src/teamsApiClientExtensions.ts +47 -0
- package/src/teamsHeaderPropagation.ts +32 -0
- package/src/teamsModelExtensions.ts +42 -0
- package/src/teamsProactiveServiceEndpoints.ts +18 -0
- package/src/teamsRouteHandler.ts +22 -0
- package/src/teamsTurnContext.ts +125 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./teamsChannel"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/channels/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;AAElC,iDAA8B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { AgentApplication, TurnState } from '@microsoft/agents-hosting';
|
|
2
|
+
import type { ChannelInfo } from '@microsoft/teams.api';
|
|
3
|
+
import { TeamsTurnContext } from '../teamsTurnContext';
|
|
4
|
+
type ChannelUpdateHandler<TState extends TurnState> = (context: TeamsTurnContext, state: TState, data: ChannelInfo) => Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Registers handlers for Microsoft Teams channel lifecycle and membership events.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TState - The turn state type used by the agent application.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TeamsChannel<TState extends TurnState = TurnState> {
|
|
11
|
+
private _app;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Teams channel route helper.
|
|
14
|
+
*
|
|
15
|
+
* @param app - The agent application that receives the registered routes.
|
|
16
|
+
*/
|
|
17
|
+
constructor(app: AgentApplication<TState>);
|
|
18
|
+
/**
|
|
19
|
+
* Registers a handler for any Teams channel update event.
|
|
20
|
+
*
|
|
21
|
+
* @param handler - Handler invoked with the Teams turn context, turn state, and channel information.
|
|
22
|
+
* @param rank - Optional route rank used for route ordering.
|
|
23
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
24
|
+
* @returns This channel helper for chaining.
|
|
25
|
+
*/
|
|
26
|
+
onChannelEventReceived(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
27
|
+
/**
|
|
28
|
+
* Registers a handler for Teams channel created events.
|
|
29
|
+
*
|
|
30
|
+
* @param handler - Handler invoked with the created channel information.
|
|
31
|
+
* @param rank - Optional route rank used for route ordering.
|
|
32
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
33
|
+
* @returns This channel helper for chaining.
|
|
34
|
+
*/
|
|
35
|
+
onCreated(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
36
|
+
/**
|
|
37
|
+
* Registers a handler for Teams channel deleted events.
|
|
38
|
+
*
|
|
39
|
+
* @param handler - Handler invoked with the deleted channel information.
|
|
40
|
+
* @param rank - Optional route rank used for route ordering.
|
|
41
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
42
|
+
* @returns This channel helper for chaining.
|
|
43
|
+
*/
|
|
44
|
+
onDeleted(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
45
|
+
/**
|
|
46
|
+
* Registers a handler for Teams channel renamed events.
|
|
47
|
+
*
|
|
48
|
+
* @param handler - Handler invoked with the renamed channel information.
|
|
49
|
+
* @param rank - Optional route rank used for route ordering.
|
|
50
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
51
|
+
* @returns This channel helper for chaining.
|
|
52
|
+
*/
|
|
53
|
+
onRenamed(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
54
|
+
/**
|
|
55
|
+
* Registers a handler for Teams channel restored events.
|
|
56
|
+
*
|
|
57
|
+
* @param handler - Handler invoked with the restored channel information.
|
|
58
|
+
* @param rank - Optional route rank used for route ordering.
|
|
59
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
60
|
+
* @returns This channel helper for chaining.
|
|
61
|
+
*/
|
|
62
|
+
onRestored(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
63
|
+
/**
|
|
64
|
+
* Registers a handler for Teams channel shared events.
|
|
65
|
+
*
|
|
66
|
+
* @param handler - Handler invoked with the shared channel information.
|
|
67
|
+
* @param rank - Optional route rank used for route ordering.
|
|
68
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
69
|
+
* @returns This channel helper for chaining.
|
|
70
|
+
*/
|
|
71
|
+
onShared(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
72
|
+
/**
|
|
73
|
+
* Registers a handler for Teams channel unshared events.
|
|
74
|
+
*
|
|
75
|
+
* @param handler - Handler invoked with the unshared channel information.
|
|
76
|
+
* @param rank - Optional route rank used for route ordering.
|
|
77
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
78
|
+
* @returns This channel helper for chaining.
|
|
79
|
+
*/
|
|
80
|
+
onUnshared(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
81
|
+
/**
|
|
82
|
+
* Registers a handler for member-added events in a Teams channel.
|
|
83
|
+
*
|
|
84
|
+
* @param handler - Handler invoked with channel information for the membership event.
|
|
85
|
+
* @param rank - Optional route rank used for route ordering.
|
|
86
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
87
|
+
* @returns This channel helper for chaining.
|
|
88
|
+
*/
|
|
89
|
+
onMemberAdded(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
90
|
+
/**
|
|
91
|
+
* Registers a handler for member-removed events in a Teams channel.
|
|
92
|
+
*
|
|
93
|
+
* @param handler - Handler invoked with channel information for the membership event.
|
|
94
|
+
* @param rank - Optional route rank used for route ordering.
|
|
95
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
96
|
+
* @returns This channel helper for chaining.
|
|
97
|
+
*/
|
|
98
|
+
onMemberRemoved(handler: ChannelUpdateHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.TeamsChannel = void 0;
|
|
6
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
7
|
+
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
8
|
+
const activity_extensions_1 = require("../activity-extensions");
|
|
9
|
+
const teamsTurnContext_1 = require("../teamsTurnContext");
|
|
10
|
+
const CHANNEL_CREATED_EVENT = 'channelCreated';
|
|
11
|
+
const CHANNEL_DELETED_EVENT = 'channelDeleted';
|
|
12
|
+
const CHANNEL_RENAMED_EVENT = 'channelRenamed';
|
|
13
|
+
const CHANNEL_RESTORED_EVENT = 'channelRestored';
|
|
14
|
+
const CHANNEL_SHARED_EVENT = 'channelShared';
|
|
15
|
+
const CHANNEL_UNSHARED_EVENT = 'channelUnshared';
|
|
16
|
+
const CHANNEL_MEMBER_ADDED_EVENT = 'channelMemberAdded';
|
|
17
|
+
const CHANNEL_MEMBER_REMOVED_EVENT = 'channelMemberRemoved';
|
|
18
|
+
function isChannelUpdateEvent(context, eventType) {
|
|
19
|
+
const channelData = (0, activity_extensions_1.parseTeamsChannelData)(context.activity.channelData);
|
|
20
|
+
const actualEventType = typeof (channelData === null || channelData === void 0 ? void 0 : channelData.eventType) === 'string' ? channelData.eventType.toLowerCase() : undefined;
|
|
21
|
+
const expectedEventType = eventType === null || eventType === void 0 ? void 0 : eventType.toLowerCase();
|
|
22
|
+
return (context.activity.type === agents_activity_1.ActivityTypes.ConversationUpdate &&
|
|
23
|
+
context.activity.channelId === 'msteams' &&
|
|
24
|
+
(channelData === null || channelData === void 0 ? void 0 : channelData.channel) != null &&
|
|
25
|
+
(expectedEventType != null
|
|
26
|
+
? actualEventType === expectedEventType
|
|
27
|
+
: (actualEventType === null || actualEventType === void 0 ? void 0 : actualEventType.startsWith('channel')) === true));
|
|
28
|
+
}
|
|
29
|
+
function getChannelInfo(context) {
|
|
30
|
+
return (0, activity_extensions_1.parseTeamsChannelData)(context.activity.channelData).channel;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Registers handlers for Microsoft Teams channel lifecycle and membership events.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam TState - The turn state type used by the agent application.
|
|
36
|
+
*/
|
|
37
|
+
class TeamsChannel {
|
|
38
|
+
/**
|
|
39
|
+
* Creates a Teams channel route helper.
|
|
40
|
+
*
|
|
41
|
+
* @param app - The agent application that receives the registered routes.
|
|
42
|
+
*/
|
|
43
|
+
constructor(app) {
|
|
44
|
+
this._app = app;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Registers a handler for any Teams channel update event.
|
|
48
|
+
*
|
|
49
|
+
* @param handler - Handler invoked with the Teams turn context, turn state, and channel information.
|
|
50
|
+
* @param rank - Optional route rank used for route ordering.
|
|
51
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
52
|
+
* @returns This channel helper for chaining.
|
|
53
|
+
*/
|
|
54
|
+
onChannelEventReceived(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
55
|
+
const routeSel = (context) => {
|
|
56
|
+
return Promise.resolve(isChannelUpdateEvent(context));
|
|
57
|
+
};
|
|
58
|
+
const routeHandler = async (context, state) => {
|
|
59
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
60
|
+
};
|
|
61
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Registers a handler for Teams channel created events.
|
|
66
|
+
*
|
|
67
|
+
* @param handler - Handler invoked with the created channel information.
|
|
68
|
+
* @param rank - Optional route rank used for route ordering.
|
|
69
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
70
|
+
* @returns This channel helper for chaining.
|
|
71
|
+
*/
|
|
72
|
+
onCreated(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
73
|
+
const routeSel = (context) => {
|
|
74
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_CREATED_EVENT));
|
|
75
|
+
};
|
|
76
|
+
const routeHandler = async (context, state) => {
|
|
77
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
78
|
+
};
|
|
79
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Registers a handler for Teams channel deleted events.
|
|
84
|
+
*
|
|
85
|
+
* @param handler - Handler invoked with the deleted channel information.
|
|
86
|
+
* @param rank - Optional route rank used for route ordering.
|
|
87
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
88
|
+
* @returns This channel helper for chaining.
|
|
89
|
+
*/
|
|
90
|
+
onDeleted(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
91
|
+
const routeSel = (context) => {
|
|
92
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_DELETED_EVENT));
|
|
93
|
+
};
|
|
94
|
+
const routeHandler = async (context, state) => {
|
|
95
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
96
|
+
};
|
|
97
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Registers a handler for Teams channel renamed events.
|
|
102
|
+
*
|
|
103
|
+
* @param handler - Handler invoked with the renamed channel information.
|
|
104
|
+
* @param rank - Optional route rank used for route ordering.
|
|
105
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
106
|
+
* @returns This channel helper for chaining.
|
|
107
|
+
*/
|
|
108
|
+
onRenamed(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
109
|
+
const routeSel = (context) => {
|
|
110
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_RENAMED_EVENT));
|
|
111
|
+
};
|
|
112
|
+
const routeHandler = async (context, state) => {
|
|
113
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
114
|
+
};
|
|
115
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Registers a handler for Teams channel restored events.
|
|
120
|
+
*
|
|
121
|
+
* @param handler - Handler invoked with the restored channel information.
|
|
122
|
+
* @param rank - Optional route rank used for route ordering.
|
|
123
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
124
|
+
* @returns This channel helper for chaining.
|
|
125
|
+
*/
|
|
126
|
+
onRestored(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
127
|
+
const routeSel = (context) => {
|
|
128
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_RESTORED_EVENT));
|
|
129
|
+
};
|
|
130
|
+
const routeHandler = async (context, state) => {
|
|
131
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
132
|
+
};
|
|
133
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Registers a handler for Teams channel shared events.
|
|
138
|
+
*
|
|
139
|
+
* @param handler - Handler invoked with the shared channel information.
|
|
140
|
+
* @param rank - Optional route rank used for route ordering.
|
|
141
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
142
|
+
* @returns This channel helper for chaining.
|
|
143
|
+
*/
|
|
144
|
+
onShared(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
145
|
+
const routeSel = (context) => {
|
|
146
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_SHARED_EVENT));
|
|
147
|
+
};
|
|
148
|
+
const routeHandler = async (context, state) => {
|
|
149
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
150
|
+
};
|
|
151
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Registers a handler for Teams channel unshared events.
|
|
156
|
+
*
|
|
157
|
+
* @param handler - Handler invoked with the unshared channel information.
|
|
158
|
+
* @param rank - Optional route rank used for route ordering.
|
|
159
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
160
|
+
* @returns This channel helper for chaining.
|
|
161
|
+
*/
|
|
162
|
+
onUnshared(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
163
|
+
const routeSel = (context) => {
|
|
164
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_UNSHARED_EVENT));
|
|
165
|
+
};
|
|
166
|
+
const routeHandler = async (context, state) => {
|
|
167
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
168
|
+
};
|
|
169
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Registers a handler for member-added events in a Teams channel.
|
|
174
|
+
*
|
|
175
|
+
* @param handler - Handler invoked with channel information for the membership event.
|
|
176
|
+
* @param rank - Optional route rank used for route ordering.
|
|
177
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
178
|
+
* @returns This channel helper for chaining.
|
|
179
|
+
*/
|
|
180
|
+
onMemberAdded(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
181
|
+
const routeSel = (context) => {
|
|
182
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_MEMBER_ADDED_EVENT));
|
|
183
|
+
};
|
|
184
|
+
const routeHandler = async (context, state) => {
|
|
185
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
186
|
+
};
|
|
187
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Registers a handler for member-removed events in a Teams channel.
|
|
192
|
+
*
|
|
193
|
+
* @param handler - Handler invoked with channel information for the membership event.
|
|
194
|
+
* @param rank - Optional route rank used for route ordering.
|
|
195
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
196
|
+
* @returns This channel helper for chaining.
|
|
197
|
+
*/
|
|
198
|
+
onMemberRemoved(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
199
|
+
const routeSel = (context) => {
|
|
200
|
+
return Promise.resolve(isChannelUpdateEvent(context, CHANNEL_MEMBER_REMOVED_EVENT));
|
|
201
|
+
};
|
|
202
|
+
const routeHandler = async (context, state) => {
|
|
203
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, getChannelInfo(context));
|
|
204
|
+
};
|
|
205
|
+
this._app.addRoute(routeSel, routeHandler, false, rank, authHandlers);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.TeamsChannel = TeamsChannel;
|
|
210
|
+
//# sourceMappingURL=teamsChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamsChannel.js","sourceRoot":"","sources":["../../../src/channels/teamsChannel.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,gEAA0D;AAC1D,8DAA4H;AAC5H,gEAA8D;AAE9D,0DAAsD;AAEtD,MAAM,qBAAqB,GAAG,gBAAgB,CAAA;AAC9C,MAAM,qBAAqB,GAAG,gBAAgB,CAAA;AAC9C,MAAM,qBAAqB,GAAG,gBAAgB,CAAA;AAC9C,MAAM,sBAAsB,GAAG,iBAAiB,CAAA;AAChD,MAAM,oBAAoB,GAAG,eAAe,CAAA;AAC5C,MAAM,sBAAsB,GAAG,iBAAiB,CAAA;AAChD,MAAM,0BAA0B,GAAG,oBAAoB,CAAA;AACvD,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AC,IAAI,mCAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;QAC9E,CAAC,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAA;QACrE,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAtLD,oCAsLC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AgentApplication, TurnState } from '@microsoft/agents-hosting';
|
|
2
|
+
import type { ConfigResponse } from '@microsoft/teams.api';
|
|
3
|
+
import { TeamsTurnContext } from '../teamsTurnContext';
|
|
4
|
+
type ConfigHandler<TState extends TurnState> = (context: TeamsTurnContext, state: TState, configData: unknown) => Promise<ConfigResponse>;
|
|
5
|
+
/**
|
|
6
|
+
* Registers handlers for Microsoft Teams app configuration invokes.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TState - The turn state type used by the agent application.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TeamsConfig<TState extends TurnState = TurnState> {
|
|
11
|
+
private _app;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Teams configuration route helper.
|
|
14
|
+
*
|
|
15
|
+
* @param app - The agent application that receives the registered routes.
|
|
16
|
+
*/
|
|
17
|
+
constructor(app: AgentApplication<TState>);
|
|
18
|
+
/**
|
|
19
|
+
* Registers a handler for Teams config/fetch invokes.
|
|
20
|
+
*
|
|
21
|
+
* @param handler - Handler invoked with the config fetch payload.
|
|
22
|
+
* @param rank - Optional route rank used for route ordering.
|
|
23
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
24
|
+
* @returns This config helper for chaining.
|
|
25
|
+
*/
|
|
26
|
+
onConfigFetch(handler: ConfigHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
27
|
+
/**
|
|
28
|
+
* Registers a handler for Teams config/submit invokes.
|
|
29
|
+
*
|
|
30
|
+
* @param handler - Handler invoked with the config submit payload.
|
|
31
|
+
* @param rank - Optional route rank used for route ordering.
|
|
32
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
33
|
+
* @returns This config helper for chaining.
|
|
34
|
+
*/
|
|
35
|
+
onConfigSubmit(handler: ConfigHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.TeamsConfig = void 0;
|
|
6
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
7
|
+
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
8
|
+
const teamsTurnContext_1 = require("../teamsTurnContext");
|
|
9
|
+
/**
|
|
10
|
+
* Registers handlers for Microsoft Teams app configuration invokes.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam TState - The turn state type used by the agent application.
|
|
13
|
+
*/
|
|
14
|
+
class TeamsConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a Teams configuration route helper.
|
|
17
|
+
*
|
|
18
|
+
* @param app - The agent application that receives the registered routes.
|
|
19
|
+
*/
|
|
20
|
+
constructor(app) {
|
|
21
|
+
this._app = app;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Registers a handler for Teams config/fetch invokes.
|
|
25
|
+
*
|
|
26
|
+
* @param handler - Handler invoked with the config fetch payload.
|
|
27
|
+
* @param rank - Optional route rank used for route ordering.
|
|
28
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
29
|
+
* @returns This config helper for chaining.
|
|
30
|
+
*/
|
|
31
|
+
onConfigFetch(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
32
|
+
const routeSel = (context) => {
|
|
33
|
+
return Promise.resolve(context.activity.type === agents_activity_1.ActivityTypes.Invoke &&
|
|
34
|
+
context.activity.channelId === 'msteams' &&
|
|
35
|
+
context.activity.name === 'config/fetch');
|
|
36
|
+
};
|
|
37
|
+
const routeHandler = async (context, state) => {
|
|
38
|
+
const response = await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, context.activity.value);
|
|
39
|
+
const invokeResponse = new agents_activity_1.Activity(agents_activity_1.ActivityTypes.InvokeResponse);
|
|
40
|
+
invokeResponse.value = { status: 200, body: response };
|
|
41
|
+
await context.sendActivity(invokeResponse);
|
|
42
|
+
};
|
|
43
|
+
this._app.addRoute(routeSel, routeHandler, true, rank, authHandlers);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Registers a handler for Teams config/submit invokes.
|
|
48
|
+
*
|
|
49
|
+
* @param handler - Handler invoked with the config submit payload.
|
|
50
|
+
* @param rank - Optional route rank used for route ordering.
|
|
51
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
52
|
+
* @returns This config helper for chaining.
|
|
53
|
+
*/
|
|
54
|
+
onConfigSubmit(handler, rank = agents_hosting_1.RouteRank.Unspecified, authHandlers = []) {
|
|
55
|
+
const routeSel = (context) => {
|
|
56
|
+
return Promise.resolve(context.activity.type === agents_activity_1.ActivityTypes.Invoke &&
|
|
57
|
+
context.activity.channelId === 'msteams' &&
|
|
58
|
+
context.activity.name === 'config/submit');
|
|
59
|
+
};
|
|
60
|
+
const routeHandler = async (context, state) => {
|
|
61
|
+
const response = await handler(new teamsTurnContext_1.TeamsTurnContext(context), state, context.activity.value);
|
|
62
|
+
const invokeResponse = new agents_activity_1.Activity(agents_activity_1.ActivityTypes.InvokeResponse);
|
|
63
|
+
invokeResponse.value = { status: 200, body: response };
|
|
64
|
+
await context.sendActivity(invokeResponse);
|
|
65
|
+
};
|
|
66
|
+
this._app.addRoute(routeSel, routeHandler, true, rank, authHandlers);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.TeamsConfig = TeamsConfig;
|
|
71
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,gEAAoE;AACpE,8DAA4H;AAE5H,0DAAsD;AAItD;;;;GAIG;AACH,MAAa,WAAW;IAGtB;;;;OAIG;IACH,YAAa,GAA6B;QACxC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;IACjB,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CAAE,OAA8B,EAAE,OAAe,0BAAS,CAAC,WAAW,EAAE,eAAyB,EAAE;QAC9G,MAAM,QAAQ,GAAkB,CAAC,OAAoB,EAAE,EAAE;YACvD,OAAO,OAAO,CAAC,OAAO,CACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,+BAAa,CAAC,MAAM;gBAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS;gBACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,cAAc,CACzC,CAAA;QACH,CAAC,CAAA;QACD,MAAM,YAAY,GAAyB,KAAK,EAAE,OAAoB,EAAE,KAAa,EAAE,EAAE;YACvF,MAAM,QAAQ,GAAmB,MAAM,OAAO,CAAC,IAAI,mCAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAC5G,MAAM,cAAc,GAAG,IAAI,0BAAQ,CAAC,+BAAa,CAAC,cAAc,CAAC,CAAA;YACjE,cAAc,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;YACtD,MAAM,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;QAC5C,CAAC,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,EA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4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./config"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;AAElC,2CAAwB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AgentErrorDefinition } from '@microsoft/agents-activity';
|
|
2
|
+
/**
|
|
3
|
+
* Error definitions for the Teams Extensions system.
|
|
4
|
+
* This contains localized error codes for the Teams Extensions subsystem of the AgentSDK.
|
|
5
|
+
*
|
|
6
|
+
* Each error definition includes an error code (starting from -150000), a description, and a help link
|
|
7
|
+
* pointing to an AKA link to get help for the given error.
|
|
8
|
+
*
|
|
9
|
+
* Usage example:
|
|
10
|
+
* ```
|
|
11
|
+
* throw ExceptionHelper.generateException(
|
|
12
|
+
* Error,
|
|
13
|
+
* Errors.TeamsApiClientNotAvailable
|
|
14
|
+
* );
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const Errors: {
|
|
18
|
+
[key: string]: AgentErrorDefinition;
|
|
19
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Errors = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Error definitions for the Teams Extensions system.
|
|
8
|
+
* This contains localized error codes for the Teams Extensions subsystem of the AgentSDK.
|
|
9
|
+
*
|
|
10
|
+
* Each error definition includes an error code (starting from -150000), a description, and a help link
|
|
11
|
+
* pointing to an AKA link to get help for the given error.
|
|
12
|
+
*
|
|
13
|
+
* Usage example:
|
|
14
|
+
* ```
|
|
15
|
+
* throw ExceptionHelper.generateException(
|
|
16
|
+
* Error,
|
|
17
|
+
* Errors.TeamsApiClientNotAvailable
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
exports.Errors = {
|
|
22
|
+
// Teams Graph Errors (-150012 to -150015, -150017 to -150019)
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when a Graph authorization handler returns an empty token.
|
|
25
|
+
*/
|
|
26
|
+
TeamsGraphTokenUnavailable: {
|
|
27
|
+
code: -150012,
|
|
28
|
+
description: 'Unable to acquire a Graph access token using authorization handler {handlerName}.'
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when no Graph authorization handlers are configured.
|
|
32
|
+
*/
|
|
33
|
+
TeamsGraphAuthorizationHandlerRequired: {
|
|
34
|
+
code: -150013,
|
|
35
|
+
description: 'A Graph client requires at least one configured authorization handler.'
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when multiple Graph authorization handlers are configured and no handler name is provided.
|
|
39
|
+
*/
|
|
40
|
+
TeamsGraphAuthorizationHandlerNameRequired: {
|
|
41
|
+
code: -150014,
|
|
42
|
+
description: 'A Graph client requires handlerName when multiple authorization handlers are configured.'
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when a required Graph client parameter is missing.
|
|
46
|
+
*/
|
|
47
|
+
TeamsGraphParameterRequired: {
|
|
48
|
+
code: -150015,
|
|
49
|
+
description: 'The {parameterName} parameter is required to create a Graph client.'
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Error thrown when the Graph base URL is invalid.
|
|
53
|
+
*/
|
|
54
|
+
TeamsGraphInvalidBaseUrl: {
|
|
55
|
+
code: -150017,
|
|
56
|
+
description: 'The graphBaseUrl parameter must be a valid absolute URL.'
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Error thrown when user authorization is unavailable from the current turn.
|
|
60
|
+
*/
|
|
61
|
+
TeamsGraphUserAuthorizationNotConfigured: {
|
|
62
|
+
code: -150018,
|
|
63
|
+
description: 'User authorization is not configured on the AgentApplication. A delegated Graph client requires configured user authorization.'
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Error thrown when token connections are unavailable.
|
|
67
|
+
*/
|
|
68
|
+
TeamsGraphConnectionsNotConfigured: {
|
|
69
|
+
code: -150019,
|
|
70
|
+
description: 'Connections are not configured on the AgentApplication. An app-only Graph client requires a configured token connection.'
|
|
71
|
+
},
|
|
72
|
+
// TaskModule Errors (-150016)
|
|
73
|
+
/**
|
|
74
|
+
* Error thrown when unexpected TaskModules.submit() is triggered.
|
|
75
|
+
*/
|
|
76
|
+
UnexpectedTaskModuleSubmit: {
|
|
77
|
+
code: -150016,
|
|
78
|
+
description: 'Unexpected TaskModules.submit() triggered for activity type: {activityType}'
|
|
79
|
+
},
|
|
80
|
+
// TeamsApiClient Errors (-150010 to -150011)
|
|
81
|
+
/**
|
|
82
|
+
* Error thrown when the Teams SDK client is not available in the context.
|
|
83
|
+
*/
|
|
84
|
+
TeamsApiClientNotAvailable: {
|
|
85
|
+
code: -150010,
|
|
86
|
+
description: 'Teams API client is not available in the context. Add TeamsAgentExtension to populate it before use.'
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Error thrown when Teams API client prerequisites are missing for Teams activities.
|
|
90
|
+
*/
|
|
91
|
+
TeamsApiClientSetupFailed: {
|
|
92
|
+
code: -150011,
|
|
93
|
+
description: 'Teams API client setup failed: missing {missing}.'
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=errorHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHelper.js","sourceRoot":"","sources":["../../src/errorHelper.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAIlC;;;;;;;;;;;;;;GAcG;AACU,QAAA,MAAM,GAA4C;IAC7D,8DAA8D;IAC9D;;OAEG;IACH,0BAA0B,EAAE;QAC1B,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,mFAAmF;KACjG;IAED;;OAEG;IACH,sCAAsC,EAAE;QACtC,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,wEAAwE;KACtF;IAED;;OAEG;IACH,0CAA0C,EAAE;QAC1C,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,0FAA0F;KACxG;IAED;;OAEG;IACH,2BAA2B,EAAE;QAC3B,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,qEAAqE;KACnF;IAED;;OAEG;IACH,wBAAwB,EAAE;QACxB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,0DAA0D;KACxE;IAED;;OAEG;IACH,wCAAwC,EAAE;QACxC,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,gIAAgI;KAC9I;IAED;;OAEG;IACH,kCAAkC,EAAE;QAClC,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,0HAA0H;KACxI;IAED,8BAA8B;IAC9B;;OAEG;IACH,0BAA0B,EAAE;QAC1B,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,6EAA6E;KAC3F;IAED,6CAA6C;IAC7C;;OAEG;IACH,0BAA0B,EAAE;QAC1B,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,sGAAsG;KACpH;IAED;;OAEG;IACH,yBAAyB,EAAE;QACzB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,mDAAmD;KACjE;CACF,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AgentApplication, TurnState } from '@microsoft/agents-hosting';
|
|
2
|
+
import type { FileConsentCardResponse } from '@microsoft/teams.api';
|
|
3
|
+
import { TeamsTurnContext } from '../teamsTurnContext';
|
|
4
|
+
type FileConsentHandler<TState extends TurnState> = (context: TeamsTurnContext, state: TState, response: FileConsentCardResponse) => Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Registers handlers for Microsoft Teams file consent card actions.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TState - The turn state type used by the agent application.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FileConsent<TState extends TurnState = TurnState> {
|
|
11
|
+
private _app;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Teams file consent route helper.
|
|
14
|
+
*
|
|
15
|
+
* @param app - The agent application that receives the registered routes.
|
|
16
|
+
*/
|
|
17
|
+
constructor(app: AgentApplication<TState>);
|
|
18
|
+
/**
|
|
19
|
+
* Registers a handler for accepted file consent cards.
|
|
20
|
+
*
|
|
21
|
+
* @param handler - Handler invoked with the file consent card response.
|
|
22
|
+
* @param rank - Optional route rank used for route ordering.
|
|
23
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
24
|
+
* @returns This file consent helper for chaining.
|
|
25
|
+
*/
|
|
26
|
+
onAccept(handler: FileConsentHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
27
|
+
/**
|
|
28
|
+
* Registers a handler for declined file consent cards.
|
|
29
|
+
*
|
|
30
|
+
* @param handler - Handler invoked with the file consent card response.
|
|
31
|
+
* @param rank - Optional route rank used for route ordering.
|
|
32
|
+
* @param authHandlers - Optional authorization handlers required by the route.
|
|
33
|
+
* @returns This file consent helper for chaining.
|
|
34
|
+
*/
|
|
35
|
+
onDecline(handler: FileConsentHandler<TState>, rank?: number, authHandlers?: string[]): this;
|
|
36
|
+
}
|
|
37
|
+
export {};
|