@microsoft/teamsfx 0.6.2-alpha.b7cedce9e.0 → 0.6.2

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": "0.6.2-alpha.b7cedce9e.0",
3
+ "version": "0.6.2",
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,7 +49,6 @@
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": "0.1.6-alpha.b7cedce9e.0",
53
52
  "@microsoft/microsoft-graph-client": "^3.0.1",
54
53
  "axios": "^0.24.0",
55
54
  "botbuilder": ">=4.15.0 <5.0.0",
@@ -127,7 +126,7 @@
127
126
  "webpack": "^5.62.1",
128
127
  "yargs": "^17.2.1"
129
128
  },
130
- "gitHead": "5c07c94d045e41983def65e5dbdba0b0a04d559c",
129
+ "gitHead": "98782ce0bca09d3a36bed239017ff81ed6994c0e",
131
130
  "publishConfig": {
132
131
  "access": "public"
133
132
  },
@@ -1,27 +1,13 @@
1
1
  import { AccessToken } from '@azure/identity';
2
- import { Activity } from 'botbuilder-core';
3
- import { Activity as Activity_2 } from 'botbuilder';
4
- import { Attachment } from 'botbuilder';
5
2
  import { AuthenticationProvider } from '@microsoft/microsoft-graph-client';
6
- import { BotFrameworkAdapter } from 'botbuilder';
7
- import { CardAction } from 'botbuilder';
8
- import { CardImage } from 'botbuilder';
9
- import { ChannelInfo } from 'botbuilder';
10
3
  import { Client } from '@microsoft/microsoft-graph-client';
11
4
  import { ConnectionConfig } from 'tedious';
12
- import { ConversationReference } from 'botbuilder';
13
5
  import { Dialog } from 'botbuilder-dialogs';
14
6
  import { DialogContext } from 'botbuilder-dialogs';
15
7
  import { DialogTurnResult } from 'botbuilder-dialogs';
16
8
  import { GetTokenOptions } from '@azure/identity';
17
- import { HeroCard } from 'botbuilder';
18
- import { O365ConnectorCard } from 'botbuilder';
19
- import { ReceiptCard } from 'botbuilder';
20
- import { TeamsChannelAccount } from 'botbuilder';
21
- import { ThumbnailCard } from 'botbuilder';
22
9
  import { TokenCredential } from '@azure/identity';
23
10
  import { TokenResponse } from 'botframework-schema';
24
- import { TurnContext } from 'botbuilder-core';
25
11
 
26
12
  /**
27
13
  * Represent Microsoft 365 tenant identity, and it is usually used when user is not involved like time-triggered automation job.
@@ -137,118 +123,6 @@ export declare interface AuthenticationConfiguration {
137
123
  readonly applicationIdUri?: string;
138
124
  }
139
125
 
140
- /**
141
- * A {@link NotificationTarget} that represents a team channel.
142
- *
143
- * @remarks
144
- * It's recommended to get channels from {@link TeamsBotInstallation.channels()}.
145
- *
146
- * @beta
147
- */
148
- export declare class Channel implements NotificationTarget {
149
- /**
150
- * The parent {@link TeamsBotInstallation} where this channel is created from.
151
- *
152
- * @beta
153
- */
154
- readonly parent: TeamsBotInstallation;
155
- /**
156
- * Detailed channel information.
157
- *
158
- * @beta
159
- */
160
- readonly info: ChannelInfo;
161
- /**
162
- * Notification target type. For channel it's always "Channel".
163
- *
164
- * @beta
165
- */
166
- readonly type: NotificationTargetType;
167
- /**
168
- * Constuctor.
169
- *
170
- * @remarks
171
- * It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
172
- *
173
- * @param parent - The parent {@link TeamsBotInstallation} where this channel is created from.
174
- * @param info - Detailed channel information.
175
- *
176
- * @beta
177
- */
178
- constructor(parent: TeamsBotInstallation, info: ChannelInfo);
179
- /**
180
- * Send a plain text message.
181
- *
182
- * @param text - the plain text message.
183
- * @returns A `Promise` representing the asynchronous operation.
184
- *
185
- * @beta
186
- */
187
- sendMessage(text: string): Promise<void>;
188
- /**
189
- * Send an adaptive card message.
190
- *
191
- * @param card - the adaptive card raw JSON.
192
- * @returns A `Promise` representing the asynchronous operation.
193
- *
194
- * @beta
195
- */
196
- sendAdaptiveCard(card: unknown): Promise<void>;
197
- /**
198
- * @internal
199
- */
200
- private newConversation;
201
- }
202
-
203
- /**
204
- * A command bot for receiving commands and sending responses in Teams.
205
- *
206
- * @remarks
207
- * Ensure each command should ONLY be registered with the command once, otherwise it'll cause unexpected behavior if you register the same command more than once.
208
- *
209
- * @example
210
- * You can register your commands through the constructor of the {@link CommandBot}, or use the `registerCommand` and `registerCommands` API to add commands after creating the `CommandBot` instance.
211
- *
212
- * ```typescript
213
- * // register through constructor
214
- * const commandBot = new CommandBot(adapter, [ new HelloWorldCommandHandler() ]);
215
- *
216
- * // register through `register*` API
217
- * commandBot.registerCommand(new HelpCommandHandler());
218
- * ```
219
- *
220
- * @beta
221
- */
222
- export declare class CommandBot {
223
- readonly adapter: BotFrameworkAdapter;
224
- private readonly middleware;
225
- /**
226
- * Creates a new instance of the `CommandBot`.
227
- *
228
- * @param adapter The bound `BotFrameworkAdapter`.
229
- * @param commands The commands to registered with the command bot. Each command should implement the interface {@link TeamsFxBotCommandHandler} so that it can be correctly handled by this command bot.
230
- *
231
- * @beta
232
- */
233
- constructor(adapter: BotFrameworkAdapter, commands?: TeamsFxBotCommandHandler[]);
234
- /**
235
- * Registers a command into the command bot.
236
- *
237
- * @param command The command to registered.
238
- *
239
- * @beta
240
- */
241
- registerCommand(command: TeamsFxBotCommandHandler): void;
242
- /**
243
- * Registers commands into the command bot.
244
- *
245
- * @param commands The command to registered.
246
- *
247
- * @beta
248
- */
249
- registerCommands(commands: TeamsFxBotCommandHandler[]): void;
250
- }
251
-
252
126
  /**
253
127
  * Get Microsoft graph client.
254
128
  *
@@ -479,198 +353,6 @@ export declare enum LogLevel {
479
353
  Error = 3
480
354
  }
481
355
 
482
- /**
483
- * A {@link NotificationTarget} that represents a team member.
484
- *
485
- * @remarks
486
- * It's recommended to get members from {@link TeamsBotInstallation.members()}.
487
- *
488
- * @beta
489
- */
490
- export declare class Member implements NotificationTarget {
491
- /**
492
- * The parent {@link TeamsBotInstallation} where this member is created from.
493
- *
494
- * @beta
495
- */
496
- readonly parent: TeamsBotInstallation;
497
- /**
498
- * Detailed member account information.
499
- *
500
- * @beta
501
- */
502
- readonly account: TeamsChannelAccount;
503
- /**
504
- * Notification target type. For member it's always "Person".
505
- *
506
- * @beta
507
- */
508
- readonly type: NotificationTargetType;
509
- /**
510
- * Constuctor.
511
- *
512
- * @remarks
513
- * It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
514
- *
515
- * @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
516
- * @param account - Detailed member account information.
517
- *
518
- * @beta
519
- */
520
- constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
521
- /**
522
- * Send a plain text message.
523
- *
524
- * @param text - the plain text message.
525
- * @returns A `Promise` representing the asynchronous operation.
526
- *
527
- * @beta
528
- */
529
- sendMessage(text: string): Promise<void>;
530
- /**
531
- * Send an adaptive card message.
532
- *
533
- * @param card - the adaptive card raw JSON.
534
- * @returns A `Promise` representing the asynchronous operation.
535
- *
536
- * @beta
537
- */
538
- sendAdaptiveCard(card: unknown): Promise<void>;
539
- /**
540
- * @internal
541
- */
542
- private newConversation;
543
- }
544
-
545
- /**
546
- * Provides utility method to build bot message with cards that supported in Teams.
547
- */
548
- export declare class MessageBuilder {
549
- /**
550
- * Build a bot message activity attached with adaptive card.
551
- *
552
- * @param getCardData Function to prepare your card data.
553
- * @param cardTemplate The adaptive card template.
554
- * @returns A bot message activity attached with an adaptive card.
555
- *
556
- * @example
557
- * ```javascript
558
- * const cardTemplate = {
559
- * type: "AdaptiveCard",
560
- * body: [
561
- * {
562
- * "type": "TextBlock",
563
- * "text": "${title}",
564
- * "size": "Large"
565
- * },
566
- * {
567
- * "type": "TextBlock",
568
- * "text": "${description}"
569
- * }],
570
- * $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
571
- * version: "1.4"
572
- * };
573
- *
574
- * type CardData = {
575
- * title: string,
576
- * description: string
577
- * };
578
- * const card = MessageBuilder.attachAdaptiveCard<CardData>(() => {
579
- * return {
580
- * title: "sample card title",
581
- * description: "sample card description"
582
- * }}, cardTemplate);
583
- * ```
584
- *
585
- * @beta
586
- */
587
- static attachAdaptiveCard<TData>(getCardData: () => TData, cardTemplate: any): Partial<Activity_2>;
588
- /**
589
- * Build a bot message activity attached with an adaptive card.
590
- *
591
- * @param card The adaptive card content.
592
- * @returns A bot message activity attached with an adaptive card.
593
- *
594
- * @beta
595
- */
596
- static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
597
- /**
598
- * Build a bot message activity attached with an hero card.
599
- *
600
- * @param title The card title.
601
- * @param images Optional. The array of images to include on the card.
602
- * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
603
- * is converted to an `imBack` button with a title and value set to the value of the string.
604
- * @param other Optional. Any additional properties to include on the card.
605
- *
606
- * @returns A bot message activity attached with a hero card.
607
- *
608
- * @example
609
- * ```javascript
610
- * const message = MessageBuilder.attachHeroCard(
611
- * 'sample title',
612
- * ['https://example.com/sample.jpg'],
613
- * ['action']
614
- * );
615
- * ```
616
- *
617
- * @beta
618
- */
619
- static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
620
- /**
621
- * Returns an attachment for a sign-in card.
622
- *
623
- * @param title The title for the card's sign-in button.
624
- * @param url The URL of the sign-in page to use.
625
- * @param text Optional. Additional text to include on the card.
626
- *
627
- * @returns A bot message activity attached with a sign-in card.
628
- *
629
- * @remarks
630
- * For channels that don't natively support sign-in cards, an alternative message is rendered.
631
- *
632
- * @beta
633
- */
634
- static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
635
- /**
636
- * Build a bot message activity attached with an Office 365 connector card.
637
- *
638
- * @param card A description of the Office 365 connector card.
639
- * @returns A bot message activity attached with an Office 365 connector card.
640
- *
641
- * @beta
642
- */
643
- static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
644
- /**
645
- * Build a message activity attached with a receipt card.
646
- * @param card A description of the receipt card.
647
- * @returns A message activity attached with a receipt card.
648
- *
649
- * @beta
650
- */
651
- static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
652
- /**
653
- *
654
- * @param title The card title.
655
- * @param images Optional. The array of images to include on the card.
656
- * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
657
- * is converted to an `imBack` button with a title and value set to the value of the string.
658
- * @param other Optional. Any additional properties to include on the card.
659
- * @returns A message activity attached with a thumbnail card
660
- *
661
- * @beta
662
- */
663
- static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
664
- /**
665
- * Add an attachement to a bot activity.
666
- * @param attachement The attachment object to attach.
667
- * @returns A message activity with an attachment.
668
- *
669
- * @beta
670
- */
671
- static attachContent(attachement: Attachment): Partial<Activity_2>;
672
- }
673
-
674
356
  /**
675
357
  * Microsoft Graph auth provider for Teams Framework
676
358
  *
@@ -707,174 +389,6 @@ export declare class MsGraphAuthProvider implements AuthenticationProvider {
707
389
  getAccessToken(): Promise<string>;
708
390
  }
709
391
 
710
- /**
711
- * Provide static utilities for bot conversation, including
712
- * - send notification to varies targets (e.g., member, channel, incoming wehbook)
713
- * - handle command and response.
714
- *
715
- * @example
716
- * Here's an example on how to send notification via Teams Bot.
717
- * ```typescript
718
- * // initialize (it's recommended to be called before handling any bot message)
719
- * const notificationBot = new NotificationBot(adapter);
720
- *
721
- * // get all bot installations and send message
722
- * for (const target of await notificationBot.installations()) {
723
- * await target.sendMessage("Hello Notification");
724
- * }
725
- *
726
- * // alternative - send message to all members
727
- * for (const target of await notificationBot.installations()) {
728
- * for (const member of await target.members()) {
729
- * await member.sendMessage("Hello Notification");
730
- * }
731
- * }
732
- * ```
733
- *
734
- * @beta
735
- */
736
- export declare class NotificationBot {
737
- private readonly conversationReferenceStore;
738
- private readonly adapter;
739
- /**
740
- * constructor of the notification bot.
741
- *
742
- * @remarks
743
- * To ensure accuracy, it's recommended to initialize before handling any message.
744
- *
745
- * @param adapter - the bound `BotFrameworkAdapter`
746
- * @param options - initialize options
747
- *
748
- * @beta
749
- */
750
- constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
751
- /**
752
- * Get all targets where the bot is installed.
753
- *
754
- * @remarks
755
- * The result is retrieving from the persisted storage.
756
- *
757
- * @returns - an array of {@link TeamsBotInstallation}.
758
- *
759
- * @beta
760
- */
761
- installations(): Promise<TeamsBotInstallation[]>;
762
- }
763
-
764
- /**
765
- * Options to initialize {@link NotificationBot}.
766
- *
767
- * @beta
768
- */
769
- declare interface NotificationOptions_2 {
770
- /**
771
- * An optional storage to persist bot notification connections.
772
- *
773
- * @remarks
774
- * If `storage` is not provided, a default local file storage will be used,
775
- * which stores notification connections into:
776
- * - ".notification.localstore.json" if running locally
777
- * - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
778
- *
779
- * It's recommended to use your own shared storage for production environment.
780
- *
781
- * @beta
782
- */
783
- storage?: NotificationTargetStorage;
784
- }
785
- export { NotificationOptions_2 as NotificationOptions }
786
-
787
- /**
788
- * Represent a notification target.
789
- *
790
- * @beta
791
- */
792
- export declare interface NotificationTarget {
793
- /**
794
- * The type of target, could be "Channel" or "Group" or "Person".
795
- *
796
- * @beta
797
- */
798
- readonly type?: NotificationTargetType;
799
- /**
800
- * Send a plain text message.
801
- *
802
- * @param text - the plain text message.
803
- *
804
- * @beta
805
- */
806
- sendMessage(text: string): Promise<void>;
807
- /**
808
- * Send an adaptive card message.
809
- *
810
- * @param card - the adaptive card raw JSON.
811
- *
812
- * @beta
813
- */
814
- sendAdaptiveCard(card: unknown): Promise<void>;
815
- }
816
-
817
- /**
818
- * Interface for a storage provider that stores and retrieves notification target references.
819
- *
820
- * @beta
821
- */
822
- declare interface NotificationTargetStorage {
823
- /**
824
- * Read one notification target by its key.
825
- *
826
- * @param key - the key of a notification target.
827
- *
828
- * @returns - the notification target. Or undefined if not found.
829
- *
830
- * @beta
831
- */
832
- read(key: string): Promise<{
833
- [key: string]: unknown;
834
- } | undefined>;
835
- /**
836
- * List all stored notification targets.
837
- *
838
- * @returns - an array of notification target. Or an empty array if nothing is stored.
839
- *
840
- * @beta
841
- */
842
- list(): Promise<{
843
- [key: string]: unknown;
844
- }[]>;
845
- /**
846
- * Write one notification target by its key.
847
- *
848
- * @param key - the key of a notification target.
849
- * @param object - the notification target.
850
- *
851
- * @beta
852
- */
853
- write(key: string, object: {
854
- [key: string]: unknown;
855
- }): Promise<void>;
856
- /**
857
- * Delete one notificaton target by its key.
858
- *
859
- * @param key - the key of a notification target.
860
- *
861
- * @beta
862
- */
863
- delete(key: string): Promise<void>;
864
- }
865
-
866
- /**
867
- * The target type where the notification will be sent to.
868
- *
869
- * @remarks
870
- * - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
871
- * - "Group" means to a group chat.
872
- * - "Person" means to a personal chat.
873
- *
874
- * @beta
875
- */
876
- export declare type NotificationTargetType = "Channel" | "Group" | "Person";
877
-
878
392
  /**
879
393
  * Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
880
394
  *
@@ -962,28 +476,6 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
962
476
  private generateAuthServerError;
963
477
  }
964
478
 
965
- /**
966
- * Send an adaptive card message to a notification target.
967
- *
968
- * @param target - the notification target.
969
- * @param card - the adaptive card raw JSON.
970
- * @returns A `Promise` representing the asynchronous operation.
971
- *
972
- * @beta
973
- */
974
- export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
975
-
976
- /**
977
- * Send a plain text message to a notification target.
978
- *
979
- * @param target - the notification target.
980
- * @param text - the plain text message.
981
- * @returns A `Promise` representing the asynchronous operation.
982
- *
983
- * @beta
984
- */
985
- export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
986
-
987
479
  /**
988
480
  * Set custom log function. Use the function if it's set. Priority is lower than setLogger.
989
481
  *
@@ -1030,89 +522,6 @@ export declare function setLogger(logger?: Logger): void;
1030
522
  */
1031
523
  export declare function setLogLevel(level: LogLevel): void;
1032
524
 
1033
- /**
1034
- * A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
1035
- * - Personal chat
1036
- * - Group chat
1037
- * - Team (by default the `General` channel)
1038
- *
1039
- * @remarks
1040
- * It's recommended to get bot installations from {@link ConversationBot.installations()}.
1041
- *
1042
- * @beta
1043
- */
1044
- export declare class TeamsBotInstallation implements NotificationTarget {
1045
- /**
1046
- * The bound `BotFrameworkAdapter`.
1047
- *
1048
- * @beta
1049
- */
1050
- readonly adapter: BotFrameworkAdapter;
1051
- /**
1052
- * The bound `ConversationReference`.
1053
- *
1054
- * @beta
1055
- */
1056
- readonly conversationReference: Partial<ConversationReference>;
1057
- /**
1058
- * Notification target type.
1059
- *
1060
- * @remarks
1061
- * - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
1062
- * - "Group" means bot is installed into a group chat.
1063
- * - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
1064
- *
1065
- * @beta
1066
- */
1067
- readonly type?: NotificationTargetType;
1068
- /**
1069
- * Constructor
1070
- *
1071
- * @remarks
1072
- * It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
1073
- *
1074
- * @param adapter - the bound `BotFrameworkAdapter`.
1075
- * @param conversationReference - the bound `ConversationReference`.
1076
- *
1077
- * @beta
1078
- */
1079
- constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
1080
- /**
1081
- * Send a plain text message.
1082
- *
1083
- * @param text - the plain text message.
1084
- * @returns A `Promise` representing the asynchronous operation.
1085
- *
1086
- * @beta
1087
- */
1088
- sendMessage(text: string): Promise<void>;
1089
- /**
1090
- * Send an adaptive card message.
1091
- *
1092
- * @param card - the adaptive card raw JSON.
1093
- * @returns A `Promise` representing the asynchronous operation.
1094
- *
1095
- * @beta
1096
- */
1097
- sendAdaptiveCard(card: unknown): Promise<void>;
1098
- /**
1099
- * Get channels from this bot installation.
1100
- *
1101
- * @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
1102
- *
1103
- * @beta
1104
- */
1105
- channels(): Promise<Channel[]>;
1106
- /**
1107
- * Get members from this bot installation.
1108
- *
1109
- * @returns an array of members from where the bot is installed.
1110
- *
1111
- * @beta
1112
- */
1113
- members(): Promise<Member[]>;
1114
- }
1115
-
1116
525
  /**
1117
526
  * Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
1118
527
  * help receive oauth token, asks the user to consent if needed.
@@ -1400,26 +809,6 @@ export declare class TeamsFx implements TeamsFxConfiguration {
1400
809
  private loadFromEnv;
1401
810
  }
1402
811
 
1403
- /**
1404
- * Interface for a command handler that can process command to a TeamsFx bot and return a response.
1405
- *
1406
- * @beta
1407
- */
1408
- export declare interface TeamsFxBotCommandHandler {
1409
- /**
1410
- * The command name or RegExp pattern that can trigger this handler.
1411
- */
1412
- commandNameOrPattern: string | RegExp;
1413
- /**
1414
- * Handles a bot command received activity.
1415
- *
1416
- * @param context The bot context.
1417
- * @param receivedText The command text the user types from Teams.
1418
- * @returns A `Promise` representing an activity or text to send as the command response.
1419
- */
1420
- handleCommandReceived(context: TurnContext, receivedText: string): Promise<string | Partial<Activity>>;
1421
- }
1422
-
1423
812
  /**
1424
813
  * TeamsFx interface that provides credential and configuration.
1425
814
  * @beta