@microsoft/teamsfx 1.2.1-alpha.cecbda807.0 → 1.2.1-rc.1
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 +18 -8
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +124 -36
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +18 -8
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +124 -36
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -3
- package/types/teamsfx.d.ts +32 -10
package/dist/index.esm2017.mjs
CHANGED
|
@@ -532,7 +532,10 @@ class AppCredential {
|
|
|
532
532
|
*/
|
|
533
533
|
loadAndValidateConfig(config) {
|
|
534
534
|
internalLogger.verbose("Validate authentication configuration");
|
|
535
|
-
if (config.clientId &&
|
|
535
|
+
if (config.clientId &&
|
|
536
|
+
(config.clientSecret || config.certificateContent) &&
|
|
537
|
+
config.tenantId &&
|
|
538
|
+
config.authorityHost) {
|
|
536
539
|
return config;
|
|
537
540
|
}
|
|
538
541
|
const missingValues = [];
|
|
@@ -545,6 +548,9 @@ class AppCredential {
|
|
|
545
548
|
if (!config.tenantId) {
|
|
546
549
|
missingValues.push("tenantId");
|
|
547
550
|
}
|
|
551
|
+
if (!config.authorityHost) {
|
|
552
|
+
missingValues.push("authorityHost");
|
|
553
|
+
}
|
|
548
554
|
const errorMsg = formatString(ErrorMessage.InvalidConfiguration, missingValues.join(", "), "undefined");
|
|
549
555
|
internalLogger.error(errorMsg);
|
|
550
556
|
throw new ErrorWithCode(errorMsg, ErrorCode.InvalidConfiguration);
|
|
@@ -1247,9 +1253,6 @@ class TeamsBotSsoPrompt extends Dialog {
|
|
|
1247
1253
|
if (!this.teamsfx.hasConfig("tenantId")) {
|
|
1248
1254
|
missingConfigurations.push("tenantId");
|
|
1249
1255
|
}
|
|
1250
|
-
if (!this.teamsfx.hasConfig("applicationIdUri")) {
|
|
1251
|
-
missingConfigurations.push("applicationIdUri");
|
|
1252
|
-
}
|
|
1253
1256
|
if (missingConfigurations.length != 0) {
|
|
1254
1257
|
const errorMsg = formatString(ErrorMessage.InvalidConfiguration, missingConfigurations.join(", "), "undefined");
|
|
1255
1258
|
internalLogger.error(errorMsg);
|
|
@@ -1300,9 +1303,7 @@ class TeamsBotSsoPrompt extends Dialog {
|
|
|
1300
1303
|
internalLogger.verbose("Sign in link: " + signInLink);
|
|
1301
1304
|
const tokenExchangeResource = {
|
|
1302
1305
|
id: v4(),
|
|
1303
|
-
uri: this.teamsfx.getConfig("applicationIdUri").replace(/\/$/, "") + "/access_as_user",
|
|
1304
1306
|
};
|
|
1305
|
-
internalLogger.verbose("Token exchange resource uri: " + tokenExchangeResource.uri);
|
|
1306
1307
|
return {
|
|
1307
1308
|
signInLink: signInLink,
|
|
1308
1309
|
tokenExchangeResource: tokenExchangeResource,
|
|
@@ -2367,8 +2368,17 @@ function getTargetType(conversationReference) {
|
|
|
2367
2368
|
* @internal
|
|
2368
2369
|
*/
|
|
2369
2370
|
function getTeamsBotInstallationId(context) {
|
|
2370
|
-
var _a, _b, _c
|
|
2371
|
-
|
|
2371
|
+
var _a, _b, _c;
|
|
2372
|
+
const teamId = (_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;
|
|
2373
|
+
if (teamId) {
|
|
2374
|
+
return teamId;
|
|
2375
|
+
}
|
|
2376
|
+
// Fallback to use conversation id.
|
|
2377
|
+
// the conversation id is equal to team id only when the bot app is installed into the General channel.
|
|
2378
|
+
if (context.activity.conversation.name === undefined) {
|
|
2379
|
+
return context.activity.conversation.id;
|
|
2380
|
+
}
|
|
2381
|
+
return undefined;
|
|
2372
2382
|
}
|
|
2373
2383
|
|
|
2374
2384
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2586,20 +2596,24 @@ class ConversationReferenceStore {
|
|
|
2586
2596
|
*
|
|
2587
2597
|
* @param target - the notification target.
|
|
2588
2598
|
* @param text - the plain text message.
|
|
2599
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2600
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2589
2601
|
* @returns the response of sending message.
|
|
2590
2602
|
*/
|
|
2591
|
-
function sendMessage(target, text) {
|
|
2592
|
-
return target.sendMessage(text);
|
|
2603
|
+
function sendMessage(target, text, onError) {
|
|
2604
|
+
return target.sendMessage(text, onError);
|
|
2593
2605
|
}
|
|
2594
2606
|
/**
|
|
2595
2607
|
* Send an adaptive card message to a notification target.
|
|
2596
2608
|
*
|
|
2597
2609
|
* @param target - the notification target.
|
|
2598
2610
|
* @param card - the adaptive card raw JSON.
|
|
2611
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2612
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2599
2613
|
* @returns the response of sending adaptive card message.
|
|
2600
2614
|
*/
|
|
2601
|
-
function sendAdaptiveCard(target, card) {
|
|
2602
|
-
return target.sendAdaptiveCard(card);
|
|
2615
|
+
function sendAdaptiveCard(target, card, onError) {
|
|
2616
|
+
return target.sendAdaptiveCard(card, onError);
|
|
2603
2617
|
}
|
|
2604
2618
|
/**
|
|
2605
2619
|
* A {@link NotificationTarget} that represents a team channel.
|
|
@@ -2629,15 +2643,27 @@ class Channel {
|
|
|
2629
2643
|
* Send a plain text message.
|
|
2630
2644
|
*
|
|
2631
2645
|
* @param text - the plain text message.
|
|
2646
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2647
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2632
2648
|
* @returns the response of sending message.
|
|
2633
2649
|
*/
|
|
2634
|
-
async sendMessage(text) {
|
|
2650
|
+
async sendMessage(text, onError) {
|
|
2635
2651
|
const response = {};
|
|
2636
2652
|
await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
|
|
2637
2653
|
const conversation = await this.newConversation(context);
|
|
2638
2654
|
await this.parent.adapter.continueConversation(conversation, async (ctx) => {
|
|
2639
|
-
|
|
2640
|
-
|
|
2655
|
+
try {
|
|
2656
|
+
const res = await ctx.sendActivity(text);
|
|
2657
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2658
|
+
}
|
|
2659
|
+
catch (error) {
|
|
2660
|
+
if (onError) {
|
|
2661
|
+
await onError(ctx, error);
|
|
2662
|
+
}
|
|
2663
|
+
else {
|
|
2664
|
+
throw error;
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2641
2667
|
});
|
|
2642
2668
|
});
|
|
2643
2669
|
return response;
|
|
@@ -2646,17 +2672,29 @@ class Channel {
|
|
|
2646
2672
|
* Send an adaptive card message.
|
|
2647
2673
|
*
|
|
2648
2674
|
* @param card - the adaptive card raw JSON.
|
|
2675
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2676
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2649
2677
|
* @returns the response of sending adaptive card message.
|
|
2650
2678
|
*/
|
|
2651
|
-
async sendAdaptiveCard(card) {
|
|
2679
|
+
async sendAdaptiveCard(card, onError) {
|
|
2652
2680
|
const response = {};
|
|
2653
2681
|
await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
|
|
2654
2682
|
const conversation = await this.newConversation(context);
|
|
2655
2683
|
await this.parent.adapter.continueConversation(conversation, async (ctx) => {
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2684
|
+
try {
|
|
2685
|
+
const res = await ctx.sendActivity({
|
|
2686
|
+
attachments: [CardFactory.adaptiveCard(card)],
|
|
2687
|
+
});
|
|
2688
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2689
|
+
}
|
|
2690
|
+
catch (error) {
|
|
2691
|
+
if (onError) {
|
|
2692
|
+
await onError(ctx, error);
|
|
2693
|
+
}
|
|
2694
|
+
else {
|
|
2695
|
+
throw error;
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2660
2698
|
});
|
|
2661
2699
|
});
|
|
2662
2700
|
return response;
|
|
@@ -2699,15 +2737,27 @@ class Member {
|
|
|
2699
2737
|
* Send a plain text message.
|
|
2700
2738
|
*
|
|
2701
2739
|
* @param text - the plain text message.
|
|
2740
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2741
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2702
2742
|
* @returns the response of sending message.
|
|
2703
2743
|
*/
|
|
2704
|
-
async sendMessage(text) {
|
|
2744
|
+
async sendMessage(text, onError) {
|
|
2705
2745
|
const response = {};
|
|
2706
2746
|
await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
|
|
2707
2747
|
const conversation = await this.newConversation(context);
|
|
2708
2748
|
await this.parent.adapter.continueConversation(conversation, async (ctx) => {
|
|
2709
|
-
|
|
2710
|
-
|
|
2749
|
+
try {
|
|
2750
|
+
const res = await ctx.sendActivity(text);
|
|
2751
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2752
|
+
}
|
|
2753
|
+
catch (error) {
|
|
2754
|
+
if (onError) {
|
|
2755
|
+
await onError(ctx, error);
|
|
2756
|
+
}
|
|
2757
|
+
else {
|
|
2758
|
+
throw error;
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2711
2761
|
});
|
|
2712
2762
|
});
|
|
2713
2763
|
return response;
|
|
@@ -2716,17 +2766,29 @@ class Member {
|
|
|
2716
2766
|
* Send an adaptive card message.
|
|
2717
2767
|
*
|
|
2718
2768
|
* @param card - the adaptive card raw JSON.
|
|
2769
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2770
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2719
2771
|
* @returns the response of sending adaptive card message.
|
|
2720
2772
|
*/
|
|
2721
|
-
async sendAdaptiveCard(card) {
|
|
2773
|
+
async sendAdaptiveCard(card, onError) {
|
|
2722
2774
|
const response = {};
|
|
2723
2775
|
await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
|
|
2724
2776
|
const conversation = await this.newConversation(context);
|
|
2725
2777
|
await this.parent.adapter.continueConversation(conversation, async (ctx) => {
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2778
|
+
try {
|
|
2779
|
+
const res = await ctx.sendActivity({
|
|
2780
|
+
attachments: [CardFactory.adaptiveCard(card)],
|
|
2781
|
+
});
|
|
2782
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2783
|
+
}
|
|
2784
|
+
catch (error) {
|
|
2785
|
+
if (onError) {
|
|
2786
|
+
await onError(ctx, error);
|
|
2787
|
+
}
|
|
2788
|
+
else {
|
|
2789
|
+
throw error;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2730
2792
|
});
|
|
2731
2793
|
});
|
|
2732
2794
|
return response;
|
|
@@ -2777,13 +2839,25 @@ class TeamsBotInstallation {
|
|
|
2777
2839
|
* Send a plain text message.
|
|
2778
2840
|
*
|
|
2779
2841
|
* @param text - the plain text message.
|
|
2842
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2843
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2780
2844
|
* @returns the response of sending message.
|
|
2781
2845
|
*/
|
|
2782
|
-
async sendMessage(text) {
|
|
2846
|
+
async sendMessage(text, onError) {
|
|
2783
2847
|
const response = {};
|
|
2784
2848
|
await this.adapter.continueConversation(this.conversationReference, async (context) => {
|
|
2785
|
-
|
|
2786
|
-
|
|
2849
|
+
try {
|
|
2850
|
+
const res = await context.sendActivity(text);
|
|
2851
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2852
|
+
}
|
|
2853
|
+
catch (error) {
|
|
2854
|
+
if (onError) {
|
|
2855
|
+
await onError(context, error);
|
|
2856
|
+
}
|
|
2857
|
+
else {
|
|
2858
|
+
throw error;
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2787
2861
|
});
|
|
2788
2862
|
return response;
|
|
2789
2863
|
}
|
|
@@ -2791,15 +2865,27 @@ class TeamsBotInstallation {
|
|
|
2791
2865
|
* Send an adaptive card message.
|
|
2792
2866
|
*
|
|
2793
2867
|
* @param card - the adaptive card raw JSON.
|
|
2868
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2869
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2794
2870
|
* @returns the response of sending adaptive card message.
|
|
2795
2871
|
*/
|
|
2796
|
-
async sendAdaptiveCard(card) {
|
|
2872
|
+
async sendAdaptiveCard(card, onError) {
|
|
2797
2873
|
const response = {};
|
|
2798
2874
|
await this.adapter.continueConversation(this.conversationReference, async (context) => {
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2875
|
+
try {
|
|
2876
|
+
const res = await context.sendActivity({
|
|
2877
|
+
attachments: [CardFactory.adaptiveCard(card)],
|
|
2878
|
+
});
|
|
2879
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2880
|
+
}
|
|
2881
|
+
catch (error) {
|
|
2882
|
+
if (onError) {
|
|
2883
|
+
await onError(context, error);
|
|
2884
|
+
}
|
|
2885
|
+
else {
|
|
2886
|
+
throw error;
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2803
2889
|
});
|
|
2804
2890
|
return response;
|
|
2805
2891
|
}
|
|
@@ -2945,6 +3031,7 @@ class NotificationBot {
|
|
|
2945
3031
|
}
|
|
2946
3032
|
/**
|
|
2947
3033
|
* Returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
|
3034
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise undefined will be returned.)
|
|
2948
3035
|
*
|
|
2949
3036
|
* @param predicate find calls predicate once for each channel of the installation,
|
|
2950
3037
|
* until it finds one where predicate returns true. If such a channel is found, find
|
|
@@ -2987,6 +3074,7 @@ class NotificationBot {
|
|
|
2987
3074
|
}
|
|
2988
3075
|
/**
|
|
2989
3076
|
* Returns all {@link Channel} where predicate is true, and empty array otherwise.
|
|
3077
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise empty array will be returned.)
|
|
2990
3078
|
*
|
|
2991
3079
|
* @param predicate find calls predicate for each channel of the installation.
|
|
2992
3080
|
* @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
|