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