@microsoft/teamsfx 0.6.2-alpha.957c90e1c.0 → 0.6.2-alpha.aafc68d57.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 +421 -1
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +939 -2
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +434 -1
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1001 -0
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +5 -3
- package/types/teamsfx.d.ts +670 -0
package/types/teamsfx.d.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
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';
|
|
2
5
|
import { AuthenticationProvider } from '@microsoft/microsoft-graph-client';
|
|
6
|
+
import { AxiosInstance } from 'axios';
|
|
7
|
+
import { AxiosRequestConfig } from 'axios';
|
|
8
|
+
import { BotFrameworkAdapter } from 'botbuilder';
|
|
9
|
+
import { CardAction } from 'botbuilder';
|
|
10
|
+
import { CardImage } from 'botbuilder';
|
|
11
|
+
import { ChannelInfo } from 'botbuilder';
|
|
3
12
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
4
13
|
import { ConnectionConfig } from 'tedious';
|
|
14
|
+
import { ConversationReference } from 'botbuilder';
|
|
5
15
|
import { Dialog } from 'botbuilder-dialogs';
|
|
6
16
|
import { DialogContext } from 'botbuilder-dialogs';
|
|
7
17
|
import { DialogTurnResult } from 'botbuilder-dialogs';
|
|
8
18
|
import { GetTokenOptions } from '@azure/identity';
|
|
19
|
+
import { HeroCard } from 'botbuilder';
|
|
20
|
+
import { O365ConnectorCard } from 'botbuilder';
|
|
21
|
+
import { ReceiptCard } from 'botbuilder';
|
|
22
|
+
import { TeamsChannelAccount } from 'botbuilder';
|
|
23
|
+
import { ThumbnailCard } from 'botbuilder';
|
|
9
24
|
import { TokenCredential } from '@azure/identity';
|
|
10
25
|
import { TokenResponse } from 'botframework-schema';
|
|
26
|
+
import { TurnContext } from 'botbuilder-core';
|
|
11
27
|
|
|
12
28
|
/**
|
|
13
29
|
* Represent Microsoft 365 tenant identity, and it is usually used when user is not involved like time-triggered automation job.
|
|
@@ -123,6 +139,175 @@ export declare interface AuthenticationConfiguration {
|
|
|
123
139
|
readonly applicationIdUri?: string;
|
|
124
140
|
}
|
|
125
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Defines method that injects authentication info to http requests
|
|
144
|
+
*
|
|
145
|
+
* @beta
|
|
146
|
+
*/
|
|
147
|
+
export declare interface AuthProvider {
|
|
148
|
+
/**
|
|
149
|
+
* Adds authentication info to http requests
|
|
150
|
+
*
|
|
151
|
+
* @param config - Contains all the request information and can be updated to include extra authentication info.
|
|
152
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
153
|
+
*
|
|
154
|
+
* @beta
|
|
155
|
+
*/
|
|
156
|
+
AddAuthenticationInfo: (config: AxiosRequestConfig) => Promise<AxiosRequestConfig>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Provider that handles Bearer Token authentication
|
|
161
|
+
*
|
|
162
|
+
* @beta
|
|
163
|
+
*/
|
|
164
|
+
export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
165
|
+
private getToken;
|
|
166
|
+
/**
|
|
167
|
+
* @param getToken Function that returns the content of bearer token used in http request
|
|
168
|
+
*
|
|
169
|
+
* @beta
|
|
170
|
+
*/
|
|
171
|
+
constructor(getToken: () => Promise<string>);
|
|
172
|
+
/**
|
|
173
|
+
* Adds authentication info to http requests
|
|
174
|
+
*
|
|
175
|
+
* @param config - Contains all the request information and can be updated to include extra authentication info.
|
|
176
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
177
|
+
*
|
|
178
|
+
* @beta
|
|
179
|
+
*/
|
|
180
|
+
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* A {@link NotificationTarget} that represents a team channel.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}.
|
|
188
|
+
*
|
|
189
|
+
* @beta
|
|
190
|
+
*/
|
|
191
|
+
export declare class Channel implements NotificationTarget {
|
|
192
|
+
/**
|
|
193
|
+
* The parent {@link TeamsBotInstallation} where this channel is created from.
|
|
194
|
+
*
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
readonly parent: TeamsBotInstallation;
|
|
198
|
+
/**
|
|
199
|
+
* Detailed channel information.
|
|
200
|
+
*
|
|
201
|
+
* @beta
|
|
202
|
+
*/
|
|
203
|
+
readonly info: ChannelInfo;
|
|
204
|
+
/**
|
|
205
|
+
* Notification target type. For channel it's always "Channel".
|
|
206
|
+
*
|
|
207
|
+
* @beta
|
|
208
|
+
*/
|
|
209
|
+
readonly type: NotificationTargetType;
|
|
210
|
+
/**
|
|
211
|
+
* Constuctor.
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
214
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
|
|
215
|
+
*
|
|
216
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this channel is created from.
|
|
217
|
+
* @param info - Detailed channel information.
|
|
218
|
+
*
|
|
219
|
+
* @beta
|
|
220
|
+
*/
|
|
221
|
+
constructor(parent: TeamsBotInstallation, info: ChannelInfo);
|
|
222
|
+
/**
|
|
223
|
+
* Send a plain text message.
|
|
224
|
+
*
|
|
225
|
+
* @param text - the plain text message.
|
|
226
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
227
|
+
*
|
|
228
|
+
* @beta
|
|
229
|
+
*/
|
|
230
|
+
sendMessage(text: string): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* Send an adaptive card message.
|
|
233
|
+
*
|
|
234
|
+
* @param card - the adaptive card raw JSON.
|
|
235
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
236
|
+
*
|
|
237
|
+
* @beta
|
|
238
|
+
*/
|
|
239
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
private newConversation;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A command bot for receiving commands and sending responses in Teams.
|
|
248
|
+
*
|
|
249
|
+
* @remarks
|
|
250
|
+
* 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.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* 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.
|
|
254
|
+
*
|
|
255
|
+
* ```typescript
|
|
256
|
+
* // register through constructor
|
|
257
|
+
* const commandBot = new CommandBot(adapter, [ new HelloWorldCommandHandler() ]);
|
|
258
|
+
*
|
|
259
|
+
* // register through `register*` API
|
|
260
|
+
* commandBot.registerCommand(new HelpCommandHandler());
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
263
|
+
* @beta
|
|
264
|
+
*/
|
|
265
|
+
export declare class CommandBot {
|
|
266
|
+
readonly adapter: BotFrameworkAdapter;
|
|
267
|
+
private readonly middleware;
|
|
268
|
+
/**
|
|
269
|
+
* Creates a new instance of the `CommandBot`.
|
|
270
|
+
*
|
|
271
|
+
* @param adapter The bound `BotFrameworkAdapter`.
|
|
272
|
+
* @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.
|
|
273
|
+
*
|
|
274
|
+
* @beta
|
|
275
|
+
*/
|
|
276
|
+
constructor(adapter: BotFrameworkAdapter, commands?: TeamsFxBotCommandHandler[]);
|
|
277
|
+
/**
|
|
278
|
+
* Registers a command into the command bot.
|
|
279
|
+
*
|
|
280
|
+
* @param command The command to registered.
|
|
281
|
+
*
|
|
282
|
+
* @beta
|
|
283
|
+
*/
|
|
284
|
+
registerCommand(command: TeamsFxBotCommandHandler): void;
|
|
285
|
+
/**
|
|
286
|
+
* Registers commands into the command bot.
|
|
287
|
+
*
|
|
288
|
+
* @param commands The command to registered.
|
|
289
|
+
*
|
|
290
|
+
* @beta
|
|
291
|
+
*/
|
|
292
|
+
registerCommands(commands: TeamsFxBotCommandHandler[]): void;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Initializes new Axios instance with specific auth provider
|
|
297
|
+
*
|
|
298
|
+
* @param apiEndpoint - Base url of the API
|
|
299
|
+
* @param authProvider - Auth provider that injects authentication info to each request
|
|
300
|
+
* @returns axios instance configured with specfic auth provider
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const client = createApiClient("https://my-api-endpoint-base-url", new BasicAuthProvider("xxx","xxx"));
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @beta
|
|
308
|
+
*/
|
|
309
|
+
export declare function createApiClient(apiEndpoint: string, authProvider: AuthProvider): AxiosInstance;
|
|
310
|
+
|
|
126
311
|
/**
|
|
127
312
|
* Get Microsoft graph client.
|
|
128
313
|
*
|
|
@@ -353,6 +538,198 @@ export declare enum LogLevel {
|
|
|
353
538
|
Error = 3
|
|
354
539
|
}
|
|
355
540
|
|
|
541
|
+
/**
|
|
542
|
+
* A {@link NotificationTarget} that represents a team member.
|
|
543
|
+
*
|
|
544
|
+
* @remarks
|
|
545
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}.
|
|
546
|
+
*
|
|
547
|
+
* @beta
|
|
548
|
+
*/
|
|
549
|
+
export declare class Member implements NotificationTarget {
|
|
550
|
+
/**
|
|
551
|
+
* The parent {@link TeamsBotInstallation} where this member is created from.
|
|
552
|
+
*
|
|
553
|
+
* @beta
|
|
554
|
+
*/
|
|
555
|
+
readonly parent: TeamsBotInstallation;
|
|
556
|
+
/**
|
|
557
|
+
* Detailed member account information.
|
|
558
|
+
*
|
|
559
|
+
* @beta
|
|
560
|
+
*/
|
|
561
|
+
readonly account: TeamsChannelAccount;
|
|
562
|
+
/**
|
|
563
|
+
* Notification target type. For member it's always "Person".
|
|
564
|
+
*
|
|
565
|
+
* @beta
|
|
566
|
+
*/
|
|
567
|
+
readonly type: NotificationTargetType;
|
|
568
|
+
/**
|
|
569
|
+
* Constuctor.
|
|
570
|
+
*
|
|
571
|
+
* @remarks
|
|
572
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
|
|
573
|
+
*
|
|
574
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
|
|
575
|
+
* @param account - Detailed member account information.
|
|
576
|
+
*
|
|
577
|
+
* @beta
|
|
578
|
+
*/
|
|
579
|
+
constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
|
|
580
|
+
/**
|
|
581
|
+
* Send a plain text message.
|
|
582
|
+
*
|
|
583
|
+
* @param text - the plain text message.
|
|
584
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
585
|
+
*
|
|
586
|
+
* @beta
|
|
587
|
+
*/
|
|
588
|
+
sendMessage(text: string): Promise<void>;
|
|
589
|
+
/**
|
|
590
|
+
* Send an adaptive card message.
|
|
591
|
+
*
|
|
592
|
+
* @param card - the adaptive card raw JSON.
|
|
593
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
594
|
+
*
|
|
595
|
+
* @beta
|
|
596
|
+
*/
|
|
597
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
598
|
+
/**
|
|
599
|
+
* @internal
|
|
600
|
+
*/
|
|
601
|
+
private newConversation;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Provides utility method to build bot message with cards that supported in Teams.
|
|
606
|
+
*/
|
|
607
|
+
export declare class MessageBuilder {
|
|
608
|
+
/**
|
|
609
|
+
* Build a bot message activity attached with adaptive card.
|
|
610
|
+
*
|
|
611
|
+
* @param getCardData Function to prepare your card data.
|
|
612
|
+
* @param cardTemplate The adaptive card template.
|
|
613
|
+
* @returns A bot message activity attached with an adaptive card.
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```javascript
|
|
617
|
+
* const cardTemplate = {
|
|
618
|
+
* type: "AdaptiveCard",
|
|
619
|
+
* body: [
|
|
620
|
+
* {
|
|
621
|
+
* "type": "TextBlock",
|
|
622
|
+
* "text": "${title}",
|
|
623
|
+
* "size": "Large"
|
|
624
|
+
* },
|
|
625
|
+
* {
|
|
626
|
+
* "type": "TextBlock",
|
|
627
|
+
* "text": "${description}"
|
|
628
|
+
* }],
|
|
629
|
+
* $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
630
|
+
* version: "1.4"
|
|
631
|
+
* };
|
|
632
|
+
*
|
|
633
|
+
* type CardData = {
|
|
634
|
+
* title: string,
|
|
635
|
+
* description: string
|
|
636
|
+
* };
|
|
637
|
+
* const card = MessageBuilder.attachAdaptiveCard<CardData>(() => {
|
|
638
|
+
* return {
|
|
639
|
+
* title: "sample card title",
|
|
640
|
+
* description: "sample card description"
|
|
641
|
+
* }}, cardTemplate);
|
|
642
|
+
* ```
|
|
643
|
+
*
|
|
644
|
+
* @beta
|
|
645
|
+
*/
|
|
646
|
+
static attachAdaptiveCard<TData>(getCardData: () => TData, cardTemplate: any): Partial<Activity_2>;
|
|
647
|
+
/**
|
|
648
|
+
* Build a bot message activity attached with an adaptive card.
|
|
649
|
+
*
|
|
650
|
+
* @param card The adaptive card content.
|
|
651
|
+
* @returns A bot message activity attached with an adaptive card.
|
|
652
|
+
*
|
|
653
|
+
* @beta
|
|
654
|
+
*/
|
|
655
|
+
static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
|
|
656
|
+
/**
|
|
657
|
+
* Build a bot message activity attached with an hero card.
|
|
658
|
+
*
|
|
659
|
+
* @param title The card title.
|
|
660
|
+
* @param images Optional. The array of images to include on the card.
|
|
661
|
+
* @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
|
|
662
|
+
* is converted to an `imBack` button with a title and value set to the value of the string.
|
|
663
|
+
* @param other Optional. Any additional properties to include on the card.
|
|
664
|
+
*
|
|
665
|
+
* @returns A bot message activity attached with a hero card.
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```javascript
|
|
669
|
+
* const message = MessageBuilder.attachHeroCard(
|
|
670
|
+
* 'sample title',
|
|
671
|
+
* ['https://example.com/sample.jpg'],
|
|
672
|
+
* ['action']
|
|
673
|
+
* );
|
|
674
|
+
* ```
|
|
675
|
+
*
|
|
676
|
+
* @beta
|
|
677
|
+
*/
|
|
678
|
+
static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
|
|
679
|
+
/**
|
|
680
|
+
* Returns an attachment for a sign-in card.
|
|
681
|
+
*
|
|
682
|
+
* @param title The title for the card's sign-in button.
|
|
683
|
+
* @param url The URL of the sign-in page to use.
|
|
684
|
+
* @param text Optional. Additional text to include on the card.
|
|
685
|
+
*
|
|
686
|
+
* @returns A bot message activity attached with a sign-in card.
|
|
687
|
+
*
|
|
688
|
+
* @remarks
|
|
689
|
+
* For channels that don't natively support sign-in cards, an alternative message is rendered.
|
|
690
|
+
*
|
|
691
|
+
* @beta
|
|
692
|
+
*/
|
|
693
|
+
static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
|
|
694
|
+
/**
|
|
695
|
+
* Build a bot message activity attached with an Office 365 connector card.
|
|
696
|
+
*
|
|
697
|
+
* @param card A description of the Office 365 connector card.
|
|
698
|
+
* @returns A bot message activity attached with an Office 365 connector card.
|
|
699
|
+
*
|
|
700
|
+
* @beta
|
|
701
|
+
*/
|
|
702
|
+
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
|
|
703
|
+
/**
|
|
704
|
+
* Build a message activity attached with a receipt card.
|
|
705
|
+
* @param card A description of the receipt card.
|
|
706
|
+
* @returns A message activity attached with a receipt card.
|
|
707
|
+
*
|
|
708
|
+
* @beta
|
|
709
|
+
*/
|
|
710
|
+
static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
|
|
711
|
+
/**
|
|
712
|
+
*
|
|
713
|
+
* @param title The card title.
|
|
714
|
+
* @param images Optional. The array of images to include on the card.
|
|
715
|
+
* @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
|
|
716
|
+
* is converted to an `imBack` button with a title and value set to the value of the string.
|
|
717
|
+
* @param other Optional. Any additional properties to include on the card.
|
|
718
|
+
* @returns A message activity attached with a thumbnail card
|
|
719
|
+
*
|
|
720
|
+
* @beta
|
|
721
|
+
*/
|
|
722
|
+
static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
|
|
723
|
+
/**
|
|
724
|
+
* Add an attachement to a bot activity.
|
|
725
|
+
* @param attachement The attachment object to attach.
|
|
726
|
+
* @returns A message activity with an attachment.
|
|
727
|
+
*
|
|
728
|
+
* @beta
|
|
729
|
+
*/
|
|
730
|
+
static attachContent(attachement: Attachment): Partial<Activity_2>;
|
|
731
|
+
}
|
|
732
|
+
|
|
356
733
|
/**
|
|
357
734
|
* Microsoft Graph auth provider for Teams Framework
|
|
358
735
|
*
|
|
@@ -389,6 +766,174 @@ export declare class MsGraphAuthProvider implements AuthenticationProvider {
|
|
|
389
766
|
getAccessToken(): Promise<string>;
|
|
390
767
|
}
|
|
391
768
|
|
|
769
|
+
/**
|
|
770
|
+
* Provide static utilities for bot conversation, including
|
|
771
|
+
* - send notification to varies targets (e.g., member, channel, incoming wehbook)
|
|
772
|
+
* - handle command and response.
|
|
773
|
+
*
|
|
774
|
+
* @example
|
|
775
|
+
* Here's an example on how to send notification via Teams Bot.
|
|
776
|
+
* ```typescript
|
|
777
|
+
* // initialize (it's recommended to be called before handling any bot message)
|
|
778
|
+
* const notificationBot = new NotificationBot(adapter);
|
|
779
|
+
*
|
|
780
|
+
* // get all bot installations and send message
|
|
781
|
+
* for (const target of await notificationBot.installations()) {
|
|
782
|
+
* await target.sendMessage("Hello Notification");
|
|
783
|
+
* }
|
|
784
|
+
*
|
|
785
|
+
* // alternative - send message to all members
|
|
786
|
+
* for (const target of await notificationBot.installations()) {
|
|
787
|
+
* for (const member of await target.members()) {
|
|
788
|
+
* await member.sendMessage("Hello Notification");
|
|
789
|
+
* }
|
|
790
|
+
* }
|
|
791
|
+
* ```
|
|
792
|
+
*
|
|
793
|
+
* @beta
|
|
794
|
+
*/
|
|
795
|
+
export declare class NotificationBot {
|
|
796
|
+
private readonly conversationReferenceStore;
|
|
797
|
+
private readonly adapter;
|
|
798
|
+
/**
|
|
799
|
+
* constructor of the notification bot.
|
|
800
|
+
*
|
|
801
|
+
* @remarks
|
|
802
|
+
* To ensure accuracy, it's recommended to initialize before handling any message.
|
|
803
|
+
*
|
|
804
|
+
* @param adapter - the bound `BotFrameworkAdapter`
|
|
805
|
+
* @param options - initialize options
|
|
806
|
+
*
|
|
807
|
+
* @beta
|
|
808
|
+
*/
|
|
809
|
+
constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
|
|
810
|
+
/**
|
|
811
|
+
* Get all targets where the bot is installed.
|
|
812
|
+
*
|
|
813
|
+
* @remarks
|
|
814
|
+
* The result is retrieving from the persisted storage.
|
|
815
|
+
*
|
|
816
|
+
* @returns - an array of {@link TeamsBotInstallation}.
|
|
817
|
+
*
|
|
818
|
+
* @beta
|
|
819
|
+
*/
|
|
820
|
+
installations(): Promise<TeamsBotInstallation[]>;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Options to initialize {@link NotificationBot}.
|
|
825
|
+
*
|
|
826
|
+
* @beta
|
|
827
|
+
*/
|
|
828
|
+
declare interface NotificationOptions_2 {
|
|
829
|
+
/**
|
|
830
|
+
* An optional storage to persist bot notification connections.
|
|
831
|
+
*
|
|
832
|
+
* @remarks
|
|
833
|
+
* If `storage` is not provided, a default local file storage will be used,
|
|
834
|
+
* which stores notification connections into:
|
|
835
|
+
* - ".notification.localstore.json" if running locally
|
|
836
|
+
* - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
|
|
837
|
+
*
|
|
838
|
+
* It's recommended to use your own shared storage for production environment.
|
|
839
|
+
*
|
|
840
|
+
* @beta
|
|
841
|
+
*/
|
|
842
|
+
storage?: NotificationTargetStorage;
|
|
843
|
+
}
|
|
844
|
+
export { NotificationOptions_2 as NotificationOptions }
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Represent a notification target.
|
|
848
|
+
*
|
|
849
|
+
* @beta
|
|
850
|
+
*/
|
|
851
|
+
export declare interface NotificationTarget {
|
|
852
|
+
/**
|
|
853
|
+
* The type of target, could be "Channel" or "Group" or "Person".
|
|
854
|
+
*
|
|
855
|
+
* @beta
|
|
856
|
+
*/
|
|
857
|
+
readonly type?: NotificationTargetType;
|
|
858
|
+
/**
|
|
859
|
+
* Send a plain text message.
|
|
860
|
+
*
|
|
861
|
+
* @param text - the plain text message.
|
|
862
|
+
*
|
|
863
|
+
* @beta
|
|
864
|
+
*/
|
|
865
|
+
sendMessage(text: string): Promise<void>;
|
|
866
|
+
/**
|
|
867
|
+
* Send an adaptive card message.
|
|
868
|
+
*
|
|
869
|
+
* @param card - the adaptive card raw JSON.
|
|
870
|
+
*
|
|
871
|
+
* @beta
|
|
872
|
+
*/
|
|
873
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Interface for a storage provider that stores and retrieves notification target references.
|
|
878
|
+
*
|
|
879
|
+
* @beta
|
|
880
|
+
*/
|
|
881
|
+
export declare interface NotificationTargetStorage {
|
|
882
|
+
/**
|
|
883
|
+
* Read one notification target by its key.
|
|
884
|
+
*
|
|
885
|
+
* @param key - the key of a notification target.
|
|
886
|
+
*
|
|
887
|
+
* @returns - the notification target. Or undefined if not found.
|
|
888
|
+
*
|
|
889
|
+
* @beta
|
|
890
|
+
*/
|
|
891
|
+
read(key: string): Promise<{
|
|
892
|
+
[key: string]: unknown;
|
|
893
|
+
} | undefined>;
|
|
894
|
+
/**
|
|
895
|
+
* List all stored notification targets.
|
|
896
|
+
*
|
|
897
|
+
* @returns - an array of notification target. Or an empty array if nothing is stored.
|
|
898
|
+
*
|
|
899
|
+
* @beta
|
|
900
|
+
*/
|
|
901
|
+
list(): Promise<{
|
|
902
|
+
[key: string]: unknown;
|
|
903
|
+
}[]>;
|
|
904
|
+
/**
|
|
905
|
+
* Write one notification target by its key.
|
|
906
|
+
*
|
|
907
|
+
* @param key - the key of a notification target.
|
|
908
|
+
* @param object - the notification target.
|
|
909
|
+
*
|
|
910
|
+
* @beta
|
|
911
|
+
*/
|
|
912
|
+
write(key: string, object: {
|
|
913
|
+
[key: string]: unknown;
|
|
914
|
+
}): Promise<void>;
|
|
915
|
+
/**
|
|
916
|
+
* Delete one notificaton target by its key.
|
|
917
|
+
*
|
|
918
|
+
* @param key - the key of a notification target.
|
|
919
|
+
*
|
|
920
|
+
* @beta
|
|
921
|
+
*/
|
|
922
|
+
delete(key: string): Promise<void>;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* The target type where the notification will be sent to.
|
|
927
|
+
*
|
|
928
|
+
* @remarks
|
|
929
|
+
* - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
|
|
930
|
+
* - "Group" means to a group chat.
|
|
931
|
+
* - "Person" means to a personal chat.
|
|
932
|
+
*
|
|
933
|
+
* @beta
|
|
934
|
+
*/
|
|
935
|
+
export declare type NotificationTargetType = "Channel" | "Group" | "Person";
|
|
936
|
+
|
|
392
937
|
/**
|
|
393
938
|
* Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
|
|
394
939
|
*
|
|
@@ -476,6 +1021,28 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
|
|
|
476
1021
|
private generateAuthServerError;
|
|
477
1022
|
}
|
|
478
1023
|
|
|
1024
|
+
/**
|
|
1025
|
+
* Send an adaptive card message to a notification target.
|
|
1026
|
+
*
|
|
1027
|
+
* @param target - the notification target.
|
|
1028
|
+
* @param card - the adaptive card raw JSON.
|
|
1029
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1030
|
+
*
|
|
1031
|
+
* @beta
|
|
1032
|
+
*/
|
|
1033
|
+
export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Send a plain text message to a notification target.
|
|
1037
|
+
*
|
|
1038
|
+
* @param target - the notification target.
|
|
1039
|
+
* @param text - the plain text message.
|
|
1040
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1041
|
+
*
|
|
1042
|
+
* @beta
|
|
1043
|
+
*/
|
|
1044
|
+
export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
|
|
1045
|
+
|
|
479
1046
|
/**
|
|
480
1047
|
* Set custom log function. Use the function if it's set. Priority is lower than setLogger.
|
|
481
1048
|
*
|
|
@@ -522,6 +1089,89 @@ export declare function setLogger(logger?: Logger): void;
|
|
|
522
1089
|
*/
|
|
523
1090
|
export declare function setLogLevel(level: LogLevel): void;
|
|
524
1091
|
|
|
1092
|
+
/**
|
|
1093
|
+
* A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
|
|
1094
|
+
* - Personal chat
|
|
1095
|
+
* - Group chat
|
|
1096
|
+
* - Team (by default the `General` channel)
|
|
1097
|
+
*
|
|
1098
|
+
* @remarks
|
|
1099
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}.
|
|
1100
|
+
*
|
|
1101
|
+
* @beta
|
|
1102
|
+
*/
|
|
1103
|
+
export declare class TeamsBotInstallation implements NotificationTarget {
|
|
1104
|
+
/**
|
|
1105
|
+
* The bound `BotFrameworkAdapter`.
|
|
1106
|
+
*
|
|
1107
|
+
* @beta
|
|
1108
|
+
*/
|
|
1109
|
+
readonly adapter: BotFrameworkAdapter;
|
|
1110
|
+
/**
|
|
1111
|
+
* The bound `ConversationReference`.
|
|
1112
|
+
*
|
|
1113
|
+
* @beta
|
|
1114
|
+
*/
|
|
1115
|
+
readonly conversationReference: Partial<ConversationReference>;
|
|
1116
|
+
/**
|
|
1117
|
+
* Notification target type.
|
|
1118
|
+
*
|
|
1119
|
+
* @remarks
|
|
1120
|
+
* - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
|
|
1121
|
+
* - "Group" means bot is installed into a group chat.
|
|
1122
|
+
* - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
|
|
1123
|
+
*
|
|
1124
|
+
* @beta
|
|
1125
|
+
*/
|
|
1126
|
+
readonly type?: NotificationTargetType;
|
|
1127
|
+
/**
|
|
1128
|
+
* Constructor
|
|
1129
|
+
*
|
|
1130
|
+
* @remarks
|
|
1131
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
|
|
1132
|
+
*
|
|
1133
|
+
* @param adapter - the bound `BotFrameworkAdapter`.
|
|
1134
|
+
* @param conversationReference - the bound `ConversationReference`.
|
|
1135
|
+
*
|
|
1136
|
+
* @beta
|
|
1137
|
+
*/
|
|
1138
|
+
constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
|
|
1139
|
+
/**
|
|
1140
|
+
* Send a plain text message.
|
|
1141
|
+
*
|
|
1142
|
+
* @param text - the plain text message.
|
|
1143
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1144
|
+
*
|
|
1145
|
+
* @beta
|
|
1146
|
+
*/
|
|
1147
|
+
sendMessage(text: string): Promise<void>;
|
|
1148
|
+
/**
|
|
1149
|
+
* Send an adaptive card message.
|
|
1150
|
+
*
|
|
1151
|
+
* @param card - the adaptive card raw JSON.
|
|
1152
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1153
|
+
*
|
|
1154
|
+
* @beta
|
|
1155
|
+
*/
|
|
1156
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Get channels from this bot installation.
|
|
1159
|
+
*
|
|
1160
|
+
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
|
1161
|
+
*
|
|
1162
|
+
* @beta
|
|
1163
|
+
*/
|
|
1164
|
+
channels(): Promise<Channel[]>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Get members from this bot installation.
|
|
1167
|
+
*
|
|
1168
|
+
* @returns an array of members from where the bot is installed.
|
|
1169
|
+
*
|
|
1170
|
+
* @beta
|
|
1171
|
+
*/
|
|
1172
|
+
members(): Promise<Member[]>;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
525
1175
|
/**
|
|
526
1176
|
* Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
|
|
527
1177
|
* help receive oauth token, asks the user to consent if needed.
|
|
@@ -809,6 +1459,26 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
809
1459
|
private loadFromEnv;
|
|
810
1460
|
}
|
|
811
1461
|
|
|
1462
|
+
/**
|
|
1463
|
+
* Interface for a command handler that can process command to a TeamsFx bot and return a response.
|
|
1464
|
+
*
|
|
1465
|
+
* @beta
|
|
1466
|
+
*/
|
|
1467
|
+
export declare interface TeamsFxBotCommandHandler {
|
|
1468
|
+
/**
|
|
1469
|
+
* The command name or RegExp pattern that can trigger this handler.
|
|
1470
|
+
*/
|
|
1471
|
+
commandNameOrPattern: string | RegExp;
|
|
1472
|
+
/**
|
|
1473
|
+
* Handles a bot command received activity.
|
|
1474
|
+
*
|
|
1475
|
+
* @param context The bot context.
|
|
1476
|
+
* @param receivedText The command text the user types from Teams.
|
|
1477
|
+
* @returns A `Promise` representing an activity or text to send as the command response.
|
|
1478
|
+
*/
|
|
1479
|
+
handleCommandReceived(context: TurnContext, receivedText: string): Promise<string | Partial<Activity>>;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
812
1482
|
/**
|
|
813
1483
|
* TeamsFx interface that provides credential and configuration.
|
|
814
1484
|
* @beta
|