@microsoft/teamsfx 1.1.1-rc.0 → 1.1.2-alpha.3113a0b87.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/teamsfx",
3
- "version": "1.1.1-rc.0",
3
+ "version": "1.1.2-alpha.3113a0b87.0",
4
4
  "description": "Microsoft Teams Framework for Node.js and browser.",
5
5
  "main": "dist/index.node.cjs.js",
6
6
  "browser": "dist/index.esm2017.js",
@@ -49,8 +49,9 @@
49
49
  "@azure/identity": "^2.0.1",
50
50
  "@azure/msal-browser": "^2.21.0",
51
51
  "@azure/msal-node": "~1.1.0",
52
- "@microsoft/adaptivecards-tools": "^1.0.1",
52
+ "@microsoft/adaptivecards-tools": "1.0.2-alpha.3113a0b87.0",
53
53
  "@microsoft/microsoft-graph-client": "^3.0.1",
54
+ "adaptivecards": "^2.10.0",
54
55
  "axios": "^0.27.2",
55
56
  "botbuilder": ">=4.15.0 <5.0.0",
56
57
  "botbuilder-dialogs": ">=4.15.0 <5.0.0",
@@ -128,7 +129,7 @@
128
129
  "webpack": "^5.62.1",
129
130
  "yargs": "^17.2.1"
130
131
  },
131
- "gitHead": "9c0b3bc030a4cbc070b45d4dae186c097bb9b98e",
132
+ "gitHead": "d68af0c479ef36a05d38de336a5c4927025e4b1b",
132
133
  "publishConfig": {
133
134
  "access": "public"
134
135
  },
@@ -19,9 +19,13 @@ import { DialogContext } from 'botbuilder-dialogs';
19
19
  import { DialogTurnResult } from 'botbuilder-dialogs';
20
20
  import { GetTokenOptions } from '@azure/identity';
21
21
  import { HeroCard } from 'botbuilder';
22
+ import { IAdaptiveCard } from 'adaptivecards';
23
+ import { InvokeResponse } from 'botbuilder-core';
24
+ import { InvokeResponse as InvokeResponse_2 } from 'botbuilder';
22
25
  import { O365ConnectorCard } from 'botbuilder';
23
26
  import { ReceiptCard } from 'botbuilder';
24
27
  import { SecureContextOptions } from 'tls';
28
+ import { StatusCodes } from 'botbuilder';
25
29
  import { TeamsChannelAccount } from 'botbuilder';
26
30
  import { ThumbnailCard } from 'botbuilder';
27
31
  import { TokenCredential } from '@azure/identity';
@@ -31,6 +35,24 @@ import { TurnContext as TurnContext_2 } from 'botbuilder';
31
35
  import { WebRequest } from 'botbuilder';
32
36
  import { WebResponse } from 'botbuilder';
33
37
 
38
+ /**
39
+ * Options used to control how the response card will be sent to users.
40
+ */
41
+ export declare enum AdaptiveCardResponse {
42
+ /**
43
+ * The response card will be replaced the current one for the interactor who trigger the action.
44
+ */
45
+ ReplaceForInteractor = 0,
46
+ /**
47
+ * The response card will be replaced the current one for all users in the chat.
48
+ */
49
+ ReplaceForAll = 1,
50
+ /**
51
+ * The response card will be sent as a new message for all users in the chat.
52
+ */
53
+ NewForAll = 2
54
+ }
55
+
34
56
  /**
35
57
  * Define available location for API Key location
36
58
  */
@@ -249,6 +271,41 @@ export declare class BearerTokenAuthProvider implements AuthProvider {
249
271
  AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
250
272
  }
251
273
 
274
+ /**
275
+ * A card action bot to respond to adaptive card universal actions.
276
+ */
277
+ export declare class CardActionBot {
278
+ private readonly adapter;
279
+ private middleware;
280
+ /**
281
+ * Creates a new instance of the `CardActionBot`.
282
+ *
283
+ * @param adapter The bound `BotFrameworkAdapter`.
284
+ * @param options - initialize options
285
+ */
286
+ constructor(adapter: BotFrameworkAdapter, options?: CardActionOptions);
287
+ /**
288
+ * Registers a card action handler to the bot.
289
+ * @param actionHandler A card action handler to be registered.
290
+ */
291
+ registerHandler(actionHandler: TeamsFxAdaptiveCardActionHandler): void;
292
+ /**
293
+ * Registers card action handlers to the bot.
294
+ * @param actionHandlers A set of card action handlers to be registered.
295
+ */
296
+ registerHandlers(actionHandlers: TeamsFxAdaptiveCardActionHandler[]): void;
297
+ }
298
+
299
+ /**
300
+ * Options to initialize {@link CardActionBot}.
301
+ */
302
+ export declare interface CardActionOptions {
303
+ /**
304
+ * The action handlers to registered with the action bot. Each command should implement the interface {@link TeamsFxAdaptiveCardActionHandler} so that it can be correctly handled by this bot.
305
+ */
306
+ actions?: TeamsFxAdaptiveCardActionHandler[];
307
+ }
308
+
252
309
  /**
253
310
  * Provider that handles Certificate authentication
254
311
  */
@@ -441,6 +498,10 @@ export declare class ConversationBot {
441
498
  * The entrypoint of notification.
442
499
  */
443
500
  readonly notification?: NotificationBot;
501
+ /**
502
+ * The action handler used for adaptive card universal actions.
503
+ */
504
+ readonly cardAction?: CardActionBot;
444
505
  /**
445
506
  * Creates new instance of the `ConversationBot`.
446
507
  *
@@ -515,6 +576,15 @@ export declare interface ConversationOptions {
515
576
  */
516
577
  enabled?: boolean;
517
578
  };
579
+ /**
580
+ * The adaptive card action handler part.
581
+ */
582
+ cardAction?: CardActionOptions & {
583
+ /**
584
+ * Whether to enable adaptive card actions or not.
585
+ */
586
+ enabled?: boolean;
587
+ };
518
588
  }
519
589
 
520
590
  /**
@@ -730,6 +800,96 @@ export declare enum IdentityType {
730
800
  App = "Application"
731
801
  }
732
802
 
803
+ /**
804
+ * Status code for an `application/vnd.microsoft.error` invoke response.
805
+ */
806
+ export declare enum InvokeResponseErrorCode {
807
+ /**
808
+ * Invalid request.
809
+ */
810
+ BadRequest = 400,
811
+ /**
812
+ * Internal server error.
813
+ */
814
+ InternalServerError = 500
815
+ }
816
+
817
+ /**
818
+ * Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
819
+ *
820
+ * @remarks
821
+ * All of these functions return an {@link InvokeResponse} object, which can be
822
+ * passed as input to generate a new `invokeResponse` activity.
823
+ *
824
+ * This example sends an invoke response that contains an adaptive card.
825
+ *
826
+ * ```typescript
827
+ *
828
+ * const myCard: IAdaptiveCard = {
829
+ * type: "AdaptiveCard",
830
+ * body: [
831
+ * {
832
+ * "type": "TextBlock",
833
+ * "text": "This is a sample card"
834
+ * }],
835
+ * $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
836
+ * version: "1.4"
837
+ * };
838
+ *
839
+ * const invokeResponse = InvokeResponseFactory.adaptiveCard(myCard);
840
+ * await context.sendActivity({
841
+ * type: ActivityTypes.InvokeResponse,
842
+ * value: invokeResponse,
843
+ * });
844
+ * ```
845
+ */
846
+ export declare class InvokeResponseFactory {
847
+ /**
848
+ * Create an invoke response from a text message.
849
+ * The type of the invoke response is `application/vnd.microsoft.activity.message`
850
+ * indicates the request was successfully processed.
851
+ *
852
+ * @param message A text message included in a invoke response.
853
+ *
854
+ * @returns {InvokeResponse} An InvokeResponse object.
855
+ */
856
+ static textMessage(message: string): InvokeResponse_2;
857
+ /**
858
+ * Create an invoke response from an adaptive card.
859
+ *
860
+ * The type of the invoke response is `application/vnd.microsoft.card.adaptive` indicates
861
+ * the request was successfully processed, and the response includes an adaptive card
862
+ * that the client should display in place of the current one.
863
+ *
864
+ * @param card The adaptive card JSON payload.
865
+ *
866
+ * @returns {InvokeResponse} An InvokeResponse object.
867
+ */
868
+ static adaptiveCard(card: IAdaptiveCard): InvokeResponse_2;
869
+ /**
870
+ * Create an invoke response with error code and message.
871
+ *
872
+ * The type of the invoke response is `application/vnd.microsoft.error` indicates
873
+ * the request was failed to processed.
874
+ *
875
+ * @param errorCode The status code indicates error, available values:
876
+ * - 400 (BadRequest): indicate the incoming request was invalid.
877
+ * - 500 (InternalServerError): indicate an unexpected error occurred.
878
+ * @param errorMessage The error message.
879
+ *
880
+ * @returns {InvokeResponse} An InvokeResponse object.
881
+ */
882
+ static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string): InvokeResponse_2;
883
+ /**
884
+ * Create an invoke response with status code and response value.
885
+ * @param statusCode The status code.
886
+ * @param body The value of the response body.
887
+ *
888
+ * @returns {InvokeResponse} An InvokeResponse object.
889
+ */
890
+ static createInvokeResponse(statusCode: StatusCodes, body?: unknown): InvokeResponse_2;
891
+ }
892
+
733
893
  /**
734
894
  * Log function for customized logging.
735
895
  */
@@ -1583,6 +1743,47 @@ export declare class TeamsFx implements TeamsFxConfiguration {
1583
1743
  private loadFromEnv;
1584
1744
  }
1585
1745
 
1746
+ /**
1747
+ * Interface for adaptive card action handler that can process card action invoke and return a response.
1748
+ */
1749
+ export declare interface TeamsFxAdaptiveCardActionHandler {
1750
+ /**
1751
+ * The verb defined in adaptive card action that can trigger this handler.
1752
+ * The verb string here is case-insensitive.
1753
+ */
1754
+ triggerVerb: string;
1755
+ /**
1756
+ * Specify the behavior for how the card response will be sent in Teams conversation.
1757
+ * The default value is `AdaptiveCardResponse.ReplaceForInteractor`, which means the card
1758
+ * response will replace the current one only for the interactor.
1759
+ */
1760
+ adaptiveCardResponse?: AdaptiveCardResponse;
1761
+ /**
1762
+ * The handler function that will be invoked when the action is fired.
1763
+ * @param context The turn context.
1764
+ * @param actionData The contextual data that associated with the action.
1765
+ *
1766
+ * @returns A `Promise` representing a invoke response for the adaptive card invoke action.
1767
+ * You can use the `InvokeResponseFactory` utility class to create an invoke response from
1768
+ * - A text message:
1769
+ * ```typescript
1770
+ * return InvokeResponseFactory.textMessage("Action is processed successfully!");
1771
+ * ```
1772
+ * - An adaptive card:
1773
+ * ```typescript
1774
+ * const responseCard = AdaptiveCards.declare(helloWorldCard).render(actionData);
1775
+ return InvokeResponseFactory.adaptiveCard(responseCard);
1776
+ * ```
1777
+ * - An error response:
1778
+ * ```typescript
1779
+ * return InvokeResponseFactory.errorResponse(InvokeResponseErrorCode.BadRequest, "Invalid request");
1780
+ * ```
1781
+ *
1782
+ * @remark For more details about the invoke response format, refer to https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/universal-action-model#response-format.
1783
+ */
1784
+ handleActionInvoked(context: TurnContext, actionData: any): Promise<InvokeResponse>;
1785
+ }
1786
+
1586
1787
  /**
1587
1788
  * Interface for a command handler that can process command to a TeamsFx bot and return a response.
1588
1789
  */