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