@microsoft/teamsfx 1.1.2-alpha.efe3d972e.0 → 1.1.2-rc-hotfix.0
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/dist/index.esm2017.js +3 -73
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +102 -379
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +3 -73
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +104 -387
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -4
- package/types/teamsfx.d.ts +0 -201
package/dist/index.esm2017.mjs
CHANGED
|
@@ -1838,280 +1838,131 @@ var NotificationTargetType;
|
|
|
1838
1838
|
* The notification will be sent to a personal chat.
|
|
1839
1839
|
*/
|
|
1840
1840
|
NotificationTargetType["Person"] = "Person";
|
|
1841
|
-
})(NotificationTargetType || (NotificationTargetType = {}));
|
|
1842
|
-
/**
|
|
1843
|
-
* Options used to control how the response card will be sent to users.
|
|
1844
|
-
*/
|
|
1845
|
-
var AdaptiveCardResponse;
|
|
1846
|
-
(function (AdaptiveCardResponse) {
|
|
1847
|
-
/**
|
|
1848
|
-
* The response card will be replaced the current one for the interactor who trigger the action.
|
|
1849
|
-
*/
|
|
1850
|
-
AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForInteractor"] = 0] = "ReplaceForInteractor";
|
|
1851
|
-
/**
|
|
1852
|
-
* The response card will be replaced the current one for all users in the chat.
|
|
1853
|
-
*/
|
|
1854
|
-
AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForAll"] = 1] = "ReplaceForAll";
|
|
1855
|
-
/**
|
|
1856
|
-
* The response card will be sent as a new message for all users in the chat.
|
|
1857
|
-
*/
|
|
1858
|
-
AdaptiveCardResponse[AdaptiveCardResponse["NewForAll"] = 2] = "NewForAll";
|
|
1859
|
-
})(AdaptiveCardResponse || (AdaptiveCardResponse = {}));
|
|
1860
|
-
/**
|
|
1861
|
-
* Status code for an `application/vnd.microsoft.error` invoke response.
|
|
1862
|
-
*/
|
|
1863
|
-
var InvokeResponseErrorCode;
|
|
1864
|
-
(function (InvokeResponseErrorCode) {
|
|
1865
|
-
/**
|
|
1866
|
-
* Invalid request.
|
|
1867
|
-
*/
|
|
1868
|
-
InvokeResponseErrorCode[InvokeResponseErrorCode["BadRequest"] = 400] = "BadRequest";
|
|
1869
|
-
/**
|
|
1870
|
-
* Internal server error.
|
|
1871
|
-
*/
|
|
1872
|
-
InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
|
|
1873
|
-
})(InvokeResponseErrorCode || (InvokeResponseErrorCode = {}));
|
|
1841
|
+
})(NotificationTargetType || (NotificationTargetType = {}));
|
|
1874
1842
|
|
|
1843
|
+
// Copyright (c) Microsoft Corporation.
|
|
1875
1844
|
/**
|
|
1876
|
-
* Available response type for an adaptive card invoke response.
|
|
1877
1845
|
* @internal
|
|
1878
1846
|
*/
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
InvokeResponseType["Message"] = "application/vnd.microsoft.activity.message";
|
|
1883
|
-
InvokeResponseType["Error"] = "application/vnd.microsoft.error";
|
|
1884
|
-
})(InvokeResponseType || (InvokeResponseType = {}));
|
|
1847
|
+
function cloneConversation(conversation) {
|
|
1848
|
+
return JSON.parse(JSON.stringify(conversation));
|
|
1849
|
+
}
|
|
1885
1850
|
/**
|
|
1886
|
-
*
|
|
1887
|
-
*
|
|
1888
|
-
* @remarks
|
|
1889
|
-
* All of these functions return an {@link InvokeResponse} object, which can be
|
|
1890
|
-
* passed as input to generate a new `invokeResponse` activity.
|
|
1891
|
-
*
|
|
1892
|
-
* This example sends an invoke response that contains an adaptive card.
|
|
1893
|
-
*
|
|
1894
|
-
* ```typescript
|
|
1895
|
-
*
|
|
1896
|
-
* const myCard: IAdaptiveCard = {
|
|
1897
|
-
* type: "AdaptiveCard",
|
|
1898
|
-
* body: [
|
|
1899
|
-
* {
|
|
1900
|
-
* "type": "TextBlock",
|
|
1901
|
-
* "text": "This is a sample card"
|
|
1902
|
-
* }],
|
|
1903
|
-
* $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
1904
|
-
* version: "1.4"
|
|
1905
|
-
* };
|
|
1906
|
-
*
|
|
1907
|
-
* const invokeResponse = InvokeResponseFactory.adaptiveCard(myCard);
|
|
1908
|
-
* await context.sendActivity({
|
|
1909
|
-
* type: ActivityTypes.InvokeResponse,
|
|
1910
|
-
* value: invokeResponse,
|
|
1911
|
-
* });
|
|
1912
|
-
* ```
|
|
1851
|
+
* @internal
|
|
1913
1852
|
*/
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
*
|
|
1920
|
-
* @param message A text message included in a invoke response.
|
|
1921
|
-
*
|
|
1922
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
1923
|
-
*/
|
|
1924
|
-
static textMessage(message) {
|
|
1925
|
-
if (!message) {
|
|
1926
|
-
throw new Error("The text message cannot be null or empty");
|
|
1927
|
-
}
|
|
1928
|
-
return {
|
|
1929
|
-
status: StatusCodes.OK,
|
|
1930
|
-
body: {
|
|
1931
|
-
statusCode: StatusCodes.OK,
|
|
1932
|
-
type: InvokeResponseType.Message,
|
|
1933
|
-
value: message,
|
|
1934
|
-
},
|
|
1935
|
-
};
|
|
1853
|
+
function getTargetType(conversationReference) {
|
|
1854
|
+
var _a;
|
|
1855
|
+
const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
1856
|
+
if (conversationType === "personal") {
|
|
1857
|
+
return NotificationTargetType.Person;
|
|
1936
1858
|
}
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
*
|
|
1940
|
-
* The type of the invoke response is `application/vnd.microsoft.card.adaptive` indicates
|
|
1941
|
-
* the request was successfully processed, and the response includes an adaptive card
|
|
1942
|
-
* that the client should display in place of the current one.
|
|
1943
|
-
*
|
|
1944
|
-
* @param card The adaptive card JSON payload.
|
|
1945
|
-
*
|
|
1946
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
1947
|
-
*/
|
|
1948
|
-
static adaptiveCard(card) {
|
|
1949
|
-
if (!card) {
|
|
1950
|
-
throw new Error("The adaptive card content cannot be null or undefined");
|
|
1951
|
-
}
|
|
1952
|
-
return {
|
|
1953
|
-
status: StatusCodes.OK,
|
|
1954
|
-
body: {
|
|
1955
|
-
statusCode: StatusCodes.OK,
|
|
1956
|
-
type: InvokeResponseType.AdaptiveCard,
|
|
1957
|
-
value: card,
|
|
1958
|
-
},
|
|
1959
|
-
};
|
|
1859
|
+
else if (conversationType === "groupChat") {
|
|
1860
|
+
return NotificationTargetType.Group;
|
|
1960
1861
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
*
|
|
1964
|
-
* The type of the invoke response is `application/vnd.microsoft.error` indicates
|
|
1965
|
-
* the request was failed to processed.
|
|
1966
|
-
*
|
|
1967
|
-
* @param errorCode The status code indicates error, available values:
|
|
1968
|
-
* - 400 (BadRequest): indicate the incoming request was invalid.
|
|
1969
|
-
* - 500 (InternalServerError): indicate an unexpected error occurred.
|
|
1970
|
-
* @param errorMessage The error message.
|
|
1971
|
-
*
|
|
1972
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
1973
|
-
*/
|
|
1974
|
-
static errorResponse(errorCode, errorMessage) {
|
|
1975
|
-
return {
|
|
1976
|
-
status: StatusCodes.OK,
|
|
1977
|
-
body: {
|
|
1978
|
-
statusCode: errorCode,
|
|
1979
|
-
type: InvokeResponseType.Error,
|
|
1980
|
-
value: {
|
|
1981
|
-
code: errorCode.toString(),
|
|
1982
|
-
message: errorMessage,
|
|
1983
|
-
},
|
|
1984
|
-
},
|
|
1985
|
-
};
|
|
1862
|
+
else if (conversationType === "channel") {
|
|
1863
|
+
return NotificationTargetType.Channel;
|
|
1986
1864
|
}
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
* @param statusCode The status code.
|
|
1990
|
-
* @param body The value of the response body.
|
|
1991
|
-
*
|
|
1992
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
1993
|
-
*/
|
|
1994
|
-
static createInvokeResponse(statusCode, body) {
|
|
1995
|
-
return {
|
|
1996
|
-
status: statusCode,
|
|
1997
|
-
body: body,
|
|
1998
|
-
};
|
|
1865
|
+
else {
|
|
1866
|
+
return undefined;
|
|
1999
1867
|
}
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* @internal
|
|
1871
|
+
*/
|
|
1872
|
+
function getTeamsBotInstallationId(context) {
|
|
1873
|
+
var _a, _b, _c, _d;
|
|
1874
|
+
return (_d = (_c = (_b = (_a = context.activity) === null || _a === void 0 ? void 0 : _a.channelData) === null || _b === void 0 ? void 0 : _b.team) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : context.activity.conversation.id;
|
|
2000
1875
|
}
|
|
2001
1876
|
|
|
1877
|
+
// Copyright (c) Microsoft Corporation.
|
|
2002
1878
|
/**
|
|
2003
1879
|
* @internal
|
|
2004
1880
|
*/
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
1881
|
+
var ActivityType;
|
|
1882
|
+
(function (ActivityType) {
|
|
1883
|
+
ActivityType[ActivityType["CurrentBotInstalled"] = 0] = "CurrentBotInstalled";
|
|
1884
|
+
ActivityType[ActivityType["CurrentBotMessaged"] = 1] = "CurrentBotMessaged";
|
|
1885
|
+
ActivityType[ActivityType["CurrentBotUninstalled"] = 2] = "CurrentBotUninstalled";
|
|
1886
|
+
ActivityType[ActivityType["TeamDeleted"] = 3] = "TeamDeleted";
|
|
1887
|
+
ActivityType[ActivityType["TeamRestored"] = 4] = "TeamRestored";
|
|
1888
|
+
ActivityType[ActivityType["Unknown"] = 5] = "Unknown";
|
|
1889
|
+
})(ActivityType || (ActivityType = {}));
|
|
1890
|
+
/**
|
|
1891
|
+
* @internal
|
|
1892
|
+
*/
|
|
1893
|
+
class NotificationMiddleware {
|
|
1894
|
+
constructor(options) {
|
|
1895
|
+
this.conversationReferenceStore = options.conversationReferenceStore;
|
|
2012
1896
|
}
|
|
2013
1897
|
async onTurn(context, next) {
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
case InvokeResponseType.AdaptiveCard:
|
|
2032
|
-
const card = (_c = response.body) === null || _c === void 0 ? void 0 : _c.value;
|
|
2033
|
-
if (!card) {
|
|
2034
|
-
const errorMessage = "Adaptive card content cannot be found in the response body";
|
|
2035
|
-
await this.sendInvokeResponse(context, InvokeResponseFactory.errorResponse(InvokeResponseErrorCode.InternalServerError, errorMessage));
|
|
2036
|
-
throw new Error(errorMessage);
|
|
2037
|
-
}
|
|
2038
|
-
if (card.refresh && handler.adaptiveCardResponse !== AdaptiveCardResponse.NewForAll) {
|
|
2039
|
-
// Card won't be refreshed with AdaptiveCardResponse.ReplaceForInteractor.
|
|
2040
|
-
// So set to AdaptiveCardResponse.ReplaceForAll here.
|
|
2041
|
-
handler.adaptiveCardResponse = AdaptiveCardResponse.ReplaceForAll;
|
|
2042
|
-
}
|
|
2043
|
-
const activity = MessageFactory.attachment(CardFactory.adaptiveCard(card));
|
|
2044
|
-
if (handler.adaptiveCardResponse === AdaptiveCardResponse.NewForAll) {
|
|
2045
|
-
await this.sendInvokeResponse(context, InvokeResponseFactory.textMessage(this.defaultMessage));
|
|
2046
|
-
await context.sendActivity(activity);
|
|
2047
|
-
}
|
|
2048
|
-
else if (handler.adaptiveCardResponse === AdaptiveCardResponse.ReplaceForAll) {
|
|
2049
|
-
activity.id = context.activity.replyToId;
|
|
2050
|
-
await context.updateActivity(activity);
|
|
2051
|
-
await this.sendInvokeResponse(context, response);
|
|
2052
|
-
}
|
|
2053
|
-
else {
|
|
2054
|
-
await this.sendInvokeResponse(context, response);
|
|
2055
|
-
}
|
|
2056
|
-
break;
|
|
2057
|
-
case InvokeResponseType.Message:
|
|
2058
|
-
case InvokeResponseType.Error:
|
|
2059
|
-
default:
|
|
2060
|
-
await this.sendInvokeResponse(context, response);
|
|
2061
|
-
break;
|
|
2062
|
-
}
|
|
2063
|
-
break;
|
|
2064
|
-
}
|
|
1898
|
+
const type = this.classifyActivity(context.activity);
|
|
1899
|
+
switch (type) {
|
|
1900
|
+
case ActivityType.CurrentBotInstalled:
|
|
1901
|
+
case ActivityType.TeamRestored: {
|
|
1902
|
+
const reference = TurnContext.getConversationReference(context.activity);
|
|
1903
|
+
await this.conversationReferenceStore.set(reference);
|
|
1904
|
+
break;
|
|
1905
|
+
}
|
|
1906
|
+
case ActivityType.CurrentBotMessaged: {
|
|
1907
|
+
await this.tryAddMessagedReference(context);
|
|
1908
|
+
break;
|
|
1909
|
+
}
|
|
1910
|
+
case ActivityType.CurrentBotUninstalled:
|
|
1911
|
+
case ActivityType.TeamDeleted: {
|
|
1912
|
+
const reference = TurnContext.getConversationReference(context.activity);
|
|
1913
|
+
await this.conversationReferenceStore.delete(reference);
|
|
1914
|
+
break;
|
|
2065
1915
|
}
|
|
2066
1916
|
}
|
|
2067
1917
|
await next();
|
|
2068
1918
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
* Registers a card action handler to the bot.
|
|
2093
|
-
* @param actionHandler A card action handler to be registered.
|
|
2094
|
-
*/
|
|
2095
|
-
registerHandler(actionHandler) {
|
|
2096
|
-
if (actionHandler) {
|
|
2097
|
-
this.middleware.actionHandlers.push(actionHandler);
|
|
1919
|
+
classifyActivity(activity) {
|
|
1920
|
+
var _a, _b;
|
|
1921
|
+
const activityType = activity.type;
|
|
1922
|
+
if (activityType === "installationUpdate") {
|
|
1923
|
+
const action = (_a = activity.action) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1924
|
+
if (action === "add") {
|
|
1925
|
+
return ActivityType.CurrentBotInstalled;
|
|
1926
|
+
}
|
|
1927
|
+
else {
|
|
1928
|
+
return ActivityType.CurrentBotUninstalled;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
else if (activityType === "conversationUpdate") {
|
|
1932
|
+
const eventType = (_b = activity.channelData) === null || _b === void 0 ? void 0 : _b.eventType;
|
|
1933
|
+
if (eventType === "teamDeleted") {
|
|
1934
|
+
return ActivityType.TeamDeleted;
|
|
1935
|
+
}
|
|
1936
|
+
else if (eventType === "teamRestored") {
|
|
1937
|
+
return ActivityType.TeamRestored;
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
else if (activityType === "message") {
|
|
1941
|
+
return ActivityType.CurrentBotMessaged;
|
|
2098
1942
|
}
|
|
1943
|
+
return ActivityType.Unknown;
|
|
2099
1944
|
}
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
1945
|
+
async tryAddMessagedReference(context) {
|
|
1946
|
+
var _a, _b, _c, _d;
|
|
1947
|
+
const reference = TurnContext.getConversationReference(context.activity);
|
|
1948
|
+
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
1949
|
+
if (conversationType === "personal" || conversationType === "groupChat") {
|
|
1950
|
+
if (!(await this.conversationReferenceStore.check(reference))) {
|
|
1951
|
+
await this.conversationReferenceStore.set(reference);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
else if (conversationType === "channel") {
|
|
1955
|
+
const teamId = (_d = (_c = (_b = context.activity) === null || _b === void 0 ? void 0 : _b.channelData) === null || _c === void 0 ? void 0 : _c.team) === null || _d === void 0 ? void 0 : _d.id;
|
|
1956
|
+
if (teamId !== undefined) {
|
|
1957
|
+
const teamReference = cloneConversation(reference);
|
|
1958
|
+
teamReference.conversation.id = teamId;
|
|
1959
|
+
if (!(await this.conversationReferenceStore.check(teamReference))) {
|
|
1960
|
+
await this.conversationReferenceStore.set(teamReference);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
2107
1963
|
}
|
|
2108
1964
|
}
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
// Copyright (c) Microsoft Corporation.
|
|
2112
|
-
/**
|
|
2113
|
-
* @internal
|
|
2114
|
-
*/
|
|
1965
|
+
}
|
|
2115
1966
|
class CommandResponseMiddleware {
|
|
2116
1967
|
constructor(handlers) {
|
|
2117
1968
|
this.commandHandlers = [];
|
|
@@ -2142,7 +1993,6 @@ class CommandResponseMiddleware {
|
|
|
2142
1993
|
await context.sendActivity(replyActivity);
|
|
2143
1994
|
}
|
|
2144
1995
|
}
|
|
2145
|
-
break;
|
|
2146
1996
|
}
|
|
2147
1997
|
}
|
|
2148
1998
|
}
|
|
@@ -2223,130 +2073,6 @@ class CommandBot {
|
|
|
2223
2073
|
}
|
|
2224
2074
|
}
|
|
2225
2075
|
|
|
2226
|
-
// Copyright (c) Microsoft Corporation.
|
|
2227
|
-
/**
|
|
2228
|
-
* @internal
|
|
2229
|
-
*/
|
|
2230
|
-
function cloneConversation(conversation) {
|
|
2231
|
-
return JSON.parse(JSON.stringify(conversation));
|
|
2232
|
-
}
|
|
2233
|
-
/**
|
|
2234
|
-
* @internal
|
|
2235
|
-
*/
|
|
2236
|
-
function getTargetType(conversationReference) {
|
|
2237
|
-
var _a;
|
|
2238
|
-
const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2239
|
-
if (conversationType === "personal") {
|
|
2240
|
-
return NotificationTargetType.Person;
|
|
2241
|
-
}
|
|
2242
|
-
else if (conversationType === "groupChat") {
|
|
2243
|
-
return NotificationTargetType.Group;
|
|
2244
|
-
}
|
|
2245
|
-
else if (conversationType === "channel") {
|
|
2246
|
-
return NotificationTargetType.Channel;
|
|
2247
|
-
}
|
|
2248
|
-
else {
|
|
2249
|
-
return undefined;
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
/**
|
|
2253
|
-
* @internal
|
|
2254
|
-
*/
|
|
2255
|
-
function getTeamsBotInstallationId(context) {
|
|
2256
|
-
var _a, _b, _c, _d;
|
|
2257
|
-
return (_d = (_c = (_b = (_a = context.activity) === null || _a === void 0 ? void 0 : _a.channelData) === null || _b === void 0 ? void 0 : _b.team) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : context.activity.conversation.id;
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
// Copyright (c) Microsoft Corporation.
|
|
2261
|
-
/**
|
|
2262
|
-
* @internal
|
|
2263
|
-
*/
|
|
2264
|
-
var ActivityType;
|
|
2265
|
-
(function (ActivityType) {
|
|
2266
|
-
ActivityType[ActivityType["CurrentBotInstalled"] = 0] = "CurrentBotInstalled";
|
|
2267
|
-
ActivityType[ActivityType["CurrentBotMessaged"] = 1] = "CurrentBotMessaged";
|
|
2268
|
-
ActivityType[ActivityType["CurrentBotUninstalled"] = 2] = "CurrentBotUninstalled";
|
|
2269
|
-
ActivityType[ActivityType["TeamDeleted"] = 3] = "TeamDeleted";
|
|
2270
|
-
ActivityType[ActivityType["TeamRestored"] = 4] = "TeamRestored";
|
|
2271
|
-
ActivityType[ActivityType["Unknown"] = 5] = "Unknown";
|
|
2272
|
-
})(ActivityType || (ActivityType = {}));
|
|
2273
|
-
/**
|
|
2274
|
-
* @internal
|
|
2275
|
-
*/
|
|
2276
|
-
class NotificationMiddleware {
|
|
2277
|
-
constructor(options) {
|
|
2278
|
-
this.conversationReferenceStore = options.conversationReferenceStore;
|
|
2279
|
-
}
|
|
2280
|
-
async onTurn(context, next) {
|
|
2281
|
-
const type = this.classifyActivity(context.activity);
|
|
2282
|
-
switch (type) {
|
|
2283
|
-
case ActivityType.CurrentBotInstalled:
|
|
2284
|
-
case ActivityType.TeamRestored: {
|
|
2285
|
-
const reference = TurnContext.getConversationReference(context.activity);
|
|
2286
|
-
await this.conversationReferenceStore.set(reference);
|
|
2287
|
-
break;
|
|
2288
|
-
}
|
|
2289
|
-
case ActivityType.CurrentBotMessaged: {
|
|
2290
|
-
await this.tryAddMessagedReference(context);
|
|
2291
|
-
break;
|
|
2292
|
-
}
|
|
2293
|
-
case ActivityType.CurrentBotUninstalled:
|
|
2294
|
-
case ActivityType.TeamDeleted: {
|
|
2295
|
-
const reference = TurnContext.getConversationReference(context.activity);
|
|
2296
|
-
await this.conversationReferenceStore.delete(reference);
|
|
2297
|
-
break;
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
await next();
|
|
2301
|
-
}
|
|
2302
|
-
classifyActivity(activity) {
|
|
2303
|
-
var _a, _b;
|
|
2304
|
-
const activityType = activity.type;
|
|
2305
|
-
if (activityType === "installationUpdate") {
|
|
2306
|
-
const action = (_a = activity.action) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
2307
|
-
if (action === "add") {
|
|
2308
|
-
return ActivityType.CurrentBotInstalled;
|
|
2309
|
-
}
|
|
2310
|
-
else {
|
|
2311
|
-
return ActivityType.CurrentBotUninstalled;
|
|
2312
|
-
}
|
|
2313
|
-
}
|
|
2314
|
-
else if (activityType === "conversationUpdate") {
|
|
2315
|
-
const eventType = (_b = activity.channelData) === null || _b === void 0 ? void 0 : _b.eventType;
|
|
2316
|
-
if (eventType === "teamDeleted") {
|
|
2317
|
-
return ActivityType.TeamDeleted;
|
|
2318
|
-
}
|
|
2319
|
-
else if (eventType === "teamRestored") {
|
|
2320
|
-
return ActivityType.TeamRestored;
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
else if (activityType === "message") {
|
|
2324
|
-
return ActivityType.CurrentBotMessaged;
|
|
2325
|
-
}
|
|
2326
|
-
return ActivityType.Unknown;
|
|
2327
|
-
}
|
|
2328
|
-
async tryAddMessagedReference(context) {
|
|
2329
|
-
var _a, _b, _c, _d;
|
|
2330
|
-
const reference = TurnContext.getConversationReference(context.activity);
|
|
2331
|
-
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2332
|
-
if (conversationType === "personal" || conversationType === "groupChat") {
|
|
2333
|
-
if (!(await this.conversationReferenceStore.check(reference))) {
|
|
2334
|
-
await this.conversationReferenceStore.set(reference);
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
else if (conversationType === "channel") {
|
|
2338
|
-
const teamId = (_d = (_c = (_b = context.activity) === null || _b === void 0 ? void 0 : _b.channelData) === null || _c === void 0 ? void 0 : _c.team) === null || _d === void 0 ? void 0 : _d.id;
|
|
2339
|
-
if (teamId !== undefined) {
|
|
2340
|
-
const teamReference = cloneConversation(reference);
|
|
2341
|
-
teamReference.conversation.id = teamId;
|
|
2342
|
-
if (!(await this.conversationReferenceStore.check(teamReference))) {
|
|
2343
|
-
await this.conversationReferenceStore.set(teamReference);
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
2076
|
// Copyright (c) Microsoft Corporation.
|
|
2351
2077
|
/**
|
|
2352
2078
|
* @internal
|
|
@@ -2850,7 +2576,7 @@ class ConversationBot {
|
|
|
2850
2576
|
* @param options - initialize options
|
|
2851
2577
|
*/
|
|
2852
2578
|
constructor(options) {
|
|
2853
|
-
var _a, _b
|
|
2579
|
+
var _a, _b;
|
|
2854
2580
|
if (options.adapter) {
|
|
2855
2581
|
this.adapter = options.adapter;
|
|
2856
2582
|
}
|
|
@@ -2863,9 +2589,6 @@ class ConversationBot {
|
|
|
2863
2589
|
if ((_b = options.notification) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
2864
2590
|
this.notification = new NotificationBot(this.adapter, options.notification);
|
|
2865
2591
|
}
|
|
2866
|
-
if ((_c = options.cardAction) === null || _c === void 0 ? void 0 : _c.enabled) {
|
|
2867
|
-
this.cardAction = new CardActionBot(this.adapter, options.cardAction);
|
|
2868
|
-
}
|
|
2869
2592
|
}
|
|
2870
2593
|
createDefaultAdapter(adapterConfig) {
|
|
2871
2594
|
const adapter = adapterConfig === undefined
|
|
@@ -3052,5 +2775,5 @@ class MessageBuilder {
|
|
|
3052
2775
|
}
|
|
3053
2776
|
}
|
|
3054
2777
|
|
|
3055
|
-
export {
|
|
2778
|
+
export { ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, CertificateAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, LogLevel, Member, MessageBuilder, MsGraphAuthProvider, NotificationBot, NotificationTargetType, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
|
|
3056
2779
|
//# sourceMappingURL=index.esm2017.mjs.map
|