@microsoft/teamsfx 1.2.1-alpha.cecbda807.0 → 1.2.1-rc.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.
@@ -563,7 +563,10 @@ class AppCredential {
563
563
  */
564
564
  loadAndValidateConfig(config) {
565
565
  internalLogger.verbose("Validate authentication configuration");
566
- if (config.clientId && (config.clientSecret || config.certificateContent) && config.tenantId) {
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,
@@ -2675,20 +2676,24 @@ class ConversationReferenceStore {
2675
2676
  *
2676
2677
  * @param target - the notification target.
2677
2678
  * @param text - the plain text message.
2679
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2680
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2678
2681
  * @returns the response of sending message.
2679
2682
  */
2680
- function sendMessage(target, text) {
2681
- return target.sendMessage(text);
2683
+ function sendMessage(target, text, onError) {
2684
+ return target.sendMessage(text, onError);
2682
2685
  }
2683
2686
  /**
2684
2687
  * Send an adaptive card message to a notification target.
2685
2688
  *
2686
2689
  * @param target - the notification target.
2687
2690
  * @param card - the adaptive card raw JSON.
2691
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2692
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2688
2693
  * @returns the response of sending adaptive card message.
2689
2694
  */
2690
- function sendAdaptiveCard(target, card) {
2691
- return target.sendAdaptiveCard(card);
2695
+ function sendAdaptiveCard(target, card, onError) {
2696
+ return target.sendAdaptiveCard(card, onError);
2692
2697
  }
2693
2698
  /**
2694
2699
  * A {@link NotificationTarget} that represents a team channel.
@@ -2718,16 +2723,28 @@ class Channel {
2718
2723
  * Send a plain text message.
2719
2724
  *
2720
2725
  * @param text - the plain text message.
2726
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2727
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2721
2728
  * @returns the response of sending message.
2722
2729
  */
2723
- sendMessage(text) {
2730
+ sendMessage(text, onError) {
2724
2731
  return tslib.__awaiter(this, void 0, void 0, function* () {
2725
2732
  const response = {};
2726
2733
  yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2727
2734
  const conversation = yield this.newConversation(context);
2728
2735
  yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
2729
- const res = yield ctx.sendActivity(text);
2730
- response.id = res === null || res === void 0 ? void 0 : res.id;
2736
+ try {
2737
+ const res = yield ctx.sendActivity(text);
2738
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2739
+ }
2740
+ catch (error) {
2741
+ if (onError) {
2742
+ yield onError(ctx, error);
2743
+ }
2744
+ else {
2745
+ throw error;
2746
+ }
2747
+ }
2731
2748
  }));
2732
2749
  }));
2733
2750
  return response;
@@ -2737,18 +2754,30 @@ class Channel {
2737
2754
  * Send an adaptive card message.
2738
2755
  *
2739
2756
  * @param card - the adaptive card raw JSON.
2757
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2758
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2740
2759
  * @returns the response of sending adaptive card message.
2741
2760
  */
2742
- sendAdaptiveCard(card) {
2761
+ sendAdaptiveCard(card, onError) {
2743
2762
  return tslib.__awaiter(this, void 0, void 0, function* () {
2744
2763
  const response = {};
2745
2764
  yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2746
2765
  const conversation = yield this.newConversation(context);
2747
2766
  yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
2748
- const res = yield ctx.sendActivity({
2749
- attachments: [botbuilder.CardFactory.adaptiveCard(card)],
2750
- });
2751
- response.id = res === null || res === void 0 ? void 0 : res.id;
2767
+ try {
2768
+ const res = yield ctx.sendActivity({
2769
+ attachments: [botbuilder.CardFactory.adaptiveCard(card)],
2770
+ });
2771
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2772
+ }
2773
+ catch (error) {
2774
+ if (onError) {
2775
+ yield onError(ctx, error);
2776
+ }
2777
+ else {
2778
+ throw error;
2779
+ }
2780
+ }
2752
2781
  }));
2753
2782
  }));
2754
2783
  return response;
@@ -2794,16 +2823,28 @@ class Member {
2794
2823
  * Send a plain text message.
2795
2824
  *
2796
2825
  * @param text - the plain text message.
2826
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2827
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2797
2828
  * @returns the response of sending message.
2798
2829
  */
2799
- sendMessage(text) {
2830
+ sendMessage(text, onError) {
2800
2831
  return tslib.__awaiter(this, void 0, void 0, function* () {
2801
2832
  const response = {};
2802
2833
  yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2803
2834
  const conversation = yield this.newConversation(context);
2804
2835
  yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
2805
- const res = yield ctx.sendActivity(text);
2806
- response.id = res === null || res === void 0 ? void 0 : res.id;
2836
+ try {
2837
+ const res = yield ctx.sendActivity(text);
2838
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2839
+ }
2840
+ catch (error) {
2841
+ if (onError) {
2842
+ yield onError(ctx, error);
2843
+ }
2844
+ else {
2845
+ throw error;
2846
+ }
2847
+ }
2807
2848
  }));
2808
2849
  }));
2809
2850
  return response;
@@ -2813,18 +2854,30 @@ class Member {
2813
2854
  * Send an adaptive card message.
2814
2855
  *
2815
2856
  * @param card - the adaptive card raw JSON.
2857
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2858
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2816
2859
  * @returns the response of sending adaptive card message.
2817
2860
  */
2818
- sendAdaptiveCard(card) {
2861
+ sendAdaptiveCard(card, onError) {
2819
2862
  return tslib.__awaiter(this, void 0, void 0, function* () {
2820
2863
  const response = {};
2821
2864
  yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2822
2865
  const conversation = yield this.newConversation(context);
2823
2866
  yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
2824
- const res = yield ctx.sendActivity({
2825
- attachments: [botbuilder.CardFactory.adaptiveCard(card)],
2826
- });
2827
- response.id = res === null || res === void 0 ? void 0 : res.id;
2867
+ try {
2868
+ const res = yield ctx.sendActivity({
2869
+ attachments: [botbuilder.CardFactory.adaptiveCard(card)],
2870
+ });
2871
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2872
+ }
2873
+ catch (error) {
2874
+ if (onError) {
2875
+ yield onError(ctx, error);
2876
+ }
2877
+ else {
2878
+ throw error;
2879
+ }
2880
+ }
2828
2881
  }));
2829
2882
  }));
2830
2883
  return response;
@@ -2878,14 +2931,26 @@ class TeamsBotInstallation {
2878
2931
  * Send a plain text message.
2879
2932
  *
2880
2933
  * @param text - the plain text message.
2934
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2935
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2881
2936
  * @returns the response of sending message.
2882
2937
  */
2883
- sendMessage(text) {
2938
+ sendMessage(text, onError) {
2884
2939
  return tslib.__awaiter(this, void 0, void 0, function* () {
2885
2940
  const response = {};
2886
2941
  yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2887
- const res = yield context.sendActivity(text);
2888
- response.id = res === null || res === void 0 ? void 0 : res.id;
2942
+ try {
2943
+ const res = yield context.sendActivity(text);
2944
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2945
+ }
2946
+ catch (error) {
2947
+ if (onError) {
2948
+ yield onError(context, error);
2949
+ }
2950
+ else {
2951
+ throw error;
2952
+ }
2953
+ }
2889
2954
  }));
2890
2955
  return response;
2891
2956
  });
@@ -2894,16 +2959,28 @@ class TeamsBotInstallation {
2894
2959
  * Send an adaptive card message.
2895
2960
  *
2896
2961
  * @param card - the adaptive card raw JSON.
2962
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2963
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2897
2964
  * @returns the response of sending adaptive card message.
2898
2965
  */
2899
- sendAdaptiveCard(card) {
2966
+ sendAdaptiveCard(card, onError) {
2900
2967
  return tslib.__awaiter(this, void 0, void 0, function* () {
2901
2968
  const response = {};
2902
2969
  yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2903
- const res = yield context.sendActivity({
2904
- attachments: [botbuilder.CardFactory.adaptiveCard(card)],
2905
- });
2906
- response.id = res === null || res === void 0 ? void 0 : res.id;
2970
+ try {
2971
+ const res = yield context.sendActivity({
2972
+ attachments: [botbuilder.CardFactory.adaptiveCard(card)],
2973
+ });
2974
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2975
+ }
2976
+ catch (error) {
2977
+ if (onError) {
2978
+ yield onError(context, error);
2979
+ }
2980
+ else {
2981
+ throw error;
2982
+ }
2983
+ }
2907
2984
  }));
2908
2985
  return response;
2909
2986
  });