@microsoft/agents-hosting-extensions-msteams 1.7.2
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,13 @@
|
|
|
1
|
+
import { TurnContext } from '@microsoft/agents-hosting';
|
|
2
|
+
/**
|
|
3
|
+
* Turn state key used to store the Teams API client for the current turn.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TeamsClientKey: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Creates and stores a Teams API client for the current Teams turn.
|
|
8
|
+
*
|
|
9
|
+
* @param context - Turn context whose turn state should receive the Teams client.
|
|
10
|
+
* @param channelId - Teams channel ID to match before creating the client. Defaults to `msteams`.
|
|
11
|
+
* @throws If the connector client or service URL required to create the Teams client is missing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setTeamsApiClient(context: TurnContext, channelId?: string): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
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.TeamsClientKey = void 0;
|
|
6
|
+
exports.setTeamsApiClient = setTeamsApiClient;
|
|
7
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
8
|
+
const teams_api_1 = require("@microsoft/teams.api");
|
|
9
|
+
const errorHelper_1 = require("./errorHelper");
|
|
10
|
+
/**
|
|
11
|
+
* Turn state key used to store the Teams API client for the current turn.
|
|
12
|
+
*/
|
|
13
|
+
exports.TeamsClientKey = Symbol('TeamsClient');
|
|
14
|
+
/**
|
|
15
|
+
* Creates and stores a Teams API client for the current Teams turn.
|
|
16
|
+
*
|
|
17
|
+
* @param context - Turn context whose turn state should receive the Teams client.
|
|
18
|
+
* @param channelId - Teams channel ID to match before creating the client. Defaults to `msteams`.
|
|
19
|
+
* @throws If the connector client or service URL required to create the Teams client is missing.
|
|
20
|
+
*/
|
|
21
|
+
function setTeamsApiClient(context, channelId = 'msteams') {
|
|
22
|
+
var _a;
|
|
23
|
+
if (context.activity.channelId !== channelId || context.turnState.has(exports.TeamsClientKey)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const connectorClient = context.turnState.get(context.adapter.ConnectorClientKey);
|
|
27
|
+
const serviceUrl = (_a = context.activity.serviceUrl) !== null && _a !== void 0 ? _a : connectorClient === null || connectorClient === void 0 ? void 0 : connectorClient.httpClient.baseURL;
|
|
28
|
+
if (!connectorClient) {
|
|
29
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.TeamsApiClientSetupFailed, undefined, { missing: 'ConnectorClient in turnState' });
|
|
30
|
+
}
|
|
31
|
+
if (!serviceUrl) {
|
|
32
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.TeamsApiClientSetupFailed, undefined, { missing: 'activity.serviceUrl and ConnectorClient baseURL' });
|
|
33
|
+
}
|
|
34
|
+
context.turnState.set(exports.TeamsClientKey, new teams_api_1.Client(serviceUrl, {
|
|
35
|
+
headers: getClientHeaders(connectorClient)
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function getClientHeaders(connectorClient) {
|
|
39
|
+
return { ...connectorClient.httpClient.defaultHeaders };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=teamsApiClientExtensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamsApiClientExtensions.js","sourceRoot":"","sources":["../../src/teamsApiClientExtensions.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAmBlC,8CAsBC;AAvCD,gEAA4D;AAE5D,oDAA4D;AAC5D,+CAAsC;AAEtC;;GAEG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAEnD;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAE,OAAoB,EAAE,YAAoB,SAAS;;IACpF,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,sBAAc,CAAC,EAAE,CAAC;QACtF,OAAM;IACR,CAAC;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAkB,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAClG,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,QAAQ,CAAC,UAAU,mCAAI,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,UAAU,CAAC,OAAO,CAAA;IAErF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,yBAAyB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAA;IAC1I,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,yBAAyB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC,CAAA;IAC7J,CAAC;IAED,OAAO,CAAC,SAAS,CAAC,GAAG,CACnB,sBAAc,EACd,IAAI,kBAAW,CAAC,UAAU,EAAE;QAC1B,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC;KAC3C,CAAC,CACH,CAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CAAE,eAAgC;IACzD,OAAO,EAAE,GAAG,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HeaderPropagationCollection } from '@microsoft/agents-hosting';
|
|
2
|
+
/**
|
|
3
|
+
* Product token appended to outbound User-Agent headers by the Teams extension.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TEAMS_USER_AGENT_PRODUCT: string;
|
|
6
|
+
/**
|
|
7
|
+
* Applies Teams-specific header propagation to an outbound header collection.
|
|
8
|
+
*
|
|
9
|
+
* The current implementation appends the Teams SDK product token to `User-Agent`, preserving
|
|
10
|
+
* any existing incoming or outgoing User-Agent value.
|
|
11
|
+
*
|
|
12
|
+
* @param headers - Header propagation collection for the current request.
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyTeamsHeaderPropagation(headers: HeaderPropagationCollection): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
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.TEAMS_USER_AGENT_PRODUCT = void 0;
|
|
6
|
+
exports.applyTeamsHeaderPropagation = applyTeamsHeaderPropagation;
|
|
7
|
+
const package_json_1 = require("../package.json");
|
|
8
|
+
const USER_AGENT_HEADER = 'User-Agent';
|
|
9
|
+
/**
|
|
10
|
+
* Product token appended to outbound User-Agent headers by the Teams extension.
|
|
11
|
+
*/
|
|
12
|
+
exports.TEAMS_USER_AGENT_PRODUCT = `agents-sdk-js-teams/${package_json_1.version}`;
|
|
13
|
+
/**
|
|
14
|
+
* Applies Teams-specific header propagation to an outbound header collection.
|
|
15
|
+
*
|
|
16
|
+
* The current implementation appends the Teams SDK product token to `User-Agent`, preserving
|
|
17
|
+
* any existing incoming or outgoing User-Agent value.
|
|
18
|
+
*
|
|
19
|
+
* @param headers - Header propagation collection for the current request.
|
|
20
|
+
*/
|
|
21
|
+
function applyTeamsHeaderPropagation(headers) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const userAgentKey = (_b = (_a = headers.key) === null || _a === void 0 ? void 0 : _a.call(headers, USER_AGENT_HEADER)) !== null && _b !== void 0 ? _b : USER_AGENT_HEADER;
|
|
24
|
+
const userAgent = (_c = headers.outgoing[userAgentKey]) !== null && _c !== void 0 ? _c : headers.incoming[userAgentKey];
|
|
25
|
+
if (!userAgent) {
|
|
26
|
+
headers.add({ [userAgentKey]: exports.TEAMS_USER_AGENT_PRODUCT });
|
|
27
|
+
}
|
|
28
|
+
else if (!userAgent.includes(exports.TEAMS_USER_AGENT_PRODUCT)) {
|
|
29
|
+
headers.concat({ [userAgentKey]: exports.TEAMS_USER_AGENT_PRODUCT });
|
|
30
|
+
}
|
|
31
|
+
else if (!headers.outgoing[userAgentKey]) {
|
|
32
|
+
headers.propagate([userAgentKey]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=teamsHeaderPropagation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamsHeaderPropagation.js","sourceRoot":"","sources":["../../src/teamsHeaderPropagation.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAmBlC,kEAWC;AA3BD,kDAAyC;AAEzC,MAAM,iBAAiB,GAAG,YAAY,CAAA;AACtC;;GAEG;AACU,QAAA,wBAAwB,GAAG,uBAAuB,sBAAO,EAAE,CAAA;AAExE;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CAAE,OAAoC;;IAC/E,MAAM,YAAY,GAAG,MAAA,MAAA,OAAO,CAAC,GAAG,wDAAG,iBAAiB,CAAC,mCAAI,iBAAiB,CAAA;IAC1E,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,mCAAI,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IAElF,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,gCAAwB,EAAE,CAAC,CAAA;IAC3D,CAAC;SAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,gCAAwB,CAAC,EAAE,CAAC;QACzD,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,gCAAwB,EAAE,CAAC,CAAA;IAC9D,CAAC;SAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;IACnC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MessagingExtensionAction, TaskModuleRequest } from '@microsoft/teams.api';
|
|
2
|
+
type TeamsDataContainer = Pick<TaskModuleRequest, 'data'> | Pick<MessagingExtensionAction, 'data'> | null | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Gets the data payload from a Teams task module request or message extension action as the specified type.
|
|
5
|
+
*
|
|
6
|
+
* @param request - Teams request or action that contains a `data` payload.
|
|
7
|
+
* @returns The data payload cast to the requested type, or undefined when no data is present.
|
|
8
|
+
*/
|
|
9
|
+
export declare function teamsGetDataAs<T = unknown>(request: TeamsDataContainer): T | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Gets a string property from a Teams task module request, message extension action, or raw data object.
|
|
12
|
+
*
|
|
13
|
+
* @param source - Teams request, Teams action, or raw data object to inspect.
|
|
14
|
+
* @param key - Property name to read from the data object.
|
|
15
|
+
* @param defaultValue - Value returned when the property is missing or is not a string.
|
|
16
|
+
* @returns The string property value, the default value, or an empty string.
|
|
17
|
+
*/
|
|
18
|
+
export declare function teamsGetDataString(source: TeamsDataContainer | unknown, key: string, defaultValue?: string): string;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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.teamsGetDataAs = teamsGetDataAs;
|
|
6
|
+
exports.teamsGetDataString = teamsGetDataString;
|
|
7
|
+
function hasDataProperty(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null && Object.prototype.hasOwnProperty.call(value, 'data');
|
|
9
|
+
}
|
|
10
|
+
function getSourceData(source) {
|
|
11
|
+
return hasDataProperty(source) ? source.data : source;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Gets the data payload from a Teams task module request or message extension action as the specified type.
|
|
15
|
+
*
|
|
16
|
+
* @param request - Teams request or action that contains a `data` payload.
|
|
17
|
+
* @returns The data payload cast to the requested type, or undefined when no data is present.
|
|
18
|
+
*/
|
|
19
|
+
function teamsGetDataAs(request) {
|
|
20
|
+
return (request === null || request === void 0 ? void 0 : request.data) == null ? undefined : request.data;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets a string property from a Teams task module request, message extension action, or raw data object.
|
|
24
|
+
*
|
|
25
|
+
* @param source - Teams request, Teams action, or raw data object to inspect.
|
|
26
|
+
* @param key - Property name to read from the data object.
|
|
27
|
+
* @param defaultValue - Value returned when the property is missing or is not a string.
|
|
28
|
+
* @returns The string property value, the default value, or an empty string.
|
|
29
|
+
*/
|
|
30
|
+
function teamsGetDataString(source, key, defaultValue) {
|
|
31
|
+
const data = getSourceData(source);
|
|
32
|
+
if (typeof data !== 'object' || data === null || Array.isArray(data)) {
|
|
33
|
+
return defaultValue !== null && defaultValue !== void 0 ? defaultValue : '';
|
|
34
|
+
}
|
|
35
|
+
const value = data[key];
|
|
36
|
+
return typeof value === 'string' ? value : defaultValue !== null && defaultValue !== void 0 ? defaultValue : '';
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=teamsModelExtensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamsModelExtensions.js","sourceRoot":"","sources":["../../src/teamsModelExtensions.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;AAoBlC,wCAEC;AAUD,gDAQC;AAlCD,SAAS,eAAe,CAAE,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAC3G,CAAC;AAED,SAAS,aAAa,CAAE,MAAoC;IAC1D,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAe,OAA2B;IACtE,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,KAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAS,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAE,MAAoC,EAAE,GAAW,EAAE,YAAqB;IAC1G,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IAClC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,OAAO,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAA;IAC3B,CAAC;IAED,MAAM,KAAK,GAAI,IAAgC,CAAC,GAAG,CAAC,CAAA;IACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Well-known service endpoint URLs for sending proactive messages to Microsoft Teams.
|
|
3
|
+
* Use these only if the incoming request serviceUrl is unavailable; once a serviceUrl
|
|
4
|
+
* has been returned from a prior conversation, cache and use that value instead.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TeamsProactiveServiceEndpoints: {
|
|
7
|
+
/** Service endpoint for the public global Teams environment. */
|
|
8
|
+
readonly publicGlobal: "https://smba.trafficmanager.net/teams/";
|
|
9
|
+
/** Service endpoint for the GCC (Government Community Cloud) Teams environment. */
|
|
10
|
+
readonly gcc: "https://smba.infra.gcc.teams.microsoft.com/teams";
|
|
11
|
+
/** Service endpoint for the GCC High Teams environment. */
|
|
12
|
+
readonly gccHigh: "https://smba.infra.gov.teams.microsoft.us/teams";
|
|
13
|
+
/** Service endpoint for the DoD (Department of Defense) Teams environment. */
|
|
14
|
+
readonly dod: "https://smba.infra.dod.teams.microsoft.us/teams";
|
|
15
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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.TeamsProactiveServiceEndpoints = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Well-known service endpoint URLs for sending proactive messages to Microsoft Teams.
|
|
8
|
+
* Use these only if the incoming request serviceUrl is unavailable; once a serviceUrl
|
|
9
|
+
* has been returned from a prior conversation, cache and use that value instead.
|
|
10
|
+
*/
|
|
11
|
+
exports.TeamsProactiveServiceEndpoints = {
|
|
12
|
+
/** Service endpoint for the public global Teams environment. */
|
|
13
|
+
publicGlobal: 'https://smba.trafficmanager.net/teams/',
|
|
14
|
+
/** Service endpoint for the GCC (Government Community Cloud) Teams environment. */
|
|
15
|
+
gcc: 'https://smba.infra.gcc.teams.microsoft.com/teams',
|
|
16
|
+
/** Service endpoint for the GCC High Teams environment. */
|
|
17
|
+
gccHigh: 'https://smba.infra.gov.teams.microsoft.us/teams',
|
|
18
|
+
/** Service endpoint for the DoD (Department of Defense) Teams environment. */
|
|
19
|
+
dod: 'https://smba.infra.dod.teams.microsoft.us/teams'
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=teamsProactiveServiceEndpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamsProactiveServiceEndpoints.js","sourceRoot":"","sources":["../../src/teamsProactiveServiceEndpoints.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC;;;;GAIG;AACU,QAAA,8BAA8B,GAAG;IAC5C,gEAAgE;IAChE,YAAY,EAAE,wCAAwC;IACtD,mFAAmF;IACnF,GAAG,EAAE,kDAAkD;IACvD,2DAA2D;IAC3D,OAAO,EAAE,iDAAiD;IAC1D,8EAA8E;IAC9E,GAAG,EAAE,iDAAiD;CAC9C,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RouteHandler, TurnState } from '@microsoft/agents-hosting';
|
|
2
|
+
import { TeamsTurnContext } from './teamsTurnContext';
|
|
3
|
+
/**
|
|
4
|
+
* Route handler that receives a Teams-specific turn context.
|
|
5
|
+
*/
|
|
6
|
+
export type TeamsRouteHandler<TState extends TurnState> = (context: TeamsTurnContext, state: TState) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a Teams route handler so it can be registered with an agent application route.
|
|
9
|
+
*
|
|
10
|
+
* @param handler - Handler that expects a Teams turn context.
|
|
11
|
+
* @returns A route handler that creates a Teams turn context for the current turn.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createTeamsRouteHandler<TState extends TurnState>(handler: TeamsRouteHandler<TState>): RouteHandler<TState>;
|
|
@@ -0,0 +1,18 @@
|
|
|
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.createTeamsRouteHandler = createTeamsRouteHandler;
|
|
6
|
+
const teamsTurnContext_1 = require("./teamsTurnContext");
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a Teams route handler so it can be registered with an agent application route.
|
|
9
|
+
*
|
|
10
|
+
* @param handler - Handler that expects a Teams turn context.
|
|
11
|
+
* @returns A route handler that creates a Teams turn context for the current turn.
|
|
12
|
+
*/
|
|
13
|
+
function createTeamsRouteHandler(handler) {
|
|
14
|
+
return async (context, state) => {
|
|
15
|
+
await handler(new teamsTurnContext_1.TeamsTurnContext(context), state);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=teamsRouteHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamsRouteHandler.js","sourceRoot":"","sources":["../../src/teamsRouteHandler.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;AAgBlC,0DAIC;AAjBD,yDAAqD;AAOrD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAA4B,OAAkC;IACnG,OAAO,KAAK,EAAE,OAAoB,EAAE,KAAa,EAAE,EAAE;QACnD,MAAM,OAAO,CAAC,IAAI,mCAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Activity } from '@microsoft/agents-activity';
|
|
2
|
+
import { Client as GraphClient } from '@microsoft/microsoft-graph-client';
|
|
3
|
+
import { ResourceResponse, TurnContext } from '@microsoft/agents-hosting';
|
|
4
|
+
import { Client as TeamsClient } from '@microsoft/teams.api';
|
|
5
|
+
import type { TeamsActivity } from './teamsActivity';
|
|
6
|
+
/**
|
|
7
|
+
* Turn context wrapper that exposes Teams-specific helpers for a Teams activity turn.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TeamsTurnContext extends TurnContext {
|
|
10
|
+
/**
|
|
11
|
+
* Gets the incoming activity with strongly typed Teams channel data.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* The returned object is the original turn activity. This getter only narrows
|
|
15
|
+
* its TypeScript type and does not convert or clone the activity.
|
|
16
|
+
*/
|
|
17
|
+
get activity(): TeamsActivity;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the Teams API client for the current turn.
|
|
20
|
+
*
|
|
21
|
+
* @returns The Teams API client configured for the activity's service URL.
|
|
22
|
+
* @throws If the Teams API client is not available in turn state.
|
|
23
|
+
*/
|
|
24
|
+
get client(): TeamsClient;
|
|
25
|
+
/**
|
|
26
|
+
* Sends a cloned copy of an activity as a Teams targeted activity.
|
|
27
|
+
*
|
|
28
|
+
* @param activity - The activity to send to the targeted recipient.
|
|
29
|
+
* @returns The resource response for the sent activity, if provided by the adapter.
|
|
30
|
+
*/
|
|
31
|
+
sendTargetedActivity(activity: Activity): Promise<ResourceResponse | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Sends cloned copies of activities as Teams targeted activities.
|
|
34
|
+
*
|
|
35
|
+
* @param activities - The activities to send to targeted recipients.
|
|
36
|
+
* @returns Resource responses for the sent activities.
|
|
37
|
+
*/
|
|
38
|
+
sendTargetedActivities(activities: Activity[]): Promise<ResourceResponse[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Microsoft Graph client authenticated with a delegated token for the current user.
|
|
41
|
+
*
|
|
42
|
+
* @param handlerName - Optional authorization handler name. Required when multiple handlers are configured.
|
|
43
|
+
* @param graphBaseUrl - Optional Graph base URL. Defaults to Microsoft Graph v1.0.
|
|
44
|
+
* @returns A Microsoft Graph client configured with delegated permissions.
|
|
45
|
+
*/
|
|
46
|
+
getGraphClient(handlerName?: string, graphBaseUrl?: string): GraphClient;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a Microsoft Graph client authenticated with an app-only token from the current turn's connection.
|
|
49
|
+
*
|
|
50
|
+
* @param graphBaseUrl - Optional Graph base URL. Defaults to Microsoft Graph v1.0.
|
|
51
|
+
* @returns A Microsoft Graph client configured with application permissions.
|
|
52
|
+
*/
|
|
53
|
+
getAppGraphClient(graphBaseUrl?: string): GraphClient;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a Microsoft Graph client authenticated with an app-only token from a named connection.
|
|
56
|
+
*
|
|
57
|
+
* @param connectionName - The configured token connection name.
|
|
58
|
+
* @param graphBaseUrl - Optional Graph base URL. Defaults to Microsoft Graph v1.0.
|
|
59
|
+
* @returns A Microsoft Graph client configured with application permissions.
|
|
60
|
+
*/
|
|
61
|
+
getAppGraphClientForConnection(connectionName: string, graphBaseUrl?: string): GraphClient;
|
|
62
|
+
private getUserAuthorization;
|
|
63
|
+
private getConnections;
|
|
64
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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.TeamsTurnContext = void 0;
|
|
6
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
7
|
+
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
8
|
+
const errorHelper_1 = require("./errorHelper");
|
|
9
|
+
const teamsApiClientExtensions_1 = require("./teamsApiClientExtensions");
|
|
10
|
+
const graphClientFactory_1 = require("./graphClientFactory");
|
|
11
|
+
const DEFAULT_GRAPH_BASE_URL = 'https://graph.microsoft.com/v1.0';
|
|
12
|
+
/**
|
|
13
|
+
* Turn context wrapper that exposes Teams-specific helpers for a Teams activity turn.
|
|
14
|
+
*/
|
|
15
|
+
class TeamsTurnContext extends agents_hosting_1.TurnContext {
|
|
16
|
+
/**
|
|
17
|
+
* Gets the incoming activity with strongly typed Teams channel data.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The returned object is the original turn activity. This getter only narrows
|
|
21
|
+
* its TypeScript type and does not convert or clone the activity.
|
|
22
|
+
*/
|
|
23
|
+
get activity() {
|
|
24
|
+
return super.activity;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the Teams API client for the current turn.
|
|
28
|
+
*
|
|
29
|
+
* @returns The Teams API client configured for the activity's service URL.
|
|
30
|
+
* @throws If the Teams API client is not available in turn state.
|
|
31
|
+
*/
|
|
32
|
+
get client() {
|
|
33
|
+
const teamsClient = this.turnState.get(teamsApiClientExtensions_1.TeamsClientKey);
|
|
34
|
+
if (!teamsClient) {
|
|
35
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.TeamsApiClientNotAvailable);
|
|
36
|
+
}
|
|
37
|
+
return teamsClient;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Sends a cloned copy of an activity as a Teams targeted activity.
|
|
41
|
+
*
|
|
42
|
+
* @param activity - The activity to send to the targeted recipient.
|
|
43
|
+
* @returns The resource response for the sent activity, if provided by the adapter.
|
|
44
|
+
*/
|
|
45
|
+
async sendTargetedActivity(activity) {
|
|
46
|
+
const targetedActivity = agents_activity_1.Activity.fromObject(activity);
|
|
47
|
+
targetedActivity.makeTargetedActivity();
|
|
48
|
+
return await this.sendActivity(targetedActivity);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sends cloned copies of activities as Teams targeted activities.
|
|
52
|
+
*
|
|
53
|
+
* @param activities - The activities to send to targeted recipients.
|
|
54
|
+
* @returns Resource responses for the sent activities.
|
|
55
|
+
*/
|
|
56
|
+
async sendTargetedActivities(activities) {
|
|
57
|
+
const targetedActivities = activities.map((activity) => {
|
|
58
|
+
const targetedActivity = agents_activity_1.Activity.fromObject(activity);
|
|
59
|
+
targetedActivity.makeTargetedActivity();
|
|
60
|
+
return targetedActivity;
|
|
61
|
+
});
|
|
62
|
+
return await this.sendActivities(targetedActivities);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a Microsoft Graph client authenticated with a delegated token for the current user.
|
|
66
|
+
*
|
|
67
|
+
* @param handlerName - Optional authorization handler name. Required when multiple handlers are configured.
|
|
68
|
+
* @param graphBaseUrl - Optional Graph base URL. Defaults to Microsoft Graph v1.0.
|
|
69
|
+
* @returns A Microsoft Graph client configured with delegated permissions.
|
|
70
|
+
*/
|
|
71
|
+
getGraphClient(handlerName, graphBaseUrl = DEFAULT_GRAPH_BASE_URL) {
|
|
72
|
+
return (0, graphClientFactory_1.createUserGraphClient)(this.getUserAuthorization(), this, handlerName, graphBaseUrl);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a Microsoft Graph client authenticated with an app-only token from the current turn's connection.
|
|
76
|
+
*
|
|
77
|
+
* @param graphBaseUrl - Optional Graph base URL. Defaults to Microsoft Graph v1.0.
|
|
78
|
+
* @returns A Microsoft Graph client configured with application permissions.
|
|
79
|
+
*/
|
|
80
|
+
getAppGraphClient(graphBaseUrl = DEFAULT_GRAPH_BASE_URL) {
|
|
81
|
+
const tokenProvider = this.getConnections().getTokenProviderFromActivity(this.identity, this.activity);
|
|
82
|
+
return (0, graphClientFactory_1.createAppGraphClient)(tokenProvider, graphBaseUrl);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates a Microsoft Graph client authenticated with an app-only token from a named connection.
|
|
86
|
+
*
|
|
87
|
+
* @param connectionName - The configured token connection name.
|
|
88
|
+
* @param graphBaseUrl - Optional Graph base URL. Defaults to Microsoft Graph v1.0.
|
|
89
|
+
* @returns A Microsoft Graph client configured with application permissions.
|
|
90
|
+
*/
|
|
91
|
+
getAppGraphClientForConnection(connectionName, graphBaseUrl = DEFAULT_GRAPH_BASE_URL) {
|
|
92
|
+
if (!connectionName) {
|
|
93
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.TeamsGraphParameterRequired, undefined, { parameterName: 'connectionName' });
|
|
94
|
+
}
|
|
95
|
+
return (0, graphClientFactory_1.createAppGraphClient)(this.getConnections().getConnection(connectionName), graphBaseUrl);
|
|
96
|
+
}
|
|
97
|
+
getUserAuthorization() {
|
|
98
|
+
const authorization = this.turnState.get(agents_hosting_1.AgentApplication.UserAuthorizationKey);
|
|
99
|
+
if (!authorization) {
|
|
100
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.TeamsGraphUserAuthorizationNotConfigured);
|
|
101
|
+
}
|
|
102
|
+
return authorization;
|
|
103
|
+
}
|
|
104
|
+
getConnections() {
|
|
105
|
+
const connections = this.turnState.get(agents_hosting_1.AgentApplication.ConnectionsKey);
|
|
106
|
+
if (!connections) {
|
|
107
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.TeamsGraphConnectionsNotConfigured);
|
|
108
|
+
}
|
|
109
|
+
return connections;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.TeamsTurnContext = TeamsTurnContext;
|
|
113
|
+
//# sourceMappingURL=teamsTurnContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamsTurnContext.js","sourceRoot":"","sources":["../../src/teamsTurnContext.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@microsoft/agents-hosting-extensions-msteams",
|
|
4
|
+
"version": "1.7.2",
|
|
5
|
+
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/microsoft/Agents-for-js.git"
|
|
9
|
+
},
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Microsoft",
|
|
12
|
+
"email": "agentssdk@microsoft.com",
|
|
13
|
+
"url": "https://aka.ms/Agents"
|
|
14
|
+
},
|
|
15
|
+
"description": "Microsoft 365 Agents SDK for JavaScript. MS Teams extensions",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"Agents"
|
|
18
|
+
],
|
|
19
|
+
"main": "dist/src/index.js",
|
|
20
|
+
"types": "dist/src/index.d.ts",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@microsoft/agents-activity": "1.7.2",
|
|
23
|
+
"@microsoft/agents-hosting": "1.7.2",
|
|
24
|
+
"@microsoft/microsoft-graph-client": "3.0.7",
|
|
25
|
+
"@microsoft/teams.api": "2.0.14",
|
|
26
|
+
"zod": "3.25.75"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"files": [
|
|
30
|
+
"README.md",
|
|
31
|
+
"dist/package.json",
|
|
32
|
+
"dist/src",
|
|
33
|
+
"src",
|
|
34
|
+
"package.json"
|
|
35
|
+
],
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"import": "./dist/src/index.js",
|
|
39
|
+
"require": "./dist/src/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright(c) Microsoft Corporation.All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod'
|
|
7
|
+
import type { ChannelData } from '@microsoft/teams.api'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Root-level validation for Teams channel data objects.
|
|
11
|
+
*
|
|
12
|
+
* The Teams SDK already defines the nested ChannelData shape. This parser
|
|
13
|
+
* normalizes missing root data to an empty object, verifies non-nullish input is
|
|
14
|
+
* an object, and preserves all properties as-is.
|
|
15
|
+
*/
|
|
16
|
+
const teamsChannelDataZodSchema = z.object({}).passthrough()
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Parses the given object as Teams ChannelData.
|
|
20
|
+
*
|
|
21
|
+
* @param {unknown} o - The value to parse.
|
|
22
|
+
* @returns {ChannelData} - The parsed ChannelData.
|
|
23
|
+
*/
|
|
24
|
+
export function parseTeamsChannelData (o: unknown): ChannelData {
|
|
25
|
+
if (o == null) {
|
|
26
|
+
return {} as ChannelData
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return teamsChannelDataZodSchema.parse(o) as ChannelData
|
|
30
|
+
}
|
package/src/app/index.ts
ADDED