@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.node.cjs.js
CHANGED
|
@@ -563,7 +563,10 @@ class AppCredential {
|
|
|
563
563
|
*/
|
|
564
564
|
loadAndValidateConfig(config) {
|
|
565
565
|
internalLogger.verbose("Validate authentication configuration");
|
|
566
|
-
if (config.clientId &&
|
|
566
|
+
if (config.clientId &&
|
|
567
|
+
(config.clientSecret || config.certificateContent) &&
|
|
568
|
+
config.tenantId &&
|
|
569
|
+
config.authorityHost) {
|
|
567
570
|
return config;
|
|
568
571
|
}
|
|
569
572
|
const missingValues = [];
|
|
@@ -576,6 +579,9 @@ class AppCredential {
|
|
|
576
579
|
if (!config.tenantId) {
|
|
577
580
|
missingValues.push("tenantId");
|
|
578
581
|
}
|
|
582
|
+
if (!config.authorityHost) {
|
|
583
|
+
missingValues.push("authorityHost");
|
|
584
|
+
}
|
|
579
585
|
const errorMsg = formatString(ErrorMessage.InvalidConfiguration, missingValues.join(", "), "undefined");
|
|
580
586
|
internalLogger.error(errorMsg);
|
|
581
587
|
throw new ErrorWithCode(errorMsg, exports.ErrorCode.InvalidConfiguration);
|
|
@@ -1294,9 +1300,6 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
|
1294
1300
|
if (!this.teamsfx.hasConfig("tenantId")) {
|
|
1295
1301
|
missingConfigurations.push("tenantId");
|
|
1296
1302
|
}
|
|
1297
|
-
if (!this.teamsfx.hasConfig("applicationIdUri")) {
|
|
1298
|
-
missingConfigurations.push("applicationIdUri");
|
|
1299
|
-
}
|
|
1300
1303
|
if (missingConfigurations.length != 0) {
|
|
1301
1304
|
const errorMsg = formatString(ErrorMessage.InvalidConfiguration, missingConfigurations.join(", "), "undefined");
|
|
1302
1305
|
internalLogger.error(errorMsg);
|
|
@@ -1349,9 +1352,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
|
1349
1352
|
internalLogger.verbose("Sign in link: " + signInLink);
|
|
1350
1353
|
const tokenExchangeResource = {
|
|
1351
1354
|
id: uuid.v4(),
|
|
1352
|
-
uri: this.teamsfx.getConfig("applicationIdUri").replace(/\/$/, "") + "/access_as_user",
|
|
1353
1355
|
};
|
|
1354
|
-
internalLogger.verbose("Token exchange resource uri: " + tokenExchangeResource.uri);
|
|
1355
1356
|
return {
|
|
1356
1357
|
signInLink: signInLink,
|
|
1357
1358
|
tokenExchangeResource: tokenExchangeResource,
|
|
@@ -2440,8 +2441,17 @@ function getTargetType(conversationReference) {
|
|
|
2440
2441
|
* @internal
|
|
2441
2442
|
*/
|
|
2442
2443
|
function getTeamsBotInstallationId(context) {
|
|
2443
|
-
var _a, _b, _c
|
|
2444
|
-
|
|
2444
|
+
var _a, _b, _c;
|
|
2445
|
+
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;
|
|
2446
|
+
if (teamId) {
|
|
2447
|
+
return teamId;
|
|
2448
|
+
}
|
|
2449
|
+
// Fallback to use conversation id.
|
|
2450
|
+
// the conversation id is equal to team id only when the bot app is installed into the General channel.
|
|
2451
|
+
if (context.activity.conversation.name === undefined) {
|
|
2452
|
+
return context.activity.conversation.id;
|
|
2453
|
+
}
|
|
2454
|
+
return undefined;
|
|
2445
2455
|
}
|
|
2446
2456
|
|
|
2447
2457
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2675,20 +2685,24 @@ class ConversationReferenceStore {
|
|
|
2675
2685
|
*
|
|
2676
2686
|
* @param target - the notification target.
|
|
2677
2687
|
* @param text - the plain text message.
|
|
2688
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2689
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2678
2690
|
* @returns the response of sending message.
|
|
2679
2691
|
*/
|
|
2680
|
-
function sendMessage(target, text) {
|
|
2681
|
-
return target.sendMessage(text);
|
|
2692
|
+
function sendMessage(target, text, onError) {
|
|
2693
|
+
return target.sendMessage(text, onError);
|
|
2682
2694
|
}
|
|
2683
2695
|
/**
|
|
2684
2696
|
* Send an adaptive card message to a notification target.
|
|
2685
2697
|
*
|
|
2686
2698
|
* @param target - the notification target.
|
|
2687
2699
|
* @param card - the adaptive card raw JSON.
|
|
2700
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2701
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2688
2702
|
* @returns the response of sending adaptive card message.
|
|
2689
2703
|
*/
|
|
2690
|
-
function sendAdaptiveCard(target, card) {
|
|
2691
|
-
return target.sendAdaptiveCard(card);
|
|
2704
|
+
function sendAdaptiveCard(target, card, onError) {
|
|
2705
|
+
return target.sendAdaptiveCard(card, onError);
|
|
2692
2706
|
}
|
|
2693
2707
|
/**
|
|
2694
2708
|
* A {@link NotificationTarget} that represents a team channel.
|
|
@@ -2718,16 +2732,28 @@ class Channel {
|
|
|
2718
2732
|
* Send a plain text message.
|
|
2719
2733
|
*
|
|
2720
2734
|
* @param text - the plain text message.
|
|
2735
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2736
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2721
2737
|
* @returns the response of sending message.
|
|
2722
2738
|
*/
|
|
2723
|
-
sendMessage(text) {
|
|
2739
|
+
sendMessage(text, onError) {
|
|
2724
2740
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2725
2741
|
const response = {};
|
|
2726
2742
|
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2727
2743
|
const conversation = yield this.newConversation(context);
|
|
2728
2744
|
yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2729
|
-
|
|
2730
|
-
|
|
2745
|
+
try {
|
|
2746
|
+
const res = yield ctx.sendActivity(text);
|
|
2747
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2748
|
+
}
|
|
2749
|
+
catch (error) {
|
|
2750
|
+
if (onError) {
|
|
2751
|
+
yield onError(ctx, error);
|
|
2752
|
+
}
|
|
2753
|
+
else {
|
|
2754
|
+
throw error;
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2731
2757
|
}));
|
|
2732
2758
|
}));
|
|
2733
2759
|
return response;
|
|
@@ -2737,18 +2763,30 @@ class Channel {
|
|
|
2737
2763
|
* Send an adaptive card message.
|
|
2738
2764
|
*
|
|
2739
2765
|
* @param card - the adaptive card raw JSON.
|
|
2766
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2767
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2740
2768
|
* @returns the response of sending adaptive card message.
|
|
2741
2769
|
*/
|
|
2742
|
-
sendAdaptiveCard(card) {
|
|
2770
|
+
sendAdaptiveCard(card, onError) {
|
|
2743
2771
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2744
2772
|
const response = {};
|
|
2745
2773
|
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2746
2774
|
const conversation = yield this.newConversation(context);
|
|
2747
2775
|
yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2776
|
+
try {
|
|
2777
|
+
const res = yield ctx.sendActivity({
|
|
2778
|
+
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
|
2779
|
+
});
|
|
2780
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2781
|
+
}
|
|
2782
|
+
catch (error) {
|
|
2783
|
+
if (onError) {
|
|
2784
|
+
yield onError(ctx, error);
|
|
2785
|
+
}
|
|
2786
|
+
else {
|
|
2787
|
+
throw error;
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2752
2790
|
}));
|
|
2753
2791
|
}));
|
|
2754
2792
|
return response;
|
|
@@ -2794,16 +2832,28 @@ class Member {
|
|
|
2794
2832
|
* Send a plain text message.
|
|
2795
2833
|
*
|
|
2796
2834
|
* @param text - the plain text message.
|
|
2835
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2836
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2797
2837
|
* @returns the response of sending message.
|
|
2798
2838
|
*/
|
|
2799
|
-
sendMessage(text) {
|
|
2839
|
+
sendMessage(text, onError) {
|
|
2800
2840
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2801
2841
|
const response = {};
|
|
2802
2842
|
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2803
2843
|
const conversation = yield this.newConversation(context);
|
|
2804
2844
|
yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2805
|
-
|
|
2806
|
-
|
|
2845
|
+
try {
|
|
2846
|
+
const res = yield ctx.sendActivity(text);
|
|
2847
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2848
|
+
}
|
|
2849
|
+
catch (error) {
|
|
2850
|
+
if (onError) {
|
|
2851
|
+
yield onError(ctx, error);
|
|
2852
|
+
}
|
|
2853
|
+
else {
|
|
2854
|
+
throw error;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2807
2857
|
}));
|
|
2808
2858
|
}));
|
|
2809
2859
|
return response;
|
|
@@ -2813,18 +2863,30 @@ class Member {
|
|
|
2813
2863
|
* Send an adaptive card message.
|
|
2814
2864
|
*
|
|
2815
2865
|
* @param card - the adaptive card raw JSON.
|
|
2866
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2867
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2816
2868
|
* @returns the response of sending adaptive card message.
|
|
2817
2869
|
*/
|
|
2818
|
-
sendAdaptiveCard(card) {
|
|
2870
|
+
sendAdaptiveCard(card, onError) {
|
|
2819
2871
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2820
2872
|
const response = {};
|
|
2821
2873
|
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2822
2874
|
const conversation = yield this.newConversation(context);
|
|
2823
2875
|
yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2876
|
+
try {
|
|
2877
|
+
const res = yield ctx.sendActivity({
|
|
2878
|
+
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
|
2879
|
+
});
|
|
2880
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2881
|
+
}
|
|
2882
|
+
catch (error) {
|
|
2883
|
+
if (onError) {
|
|
2884
|
+
yield onError(ctx, error);
|
|
2885
|
+
}
|
|
2886
|
+
else {
|
|
2887
|
+
throw error;
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2828
2890
|
}));
|
|
2829
2891
|
}));
|
|
2830
2892
|
return response;
|
|
@@ -2878,14 +2940,26 @@ class TeamsBotInstallation {
|
|
|
2878
2940
|
* Send a plain text message.
|
|
2879
2941
|
*
|
|
2880
2942
|
* @param text - the plain text message.
|
|
2943
|
+
* @param onError - an optional error handler that can catch exceptions during message sending.
|
|
2944
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2881
2945
|
* @returns the response of sending message.
|
|
2882
2946
|
*/
|
|
2883
|
-
sendMessage(text) {
|
|
2947
|
+
sendMessage(text, onError) {
|
|
2884
2948
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2885
2949
|
const response = {};
|
|
2886
2950
|
yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2887
|
-
|
|
2888
|
-
|
|
2951
|
+
try {
|
|
2952
|
+
const res = yield context.sendActivity(text);
|
|
2953
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2954
|
+
}
|
|
2955
|
+
catch (error) {
|
|
2956
|
+
if (onError) {
|
|
2957
|
+
yield onError(context, error);
|
|
2958
|
+
}
|
|
2959
|
+
else {
|
|
2960
|
+
throw error;
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2889
2963
|
}));
|
|
2890
2964
|
return response;
|
|
2891
2965
|
});
|
|
@@ -2894,16 +2968,28 @@ class TeamsBotInstallation {
|
|
|
2894
2968
|
* Send an adaptive card message.
|
|
2895
2969
|
*
|
|
2896
2970
|
* @param card - the adaptive card raw JSON.
|
|
2971
|
+
* @param onError - an optional error handler that can catch exceptions during adaptive card sending.
|
|
2972
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2897
2973
|
* @returns the response of sending adaptive card message.
|
|
2898
2974
|
*/
|
|
2899
|
-
sendAdaptiveCard(card) {
|
|
2975
|
+
sendAdaptiveCard(card, onError) {
|
|
2900
2976
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2901
2977
|
const response = {};
|
|
2902
2978
|
yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2979
|
+
try {
|
|
2980
|
+
const res = yield context.sendActivity({
|
|
2981
|
+
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
|
2982
|
+
});
|
|
2983
|
+
response.id = res === null || res === void 0 ? void 0 : res.id;
|
|
2984
|
+
}
|
|
2985
|
+
catch (error) {
|
|
2986
|
+
if (onError) {
|
|
2987
|
+
yield onError(context, error);
|
|
2988
|
+
}
|
|
2989
|
+
else {
|
|
2990
|
+
throw error;
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2907
2993
|
}));
|
|
2908
2994
|
return response;
|
|
2909
2995
|
});
|
|
@@ -3060,6 +3146,7 @@ class NotificationBot {
|
|
|
3060
3146
|
}
|
|
3061
3147
|
/**
|
|
3062
3148
|
* Returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
|
3149
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise undefined will be returned.)
|
|
3063
3150
|
*
|
|
3064
3151
|
* @param predicate find calls predicate once for each channel of the installation,
|
|
3065
3152
|
* until it finds one where predicate returns true. If such a channel is found, find
|
|
@@ -3106,6 +3193,7 @@ class NotificationBot {
|
|
|
3106
3193
|
}
|
|
3107
3194
|
/**
|
|
3108
3195
|
* Returns all {@link Channel} where predicate is true, and empty array otherwise.
|
|
3196
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise empty array will be returned.)
|
|
3109
3197
|
*
|
|
3110
3198
|
* @param predicate find calls predicate for each channel of the installation.
|
|
3111
3199
|
* @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
|