@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.node.cjs.js
CHANGED
|
@@ -1723,9 +1723,8 @@ class TeamsFx {
|
|
|
1723
1723
|
this.configuration = new Map();
|
|
1724
1724
|
this.loadFromEnv();
|
|
1725
1725
|
if (customConfig) {
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
const value = myConfig[key];
|
|
1726
|
+
for (const key of Object.keys(customConfig)) {
|
|
1727
|
+
const value = customConfig[key];
|
|
1729
1728
|
if (value) {
|
|
1730
1729
|
this.configuration.set(key, value);
|
|
1731
1730
|
}
|
|
@@ -1905,284 +1904,135 @@ exports.NotificationTargetType = void 0;
|
|
|
1905
1904
|
* The notification will be sent to a personal chat.
|
|
1906
1905
|
*/
|
|
1907
1906
|
NotificationTargetType["Person"] = "Person";
|
|
1908
|
-
})(exports.NotificationTargetType || (exports.NotificationTargetType = {}));
|
|
1909
|
-
/**
|
|
1910
|
-
* Options used to control how the response card will be sent to users.
|
|
1911
|
-
*/
|
|
1912
|
-
exports.AdaptiveCardResponse = void 0;
|
|
1913
|
-
(function (AdaptiveCardResponse) {
|
|
1914
|
-
/**
|
|
1915
|
-
* The response card will be replaced the current one for the interactor who trigger the action.
|
|
1916
|
-
*/
|
|
1917
|
-
AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForInteractor"] = 0] = "ReplaceForInteractor";
|
|
1918
|
-
/**
|
|
1919
|
-
* The response card will be replaced the current one for all users in the chat.
|
|
1920
|
-
*/
|
|
1921
|
-
AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForAll"] = 1] = "ReplaceForAll";
|
|
1922
|
-
/**
|
|
1923
|
-
* The response card will be sent as a new message for all users in the chat.
|
|
1924
|
-
*/
|
|
1925
|
-
AdaptiveCardResponse[AdaptiveCardResponse["NewForAll"] = 2] = "NewForAll";
|
|
1926
|
-
})(exports.AdaptiveCardResponse || (exports.AdaptiveCardResponse = {}));
|
|
1927
|
-
/**
|
|
1928
|
-
* Status code for an `application/vnd.microsoft.error` invoke response.
|
|
1929
|
-
*/
|
|
1930
|
-
exports.InvokeResponseErrorCode = void 0;
|
|
1931
|
-
(function (InvokeResponseErrorCode) {
|
|
1932
|
-
/**
|
|
1933
|
-
* Invalid request.
|
|
1934
|
-
*/
|
|
1935
|
-
InvokeResponseErrorCode[InvokeResponseErrorCode["BadRequest"] = 400] = "BadRequest";
|
|
1936
|
-
/**
|
|
1937
|
-
* Internal server error.
|
|
1938
|
-
*/
|
|
1939
|
-
InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
|
|
1940
|
-
})(exports.InvokeResponseErrorCode || (exports.InvokeResponseErrorCode = {}));
|
|
1907
|
+
})(exports.NotificationTargetType || (exports.NotificationTargetType = {}));
|
|
1941
1908
|
|
|
1909
|
+
// Copyright (c) Microsoft Corporation.
|
|
1942
1910
|
/**
|
|
1943
|
-
* Available response type for an adaptive card invoke response.
|
|
1944
1911
|
* @internal
|
|
1945
1912
|
*/
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
InvokeResponseType["Message"] = "application/vnd.microsoft.activity.message";
|
|
1950
|
-
InvokeResponseType["Error"] = "application/vnd.microsoft.error";
|
|
1951
|
-
})(InvokeResponseType || (InvokeResponseType = {}));
|
|
1913
|
+
function cloneConversation(conversation) {
|
|
1914
|
+
return JSON.parse(JSON.stringify(conversation));
|
|
1915
|
+
}
|
|
1952
1916
|
/**
|
|
1953
|
-
*
|
|
1954
|
-
*
|
|
1955
|
-
* @remarks
|
|
1956
|
-
* All of these functions return an {@link InvokeResponse} object, which can be
|
|
1957
|
-
* passed as input to generate a new `invokeResponse` activity.
|
|
1958
|
-
*
|
|
1959
|
-
* This example sends an invoke response that contains an adaptive card.
|
|
1960
|
-
*
|
|
1961
|
-
* ```typescript
|
|
1962
|
-
*
|
|
1963
|
-
* const myCard: IAdaptiveCard = {
|
|
1964
|
-
* type: "AdaptiveCard",
|
|
1965
|
-
* body: [
|
|
1966
|
-
* {
|
|
1967
|
-
* "type": "TextBlock",
|
|
1968
|
-
* "text": "This is a sample card"
|
|
1969
|
-
* }],
|
|
1970
|
-
* $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
1971
|
-
* version: "1.4"
|
|
1972
|
-
* };
|
|
1973
|
-
*
|
|
1974
|
-
* const invokeResponse = InvokeResponseFactory.adaptiveCard(myCard);
|
|
1975
|
-
* await context.sendActivity({
|
|
1976
|
-
* type: ActivityTypes.InvokeResponse,
|
|
1977
|
-
* value: invokeResponse,
|
|
1978
|
-
* });
|
|
1979
|
-
* ```
|
|
1917
|
+
* @internal
|
|
1980
1918
|
*/
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
*
|
|
1987
|
-
* @param message A text message included in a invoke response.
|
|
1988
|
-
*
|
|
1989
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
1990
|
-
*/
|
|
1991
|
-
static textMessage(message) {
|
|
1992
|
-
if (!message) {
|
|
1993
|
-
throw new Error("The text message cannot be null or empty");
|
|
1994
|
-
}
|
|
1995
|
-
return {
|
|
1996
|
-
status: botbuilder.StatusCodes.OK,
|
|
1997
|
-
body: {
|
|
1998
|
-
statusCode: botbuilder.StatusCodes.OK,
|
|
1999
|
-
type: InvokeResponseType.Message,
|
|
2000
|
-
value: message,
|
|
2001
|
-
},
|
|
2002
|
-
};
|
|
1919
|
+
function getTargetType(conversationReference) {
|
|
1920
|
+
var _a;
|
|
1921
|
+
const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
1922
|
+
if (conversationType === "personal") {
|
|
1923
|
+
return exports.NotificationTargetType.Person;
|
|
2003
1924
|
}
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
*
|
|
2007
|
-
* The type of the invoke response is `application/vnd.microsoft.card.adaptive` indicates
|
|
2008
|
-
* the request was successfully processed, and the response includes an adaptive card
|
|
2009
|
-
* that the client should display in place of the current one.
|
|
2010
|
-
*
|
|
2011
|
-
* @param card The adaptive card JSON payload.
|
|
2012
|
-
*
|
|
2013
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
2014
|
-
*/
|
|
2015
|
-
static adaptiveCard(card) {
|
|
2016
|
-
if (!card) {
|
|
2017
|
-
throw new Error("The adaptive card content cannot be null or undefined");
|
|
2018
|
-
}
|
|
2019
|
-
return {
|
|
2020
|
-
status: botbuilder.StatusCodes.OK,
|
|
2021
|
-
body: {
|
|
2022
|
-
statusCode: botbuilder.StatusCodes.OK,
|
|
2023
|
-
type: InvokeResponseType.AdaptiveCard,
|
|
2024
|
-
value: card,
|
|
2025
|
-
},
|
|
2026
|
-
};
|
|
1925
|
+
else if (conversationType === "groupChat") {
|
|
1926
|
+
return exports.NotificationTargetType.Group;
|
|
2027
1927
|
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
*
|
|
2031
|
-
* The type of the invoke response is `application/vnd.microsoft.error` indicates
|
|
2032
|
-
* the request was failed to processed.
|
|
2033
|
-
*
|
|
2034
|
-
* @param errorCode The status code indicates error, available values:
|
|
2035
|
-
* - 400 (BadRequest): indicate the incoming request was invalid.
|
|
2036
|
-
* - 500 (InternalServerError): indicate an unexpected error occurred.
|
|
2037
|
-
* @param errorMessage The error message.
|
|
2038
|
-
*
|
|
2039
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
2040
|
-
*/
|
|
2041
|
-
static errorResponse(errorCode, errorMessage) {
|
|
2042
|
-
return {
|
|
2043
|
-
status: botbuilder.StatusCodes.OK,
|
|
2044
|
-
body: {
|
|
2045
|
-
statusCode: errorCode,
|
|
2046
|
-
type: InvokeResponseType.Error,
|
|
2047
|
-
value: {
|
|
2048
|
-
code: errorCode.toString(),
|
|
2049
|
-
message: errorMessage,
|
|
2050
|
-
},
|
|
2051
|
-
},
|
|
2052
|
-
};
|
|
1928
|
+
else if (conversationType === "channel") {
|
|
1929
|
+
return exports.NotificationTargetType.Channel;
|
|
2053
1930
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
* @param statusCode The status code.
|
|
2057
|
-
* @param body The value of the response body.
|
|
2058
|
-
*
|
|
2059
|
-
* @returns {InvokeResponse} An InvokeResponse object.
|
|
2060
|
-
*/
|
|
2061
|
-
static createInvokeResponse(statusCode, body) {
|
|
2062
|
-
return {
|
|
2063
|
-
status: statusCode,
|
|
2064
|
-
body: body,
|
|
2065
|
-
};
|
|
1931
|
+
else {
|
|
1932
|
+
return undefined;
|
|
2066
1933
|
}
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* @internal
|
|
1937
|
+
*/
|
|
1938
|
+
function getTeamsBotInstallationId(context) {
|
|
1939
|
+
var _a, _b, _c, _d;
|
|
1940
|
+
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;
|
|
2067
1941
|
}
|
|
2068
1942
|
|
|
1943
|
+
// Copyright (c) Microsoft Corporation.
|
|
2069
1944
|
/**
|
|
2070
1945
|
* @internal
|
|
2071
1946
|
*/
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
1947
|
+
var ActivityType;
|
|
1948
|
+
(function (ActivityType) {
|
|
1949
|
+
ActivityType[ActivityType["CurrentBotInstalled"] = 0] = "CurrentBotInstalled";
|
|
1950
|
+
ActivityType[ActivityType["CurrentBotMessaged"] = 1] = "CurrentBotMessaged";
|
|
1951
|
+
ActivityType[ActivityType["CurrentBotUninstalled"] = 2] = "CurrentBotUninstalled";
|
|
1952
|
+
ActivityType[ActivityType["TeamDeleted"] = 3] = "TeamDeleted";
|
|
1953
|
+
ActivityType[ActivityType["TeamRestored"] = 4] = "TeamRestored";
|
|
1954
|
+
ActivityType[ActivityType["Unknown"] = 5] = "Unknown";
|
|
1955
|
+
})(ActivityType || (ActivityType = {}));
|
|
1956
|
+
/**
|
|
1957
|
+
* @internal
|
|
1958
|
+
*/
|
|
1959
|
+
class NotificationMiddleware {
|
|
1960
|
+
constructor(options) {
|
|
1961
|
+
this.conversationReferenceStore = options.conversationReferenceStore;
|
|
2079
1962
|
}
|
|
2080
1963
|
onTurn(context, next) {
|
|
2081
|
-
var _a, _b, _c;
|
|
2082
1964
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
const card = (_c = response.body) === null || _c === void 0 ? void 0 : _c.value;
|
|
2101
|
-
if (!card) {
|
|
2102
|
-
const errorMessage = "Adaptive card content cannot be found in the response body";
|
|
2103
|
-
yield this.sendInvokeResponse(context, InvokeResponseFactory.errorResponse(exports.InvokeResponseErrorCode.InternalServerError, errorMessage));
|
|
2104
|
-
throw new Error(errorMessage);
|
|
2105
|
-
}
|
|
2106
|
-
if (card.refresh && handler.adaptiveCardResponse !== exports.AdaptiveCardResponse.NewForAll) {
|
|
2107
|
-
// Card won't be refreshed with AdaptiveCardResponse.ReplaceForInteractor.
|
|
2108
|
-
// So set to AdaptiveCardResponse.ReplaceForAll here.
|
|
2109
|
-
handler.adaptiveCardResponse = exports.AdaptiveCardResponse.ReplaceForAll;
|
|
2110
|
-
}
|
|
2111
|
-
const activity = botbuilder.MessageFactory.attachment(botbuilder.CardFactory.adaptiveCard(card));
|
|
2112
|
-
if (handler.adaptiveCardResponse === exports.AdaptiveCardResponse.NewForAll) {
|
|
2113
|
-
yield this.sendInvokeResponse(context, InvokeResponseFactory.textMessage(this.defaultMessage));
|
|
2114
|
-
yield context.sendActivity(activity);
|
|
2115
|
-
}
|
|
2116
|
-
else if (handler.adaptiveCardResponse === exports.AdaptiveCardResponse.ReplaceForAll) {
|
|
2117
|
-
activity.id = context.activity.replyToId;
|
|
2118
|
-
yield context.updateActivity(activity);
|
|
2119
|
-
yield this.sendInvokeResponse(context, response);
|
|
2120
|
-
}
|
|
2121
|
-
else {
|
|
2122
|
-
yield this.sendInvokeResponse(context, response);
|
|
2123
|
-
}
|
|
2124
|
-
break;
|
|
2125
|
-
case InvokeResponseType.Message:
|
|
2126
|
-
case InvokeResponseType.Error:
|
|
2127
|
-
default:
|
|
2128
|
-
yield this.sendInvokeResponse(context, response);
|
|
2129
|
-
break;
|
|
2130
|
-
}
|
|
2131
|
-
break;
|
|
2132
|
-
}
|
|
1965
|
+
const type = this.classifyActivity(context.activity);
|
|
1966
|
+
switch (type) {
|
|
1967
|
+
case ActivityType.CurrentBotInstalled:
|
|
1968
|
+
case ActivityType.TeamRestored: {
|
|
1969
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
1970
|
+
yield this.conversationReferenceStore.set(reference);
|
|
1971
|
+
break;
|
|
1972
|
+
}
|
|
1973
|
+
case ActivityType.CurrentBotMessaged: {
|
|
1974
|
+
yield this.tryAddMessagedReference(context);
|
|
1975
|
+
break;
|
|
1976
|
+
}
|
|
1977
|
+
case ActivityType.CurrentBotUninstalled:
|
|
1978
|
+
case ActivityType.TeamDeleted: {
|
|
1979
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
1980
|
+
yield this.conversationReferenceStore.delete(reference);
|
|
1981
|
+
break;
|
|
2133
1982
|
}
|
|
2134
1983
|
}
|
|
2135
1984
|
yield next();
|
|
2136
1985
|
});
|
|
2137
1986
|
}
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
* A card action bot to respond to adaptive card universal actions.
|
|
2150
|
-
*/
|
|
2151
|
-
class CardActionBot {
|
|
2152
|
-
/**
|
|
2153
|
-
* Creates a new instance of the `CardActionBot`.
|
|
2154
|
-
*
|
|
2155
|
-
* @param adapter The bound `BotFrameworkAdapter`.
|
|
2156
|
-
* @param options - initialize options
|
|
2157
|
-
*/
|
|
2158
|
-
constructor(adapter, options) {
|
|
2159
|
-
this.middleware = new CardActionMiddleware(options === null || options === void 0 ? void 0 : options.actions);
|
|
2160
|
-
this.adapter = adapter.use(this.middleware);
|
|
2161
|
-
}
|
|
2162
|
-
/**
|
|
2163
|
-
* Registers a card action handler to the bot.
|
|
2164
|
-
* @param actionHandler A card action handler to be registered.
|
|
2165
|
-
*/
|
|
2166
|
-
registerHandler(actionHandler) {
|
|
2167
|
-
if (actionHandler) {
|
|
2168
|
-
this.middleware.actionHandlers.push(actionHandler);
|
|
1987
|
+
classifyActivity(activity) {
|
|
1988
|
+
var _a, _b;
|
|
1989
|
+
const activityType = activity.type;
|
|
1990
|
+
if (activityType === "installationUpdate") {
|
|
1991
|
+
const action = (_a = activity.action) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1992
|
+
if (action === "add") {
|
|
1993
|
+
return ActivityType.CurrentBotInstalled;
|
|
1994
|
+
}
|
|
1995
|
+
else {
|
|
1996
|
+
return ActivityType.CurrentBotUninstalled;
|
|
1997
|
+
}
|
|
2169
1998
|
}
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
1999
|
+
else if (activityType === "conversationUpdate") {
|
|
2000
|
+
const eventType = (_b = activity.channelData) === null || _b === void 0 ? void 0 : _b.eventType;
|
|
2001
|
+
if (eventType === "teamDeleted") {
|
|
2002
|
+
return ActivityType.TeamDeleted;
|
|
2003
|
+
}
|
|
2004
|
+
else if (eventType === "teamRestored") {
|
|
2005
|
+
return ActivityType.TeamRestored;
|
|
2006
|
+
}
|
|
2178
2007
|
}
|
|
2008
|
+
else if (activityType === "message") {
|
|
2009
|
+
return ActivityType.CurrentBotMessaged;
|
|
2010
|
+
}
|
|
2011
|
+
return ActivityType.Unknown;
|
|
2179
2012
|
}
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2013
|
+
tryAddMessagedReference(context) {
|
|
2014
|
+
var _a, _b, _c, _d;
|
|
2015
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2016
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
2017
|
+
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2018
|
+
if (conversationType === "personal" || conversationType === "groupChat") {
|
|
2019
|
+
if (!(yield this.conversationReferenceStore.check(reference))) {
|
|
2020
|
+
yield this.conversationReferenceStore.set(reference);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
else if (conversationType === "channel") {
|
|
2024
|
+
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;
|
|
2025
|
+
if (teamId !== undefined) {
|
|
2026
|
+
const teamReference = cloneConversation(reference);
|
|
2027
|
+
teamReference.conversation.id = teamId;
|
|
2028
|
+
if (!(yield this.conversationReferenceStore.check(teamReference))) {
|
|
2029
|
+
yield this.conversationReferenceStore.set(teamReference);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2186
2036
|
class CommandResponseMiddleware {
|
|
2187
2037
|
constructor(handlers) {
|
|
2188
2038
|
this.commandHandlers = [];
|
|
@@ -2214,7 +2064,6 @@ class CommandResponseMiddleware {
|
|
|
2214
2064
|
yield context.sendActivity(replyActivity);
|
|
2215
2065
|
}
|
|
2216
2066
|
}
|
|
2217
|
-
break;
|
|
2218
2067
|
}
|
|
2219
2068
|
}
|
|
2220
2069
|
}
|
|
@@ -2296,134 +2145,6 @@ class CommandBot {
|
|
|
2296
2145
|
}
|
|
2297
2146
|
}
|
|
2298
2147
|
|
|
2299
|
-
// Copyright (c) Microsoft Corporation.
|
|
2300
|
-
/**
|
|
2301
|
-
* @internal
|
|
2302
|
-
*/
|
|
2303
|
-
function cloneConversation(conversation) {
|
|
2304
|
-
return JSON.parse(JSON.stringify(conversation));
|
|
2305
|
-
}
|
|
2306
|
-
/**
|
|
2307
|
-
* @internal
|
|
2308
|
-
*/
|
|
2309
|
-
function getTargetType(conversationReference) {
|
|
2310
|
-
var _a;
|
|
2311
|
-
const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2312
|
-
if (conversationType === "personal") {
|
|
2313
|
-
return exports.NotificationTargetType.Person;
|
|
2314
|
-
}
|
|
2315
|
-
else if (conversationType === "groupChat") {
|
|
2316
|
-
return exports.NotificationTargetType.Group;
|
|
2317
|
-
}
|
|
2318
|
-
else if (conversationType === "channel") {
|
|
2319
|
-
return exports.NotificationTargetType.Channel;
|
|
2320
|
-
}
|
|
2321
|
-
else {
|
|
2322
|
-
return undefined;
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
/**
|
|
2326
|
-
* @internal
|
|
2327
|
-
*/
|
|
2328
|
-
function getTeamsBotInstallationId(context) {
|
|
2329
|
-
var _a, _b, _c, _d;
|
|
2330
|
-
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;
|
|
2331
|
-
}
|
|
2332
|
-
|
|
2333
|
-
// Copyright (c) Microsoft Corporation.
|
|
2334
|
-
/**
|
|
2335
|
-
* @internal
|
|
2336
|
-
*/
|
|
2337
|
-
var ActivityType;
|
|
2338
|
-
(function (ActivityType) {
|
|
2339
|
-
ActivityType[ActivityType["CurrentBotInstalled"] = 0] = "CurrentBotInstalled";
|
|
2340
|
-
ActivityType[ActivityType["CurrentBotMessaged"] = 1] = "CurrentBotMessaged";
|
|
2341
|
-
ActivityType[ActivityType["CurrentBotUninstalled"] = 2] = "CurrentBotUninstalled";
|
|
2342
|
-
ActivityType[ActivityType["TeamDeleted"] = 3] = "TeamDeleted";
|
|
2343
|
-
ActivityType[ActivityType["TeamRestored"] = 4] = "TeamRestored";
|
|
2344
|
-
ActivityType[ActivityType["Unknown"] = 5] = "Unknown";
|
|
2345
|
-
})(ActivityType || (ActivityType = {}));
|
|
2346
|
-
/**
|
|
2347
|
-
* @internal
|
|
2348
|
-
*/
|
|
2349
|
-
class NotificationMiddleware {
|
|
2350
|
-
constructor(options) {
|
|
2351
|
-
this.conversationReferenceStore = options.conversationReferenceStore;
|
|
2352
|
-
}
|
|
2353
|
-
onTurn(context, next) {
|
|
2354
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2355
|
-
const type = this.classifyActivity(context.activity);
|
|
2356
|
-
switch (type) {
|
|
2357
|
-
case ActivityType.CurrentBotInstalled:
|
|
2358
|
-
case ActivityType.TeamRestored: {
|
|
2359
|
-
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
2360
|
-
yield this.conversationReferenceStore.set(reference);
|
|
2361
|
-
break;
|
|
2362
|
-
}
|
|
2363
|
-
case ActivityType.CurrentBotMessaged: {
|
|
2364
|
-
yield this.tryAddMessagedReference(context);
|
|
2365
|
-
break;
|
|
2366
|
-
}
|
|
2367
|
-
case ActivityType.CurrentBotUninstalled:
|
|
2368
|
-
case ActivityType.TeamDeleted: {
|
|
2369
|
-
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
2370
|
-
yield this.conversationReferenceStore.delete(reference);
|
|
2371
|
-
break;
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
yield next();
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
classifyActivity(activity) {
|
|
2378
|
-
var _a, _b;
|
|
2379
|
-
const activityType = activity.type;
|
|
2380
|
-
if (activityType === "installationUpdate") {
|
|
2381
|
-
const action = (_a = activity.action) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
2382
|
-
if (action === "add") {
|
|
2383
|
-
return ActivityType.CurrentBotInstalled;
|
|
2384
|
-
}
|
|
2385
|
-
else {
|
|
2386
|
-
return ActivityType.CurrentBotUninstalled;
|
|
2387
|
-
}
|
|
2388
|
-
}
|
|
2389
|
-
else if (activityType === "conversationUpdate") {
|
|
2390
|
-
const eventType = (_b = activity.channelData) === null || _b === void 0 ? void 0 : _b.eventType;
|
|
2391
|
-
if (eventType === "teamDeleted") {
|
|
2392
|
-
return ActivityType.TeamDeleted;
|
|
2393
|
-
}
|
|
2394
|
-
else if (eventType === "teamRestored") {
|
|
2395
|
-
return ActivityType.TeamRestored;
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
else if (activityType === "message") {
|
|
2399
|
-
return ActivityType.CurrentBotMessaged;
|
|
2400
|
-
}
|
|
2401
|
-
return ActivityType.Unknown;
|
|
2402
|
-
}
|
|
2403
|
-
tryAddMessagedReference(context) {
|
|
2404
|
-
var _a, _b, _c, _d;
|
|
2405
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2406
|
-
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
2407
|
-
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2408
|
-
if (conversationType === "personal" || conversationType === "groupChat") {
|
|
2409
|
-
if (!(yield this.conversationReferenceStore.check(reference))) {
|
|
2410
|
-
yield this.conversationReferenceStore.set(reference);
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
else if (conversationType === "channel") {
|
|
2414
|
-
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;
|
|
2415
|
-
if (teamId !== undefined) {
|
|
2416
|
-
const teamReference = cloneConversation(reference);
|
|
2417
|
-
teamReference.conversation.id = teamId;
|
|
2418
|
-
if (!(yield this.conversationReferenceStore.check(teamReference))) {
|
|
2419
|
-
yield this.conversationReferenceStore.set(teamReference);
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
});
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
2148
|
// Copyright (c) Microsoft Corporation.
|
|
2428
2149
|
/**
|
|
2429
2150
|
* @internal
|
|
@@ -2961,7 +2682,7 @@ class ConversationBot {
|
|
|
2961
2682
|
* @param options - initialize options
|
|
2962
2683
|
*/
|
|
2963
2684
|
constructor(options) {
|
|
2964
|
-
var _a, _b
|
|
2685
|
+
var _a, _b;
|
|
2965
2686
|
if (options.adapter) {
|
|
2966
2687
|
this.adapter = options.adapter;
|
|
2967
2688
|
}
|
|
@@ -2974,9 +2695,6 @@ class ConversationBot {
|
|
|
2974
2695
|
if ((_b = options.notification) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
2975
2696
|
this.notification = new NotificationBot(this.adapter, options.notification);
|
|
2976
2697
|
}
|
|
2977
|
-
if ((_c = options.cardAction) === null || _c === void 0 ? void 0 : _c.enabled) {
|
|
2978
|
-
this.cardAction = new CardActionBot(this.adapter, options.cardAction);
|
|
2979
|
-
}
|
|
2980
2698
|
}
|
|
2981
2699
|
createDefaultAdapter(adapterConfig) {
|
|
2982
2700
|
const adapter = adapterConfig === undefined
|
|
@@ -3169,13 +2887,11 @@ exports.ApiKeyProvider = ApiKeyProvider;
|
|
|
3169
2887
|
exports.AppCredential = AppCredential;
|
|
3170
2888
|
exports.BasicAuthProvider = BasicAuthProvider;
|
|
3171
2889
|
exports.BearerTokenAuthProvider = BearerTokenAuthProvider;
|
|
3172
|
-
exports.CardActionBot = CardActionBot;
|
|
3173
2890
|
exports.CertificateAuthProvider = CertificateAuthProvider;
|
|
3174
2891
|
exports.Channel = Channel;
|
|
3175
2892
|
exports.CommandBot = CommandBot;
|
|
3176
2893
|
exports.ConversationBot = ConversationBot;
|
|
3177
2894
|
exports.ErrorWithCode = ErrorWithCode;
|
|
3178
|
-
exports.InvokeResponseFactory = InvokeResponseFactory;
|
|
3179
2895
|
exports.Member = Member;
|
|
3180
2896
|
exports.MessageBuilder = MessageBuilder;
|
|
3181
2897
|
exports.MsGraphAuthProvider = MsGraphAuthProvider;
|