@microsoft/teamsfx 1.1.2-alpha.c46d33f34.0 → 1.1.2-alpha.d61ffd7b2.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.
@@ -694,10 +694,13 @@ class TeamsUserCredential {
694
694
  }
695
695
  /**
696
696
  * Popup login page to get user's access token with specific scopes.
697
+ *
698
+ * @param {string[]} resources - The optional list of resources for full trust Teams apps.
699
+ *
697
700
  * @remarks
698
701
  * Can only be used within Teams.
699
702
  */
700
- async login(scopes) {
703
+ async login(scopes, resources) {
701
704
  throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), ErrorCode.RuntimeNotSupported);
702
705
  }
703
706
  /**
@@ -710,10 +713,13 @@ class TeamsUserCredential {
710
713
  }
711
714
  /**
712
715
  * Get basic user info from SSO token
716
+ *
717
+ * @param {string[]} resources - The optional list of resources for full trust Teams apps.
718
+ *
713
719
  * @remarks
714
720
  * Can only be used within Teams.
715
721
  */
716
- getUserInfo() {
722
+ getUserInfo(resources) {
717
723
  throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), ErrorCode.RuntimeNotSupported);
718
724
  }
719
725
  }
@@ -1661,8 +1667,9 @@ class TeamsFx {
1661
1667
  this.configuration = new Map();
1662
1668
  this.loadFromEnv();
1663
1669
  if (customConfig) {
1664
- for (const key of Object.keys(customConfig)) {
1665
- const value = customConfig[key];
1670
+ const myConfig = Object.assign({}, customConfig);
1671
+ for (const key of Object.keys(myConfig)) {
1672
+ const value = myConfig[key];
1666
1673
  if (value) {
1667
1674
  this.configuration.set(key, value);
1668
1675
  }
@@ -1704,9 +1711,10 @@ class TeamsFx {
1704
1711
  }
1705
1712
  /**
1706
1713
  * Get user information.
1714
+ * @param {string[]} resources - The optional list of resources for full trust Teams apps.
1707
1715
  * @returns UserInfo object.
1708
1716
  */
1709
- async getUserInfo() {
1717
+ async getUserInfo(resources) {
1710
1718
  if (this.identityType !== IdentityType.User) {
1711
1719
  const errorMsg = formatString(ErrorMessage.IdentityTypeNotSupported, this.identityType.toString(), "TeamsFx");
1712
1720
  internalLogger.error(errorMsg);
@@ -1728,13 +1736,14 @@ class TeamsFx {
1728
1736
  * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1729
1737
  * ```
1730
1738
  * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1739
+ * @param {string[]} resources - The optional list of resources for full trust Teams apps.
1731
1740
  *
1732
1741
  * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1733
1742
  * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1734
1743
  * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1735
1744
  * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1736
1745
  */
1737
- async login(scopes) {
1746
+ async login(scopes, resources) {
1738
1747
  throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "login"), ErrorCode.RuntimeNotSupported);
1739
1748
  }
1740
1749
  /**
@@ -1838,131 +1847,280 @@ var NotificationTargetType;
1838
1847
  * The notification will be sent to a personal chat.
1839
1848
  */
1840
1849
  NotificationTargetType["Person"] = "Person";
1841
- })(NotificationTargetType || (NotificationTargetType = {}));
1850
+ })(NotificationTargetType || (NotificationTargetType = {}));
1851
+ /**
1852
+ * Options used to control how the response card will be sent to users.
1853
+ */
1854
+ var AdaptiveCardResponse;
1855
+ (function (AdaptiveCardResponse) {
1856
+ /**
1857
+ * The response card will be replaced the current one for the interactor who trigger the action.
1858
+ */
1859
+ AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForInteractor"] = 0] = "ReplaceForInteractor";
1860
+ /**
1861
+ * The response card will be replaced the current one for all users in the chat.
1862
+ */
1863
+ AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForAll"] = 1] = "ReplaceForAll";
1864
+ /**
1865
+ * The response card will be sent as a new message for all users in the chat.
1866
+ */
1867
+ AdaptiveCardResponse[AdaptiveCardResponse["NewForAll"] = 2] = "NewForAll";
1868
+ })(AdaptiveCardResponse || (AdaptiveCardResponse = {}));
1869
+ /**
1870
+ * Status code for an `application/vnd.microsoft.error` invoke response.
1871
+ */
1872
+ var InvokeResponseErrorCode;
1873
+ (function (InvokeResponseErrorCode) {
1874
+ /**
1875
+ * Invalid request.
1876
+ */
1877
+ InvokeResponseErrorCode[InvokeResponseErrorCode["BadRequest"] = 400] = "BadRequest";
1878
+ /**
1879
+ * Internal server error.
1880
+ */
1881
+ InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
1882
+ })(InvokeResponseErrorCode || (InvokeResponseErrorCode = {}));
1842
1883
 
1843
- // Copyright (c) Microsoft Corporation.
1844
1884
  /**
1885
+ * Available response type for an adaptive card invoke response.
1845
1886
  * @internal
1846
1887
  */
1847
- function cloneConversation(conversation) {
1848
- return JSON.parse(JSON.stringify(conversation));
1849
- }
1888
+ var InvokeResponseType;
1889
+ (function (InvokeResponseType) {
1890
+ InvokeResponseType["AdaptiveCard"] = "application/vnd.microsoft.card.adaptive";
1891
+ InvokeResponseType["Message"] = "application/vnd.microsoft.activity.message";
1892
+ InvokeResponseType["Error"] = "application/vnd.microsoft.error";
1893
+ })(InvokeResponseType || (InvokeResponseType = {}));
1850
1894
  /**
1851
- * @internal
1895
+ * Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
1896
+ *
1897
+ * @remarks
1898
+ * All of these functions return an {@link InvokeResponse} object, which can be
1899
+ * passed as input to generate a new `invokeResponse` activity.
1900
+ *
1901
+ * This example sends an invoke response that contains an adaptive card.
1902
+ *
1903
+ * ```typescript
1904
+ *
1905
+ * const myCard: IAdaptiveCard = {
1906
+ * type: "AdaptiveCard",
1907
+ * body: [
1908
+ * {
1909
+ * "type": "TextBlock",
1910
+ * "text": "This is a sample card"
1911
+ * }],
1912
+ * $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
1913
+ * version: "1.4"
1914
+ * };
1915
+ *
1916
+ * const invokeResponse = InvokeResponseFactory.adaptiveCard(myCard);
1917
+ * await context.sendActivity({
1918
+ * type: ActivityTypes.InvokeResponse,
1919
+ * value: invokeResponse,
1920
+ * });
1921
+ * ```
1852
1922
  */
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;
1923
+ class InvokeResponseFactory {
1924
+ /**
1925
+ * Create an invoke response from a text message.
1926
+ * The type of the invoke response is `application/vnd.microsoft.activity.message`
1927
+ * indicates the request was successfully processed.
1928
+ *
1929
+ * @param message A text message included in a invoke response.
1930
+ *
1931
+ * @returns {InvokeResponse} An InvokeResponse object.
1932
+ */
1933
+ static textMessage(message) {
1934
+ if (!message) {
1935
+ throw new Error("The text message cannot be null or empty");
1936
+ }
1937
+ return {
1938
+ status: StatusCodes.OK,
1939
+ body: {
1940
+ statusCode: StatusCodes.OK,
1941
+ type: InvokeResponseType.Message,
1942
+ value: message,
1943
+ },
1944
+ };
1858
1945
  }
1859
- else if (conversationType === "groupChat") {
1860
- return NotificationTargetType.Group;
1946
+ /**
1947
+ * Create an invoke response from an adaptive card.
1948
+ *
1949
+ * The type of the invoke response is `application/vnd.microsoft.card.adaptive` indicates
1950
+ * the request was successfully processed, and the response includes an adaptive card
1951
+ * that the client should display in place of the current one.
1952
+ *
1953
+ * @param card The adaptive card JSON payload.
1954
+ *
1955
+ * @returns {InvokeResponse} An InvokeResponse object.
1956
+ */
1957
+ static adaptiveCard(card) {
1958
+ if (!card) {
1959
+ throw new Error("The adaptive card content cannot be null or undefined");
1960
+ }
1961
+ return {
1962
+ status: StatusCodes.OK,
1963
+ body: {
1964
+ statusCode: StatusCodes.OK,
1965
+ type: InvokeResponseType.AdaptiveCard,
1966
+ value: card,
1967
+ },
1968
+ };
1861
1969
  }
1862
- else if (conversationType === "channel") {
1863
- return NotificationTargetType.Channel;
1970
+ /**
1971
+ * Create an invoke response with error code and message.
1972
+ *
1973
+ * The type of the invoke response is `application/vnd.microsoft.error` indicates
1974
+ * the request was failed to processed.
1975
+ *
1976
+ * @param errorCode The status code indicates error, available values:
1977
+ * - 400 (BadRequest): indicate the incoming request was invalid.
1978
+ * - 500 (InternalServerError): indicate an unexpected error occurred.
1979
+ * @param errorMessage The error message.
1980
+ *
1981
+ * @returns {InvokeResponse} An InvokeResponse object.
1982
+ */
1983
+ static errorResponse(errorCode, errorMessage) {
1984
+ return {
1985
+ status: StatusCodes.OK,
1986
+ body: {
1987
+ statusCode: errorCode,
1988
+ type: InvokeResponseType.Error,
1989
+ value: {
1990
+ code: errorCode.toString(),
1991
+ message: errorMessage,
1992
+ },
1993
+ },
1994
+ };
1864
1995
  }
1865
- else {
1866
- return undefined;
1996
+ /**
1997
+ * Create an invoke response with status code and response value.
1998
+ * @param statusCode The status code.
1999
+ * @param body The value of the response body.
2000
+ *
2001
+ * @returns {InvokeResponse} An InvokeResponse object.
2002
+ */
2003
+ static createInvokeResponse(statusCode, body) {
2004
+ return {
2005
+ status: statusCode,
2006
+ body: body,
2007
+ };
1867
2008
  }
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;
1875
2009
  }
1876
2010
 
1877
- // Copyright (c) Microsoft Corporation.
1878
- /**
1879
- * @internal
1880
- */
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
2011
  /**
1891
2012
  * @internal
1892
2013
  */
1893
- class NotificationMiddleware {
1894
- constructor(options) {
1895
- this.conversationReferenceStore = options.conversationReferenceStore;
2014
+ class CardActionMiddleware {
2015
+ constructor(handlers) {
2016
+ this.actionHandlers = [];
2017
+ this.defaultMessage = "Your response was sent to the app";
2018
+ if (handlers && handlers.length > 0) {
2019
+ this.actionHandlers.push(...handlers);
2020
+ }
1896
2021
  }
1897
2022
  async onTurn(context, next) {
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;
2023
+ var _a, _b, _c;
2024
+ if (context.activity.name === "adaptiveCard/action") {
2025
+ const action = context.activity.value.action;
2026
+ const actionVerb = action.verb;
2027
+ for (const handler of this.actionHandlers) {
2028
+ if (((_a = handler.triggerVerb) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (actionVerb === null || actionVerb === void 0 ? void 0 : actionVerb.toLowerCase())) {
2029
+ let response;
2030
+ try {
2031
+ response = await handler.handleActionInvoked(context, action.data);
2032
+ }
2033
+ catch (error) {
2034
+ const errorResponse = InvokeResponseFactory.errorResponse(InvokeResponseErrorCode.InternalServerError, error.message);
2035
+ await this.sendInvokeResponse(context, errorResponse);
2036
+ throw error;
2037
+ }
2038
+ const responseType = (_b = response.body) === null || _b === void 0 ? void 0 : _b.type;
2039
+ switch (responseType) {
2040
+ case InvokeResponseType.AdaptiveCard:
2041
+ const card = (_c = response.body) === null || _c === void 0 ? void 0 : _c.value;
2042
+ if (!card) {
2043
+ const errorMessage = "Adaptive card content cannot be found in the response body";
2044
+ await this.sendInvokeResponse(context, InvokeResponseFactory.errorResponse(InvokeResponseErrorCode.InternalServerError, errorMessage));
2045
+ throw new Error(errorMessage);
2046
+ }
2047
+ if (card.refresh && handler.adaptiveCardResponse !== AdaptiveCardResponse.NewForAll) {
2048
+ // Card won't be refreshed with AdaptiveCardResponse.ReplaceForInteractor.
2049
+ // So set to AdaptiveCardResponse.ReplaceForAll here.
2050
+ handler.adaptiveCardResponse = AdaptiveCardResponse.ReplaceForAll;
2051
+ }
2052
+ const activity = MessageFactory.attachment(CardFactory.adaptiveCard(card));
2053
+ if (handler.adaptiveCardResponse === AdaptiveCardResponse.NewForAll) {
2054
+ await this.sendInvokeResponse(context, InvokeResponseFactory.textMessage(this.defaultMessage));
2055
+ await context.sendActivity(activity);
2056
+ }
2057
+ else if (handler.adaptiveCardResponse === AdaptiveCardResponse.ReplaceForAll) {
2058
+ activity.id = context.activity.replyToId;
2059
+ await context.updateActivity(activity);
2060
+ await this.sendInvokeResponse(context, response);
2061
+ }
2062
+ else {
2063
+ await this.sendInvokeResponse(context, response);
2064
+ }
2065
+ break;
2066
+ case InvokeResponseType.Message:
2067
+ case InvokeResponseType.Error:
2068
+ default:
2069
+ await this.sendInvokeResponse(context, response);
2070
+ break;
2071
+ }
2072
+ break;
2073
+ }
1915
2074
  }
1916
2075
  }
1917
2076
  await next();
1918
2077
  }
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;
1942
- }
1943
- return ActivityType.Unknown;
2078
+ async sendInvokeResponse(context, response) {
2079
+ await context.sendActivity({
2080
+ type: ActivityTypes.InvokeResponse,
2081
+ value: response,
2082
+ });
1944
2083
  }
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
- }
2084
+ }
2085
+
2086
+ /**
2087
+ * A card action bot to respond to adaptive card universal actions.
2088
+ */
2089
+ class CardActionBot {
2090
+ /**
2091
+ * Creates a new instance of the `CardActionBot`.
2092
+ *
2093
+ * @param adapter The bound `BotFrameworkAdapter`.
2094
+ * @param options - initialize options
2095
+ */
2096
+ constructor(adapter, options) {
2097
+ this.middleware = new CardActionMiddleware(options === null || options === void 0 ? void 0 : options.actions);
2098
+ this.adapter = adapter.use(this.middleware);
2099
+ }
2100
+ /**
2101
+ * Registers a card action handler to the bot.
2102
+ * @param actionHandler A card action handler to be registered.
2103
+ */
2104
+ registerHandler(actionHandler) {
2105
+ if (actionHandler) {
2106
+ this.middleware.actionHandlers.push(actionHandler);
1953
2107
  }
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
+ }
2109
+ /**
2110
+ * Registers card action handlers to the bot.
2111
+ * @param actionHandlers A set of card action handlers to be registered.
2112
+ */
2113
+ registerHandlers(actionHandlers) {
2114
+ if (actionHandlers) {
2115
+ this.middleware.actionHandlers.push(...actionHandlers);
1963
2116
  }
1964
2117
  }
1965
- }
2118
+ }
2119
+
2120
+ // Copyright (c) Microsoft Corporation.
2121
+ /**
2122
+ * @internal
2123
+ */
1966
2124
  class CommandResponseMiddleware {
1967
2125
  constructor(handlers) {
1968
2126
  this.commandHandlers = [];
@@ -1993,6 +2151,7 @@ class CommandResponseMiddleware {
1993
2151
  await context.sendActivity(replyActivity);
1994
2152
  }
1995
2153
  }
2154
+ break;
1996
2155
  }
1997
2156
  }
1998
2157
  }
@@ -2073,6 +2232,130 @@ class CommandBot {
2073
2232
  }
2074
2233
  }
2075
2234
 
2235
+ // Copyright (c) Microsoft Corporation.
2236
+ /**
2237
+ * @internal
2238
+ */
2239
+ function cloneConversation(conversation) {
2240
+ return JSON.parse(JSON.stringify(conversation));
2241
+ }
2242
+ /**
2243
+ * @internal
2244
+ */
2245
+ function getTargetType(conversationReference) {
2246
+ var _a;
2247
+ const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
2248
+ if (conversationType === "personal") {
2249
+ return NotificationTargetType.Person;
2250
+ }
2251
+ else if (conversationType === "groupChat") {
2252
+ return NotificationTargetType.Group;
2253
+ }
2254
+ else if (conversationType === "channel") {
2255
+ return NotificationTargetType.Channel;
2256
+ }
2257
+ else {
2258
+ return undefined;
2259
+ }
2260
+ }
2261
+ /**
2262
+ * @internal
2263
+ */
2264
+ function getTeamsBotInstallationId(context) {
2265
+ var _a, _b, _c, _d;
2266
+ 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;
2267
+ }
2268
+
2269
+ // Copyright (c) Microsoft Corporation.
2270
+ /**
2271
+ * @internal
2272
+ */
2273
+ var ActivityType;
2274
+ (function (ActivityType) {
2275
+ ActivityType[ActivityType["CurrentBotInstalled"] = 0] = "CurrentBotInstalled";
2276
+ ActivityType[ActivityType["CurrentBotMessaged"] = 1] = "CurrentBotMessaged";
2277
+ ActivityType[ActivityType["CurrentBotUninstalled"] = 2] = "CurrentBotUninstalled";
2278
+ ActivityType[ActivityType["TeamDeleted"] = 3] = "TeamDeleted";
2279
+ ActivityType[ActivityType["TeamRestored"] = 4] = "TeamRestored";
2280
+ ActivityType[ActivityType["Unknown"] = 5] = "Unknown";
2281
+ })(ActivityType || (ActivityType = {}));
2282
+ /**
2283
+ * @internal
2284
+ */
2285
+ class NotificationMiddleware {
2286
+ constructor(options) {
2287
+ this.conversationReferenceStore = options.conversationReferenceStore;
2288
+ }
2289
+ async onTurn(context, next) {
2290
+ const type = this.classifyActivity(context.activity);
2291
+ switch (type) {
2292
+ case ActivityType.CurrentBotInstalled:
2293
+ case ActivityType.TeamRestored: {
2294
+ const reference = TurnContext.getConversationReference(context.activity);
2295
+ await this.conversationReferenceStore.set(reference);
2296
+ break;
2297
+ }
2298
+ case ActivityType.CurrentBotMessaged: {
2299
+ await this.tryAddMessagedReference(context);
2300
+ break;
2301
+ }
2302
+ case ActivityType.CurrentBotUninstalled:
2303
+ case ActivityType.TeamDeleted: {
2304
+ const reference = TurnContext.getConversationReference(context.activity);
2305
+ await this.conversationReferenceStore.delete(reference);
2306
+ break;
2307
+ }
2308
+ }
2309
+ await next();
2310
+ }
2311
+ classifyActivity(activity) {
2312
+ var _a, _b;
2313
+ const activityType = activity.type;
2314
+ if (activityType === "installationUpdate") {
2315
+ const action = (_a = activity.action) === null || _a === void 0 ? void 0 : _a.toLowerCase();
2316
+ if (action === "add") {
2317
+ return ActivityType.CurrentBotInstalled;
2318
+ }
2319
+ else {
2320
+ return ActivityType.CurrentBotUninstalled;
2321
+ }
2322
+ }
2323
+ else if (activityType === "conversationUpdate") {
2324
+ const eventType = (_b = activity.channelData) === null || _b === void 0 ? void 0 : _b.eventType;
2325
+ if (eventType === "teamDeleted") {
2326
+ return ActivityType.TeamDeleted;
2327
+ }
2328
+ else if (eventType === "teamRestored") {
2329
+ return ActivityType.TeamRestored;
2330
+ }
2331
+ }
2332
+ else if (activityType === "message") {
2333
+ return ActivityType.CurrentBotMessaged;
2334
+ }
2335
+ return ActivityType.Unknown;
2336
+ }
2337
+ async tryAddMessagedReference(context) {
2338
+ var _a, _b, _c, _d;
2339
+ const reference = TurnContext.getConversationReference(context.activity);
2340
+ const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
2341
+ if (conversationType === "personal" || conversationType === "groupChat") {
2342
+ if (!(await this.conversationReferenceStore.check(reference))) {
2343
+ await this.conversationReferenceStore.set(reference);
2344
+ }
2345
+ }
2346
+ else if (conversationType === "channel") {
2347
+ 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;
2348
+ if (teamId !== undefined) {
2349
+ const teamReference = cloneConversation(reference);
2350
+ teamReference.conversation.id = teamId;
2351
+ if (!(await this.conversationReferenceStore.check(teamReference))) {
2352
+ await this.conversationReferenceStore.set(teamReference);
2353
+ }
2354
+ }
2355
+ }
2356
+ }
2357
+ }
2358
+
2076
2359
  // Copyright (c) Microsoft Corporation.
2077
2360
  /**
2078
2361
  * @internal
@@ -2576,7 +2859,7 @@ class ConversationBot {
2576
2859
  * @param options - initialize options
2577
2860
  */
2578
2861
  constructor(options) {
2579
- var _a, _b;
2862
+ var _a, _b, _c;
2580
2863
  if (options.adapter) {
2581
2864
  this.adapter = options.adapter;
2582
2865
  }
@@ -2589,6 +2872,9 @@ class ConversationBot {
2589
2872
  if ((_b = options.notification) === null || _b === void 0 ? void 0 : _b.enabled) {
2590
2873
  this.notification = new NotificationBot(this.adapter, options.notification);
2591
2874
  }
2875
+ if ((_c = options.cardAction) === null || _c === void 0 ? void 0 : _c.enabled) {
2876
+ this.cardAction = new CardActionBot(this.adapter, options.cardAction);
2877
+ }
2592
2878
  }
2593
2879
  createDefaultAdapter(adapterConfig) {
2594
2880
  const adapter = adapterConfig === undefined
@@ -2775,5 +3061,5 @@ class MessageBuilder {
2775
3061
  }
2776
3062
  }
2777
3063
 
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 };
3064
+ export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, CardActionBot, CertificateAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, InvokeResponseErrorCode, InvokeResponseFactory, LogLevel, Member, MessageBuilder, MsGraphAuthProvider, NotificationBot, NotificationTargetType, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
2779
3065
  //# sourceMappingURL=index.esm2017.mjs.map