@microsoft/teamsfx 1.2.1-alpha.4c6d4fda8.0 → 1.2.1-alpha.68dc011f1.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.
@@ -532,7 +532,10 @@ class AppCredential {
532
532
  */
533
533
  loadAndValidateConfig(config) {
534
534
  internalLogger.verbose("Validate authentication configuration");
535
- if (config.clientId && (config.clientSecret || config.certificateContent) && config.tenantId) {
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);
@@ -2586,20 +2592,24 @@ class ConversationReferenceStore {
2586
2592
  *
2587
2593
  * @param target - the notification target.
2588
2594
  * @param text - the plain text message.
2595
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2596
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2589
2597
  * @returns the response of sending message.
2590
2598
  */
2591
- function sendMessage(target, text) {
2592
- return target.sendMessage(text);
2599
+ function sendMessage(target, text, onError) {
2600
+ return target.sendMessage(text, onError);
2593
2601
  }
2594
2602
  /**
2595
2603
  * Send an adaptive card message to a notification target.
2596
2604
  *
2597
2605
  * @param target - the notification target.
2598
2606
  * @param card - the adaptive card raw JSON.
2607
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2608
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2599
2609
  * @returns the response of sending adaptive card message.
2600
2610
  */
2601
- function sendAdaptiveCard(target, card) {
2602
- return target.sendAdaptiveCard(card);
2611
+ function sendAdaptiveCard(target, card, onError) {
2612
+ return target.sendAdaptiveCard(card, onError);
2603
2613
  }
2604
2614
  /**
2605
2615
  * A {@link NotificationTarget} that represents a team channel.
@@ -2629,15 +2639,27 @@ class Channel {
2629
2639
  * Send a plain text message.
2630
2640
  *
2631
2641
  * @param text - the plain text message.
2642
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2643
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2632
2644
  * @returns the response of sending message.
2633
2645
  */
2634
- async sendMessage(text) {
2646
+ async sendMessage(text, onError) {
2635
2647
  const response = {};
2636
2648
  await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
2637
2649
  const conversation = await this.newConversation(context);
2638
2650
  await this.parent.adapter.continueConversation(conversation, async (ctx) => {
2639
- const res = await ctx.sendActivity(text);
2640
- response.id = res === null || res === void 0 ? void 0 : res.id;
2651
+ try {
2652
+ const res = await ctx.sendActivity(text);
2653
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2654
+ }
2655
+ catch (error) {
2656
+ if (onError) {
2657
+ await onError(ctx, error);
2658
+ }
2659
+ else {
2660
+ throw error;
2661
+ }
2662
+ }
2641
2663
  });
2642
2664
  });
2643
2665
  return response;
@@ -2646,17 +2668,29 @@ class Channel {
2646
2668
  * Send an adaptive card message.
2647
2669
  *
2648
2670
  * @param card - the adaptive card raw JSON.
2671
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2672
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2649
2673
  * @returns the response of sending adaptive card message.
2650
2674
  */
2651
- async sendAdaptiveCard(card) {
2675
+ async sendAdaptiveCard(card, onError) {
2652
2676
  const response = {};
2653
2677
  await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
2654
2678
  const conversation = await this.newConversation(context);
2655
2679
  await this.parent.adapter.continueConversation(conversation, async (ctx) => {
2656
- const res = await ctx.sendActivity({
2657
- attachments: [CardFactory.adaptiveCard(card)],
2658
- });
2659
- response.id = res === null || res === void 0 ? void 0 : res.id;
2680
+ try {
2681
+ const res = await ctx.sendActivity({
2682
+ attachments: [CardFactory.adaptiveCard(card)],
2683
+ });
2684
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2685
+ }
2686
+ catch (error) {
2687
+ if (onError) {
2688
+ await onError(ctx, error);
2689
+ }
2690
+ else {
2691
+ throw error;
2692
+ }
2693
+ }
2660
2694
  });
2661
2695
  });
2662
2696
  return response;
@@ -2699,15 +2733,27 @@ class Member {
2699
2733
  * Send a plain text message.
2700
2734
  *
2701
2735
  * @param text - the plain text message.
2736
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2737
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2702
2738
  * @returns the response of sending message.
2703
2739
  */
2704
- async sendMessage(text) {
2740
+ async sendMessage(text, onError) {
2705
2741
  const response = {};
2706
2742
  await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
2707
2743
  const conversation = await this.newConversation(context);
2708
2744
  await this.parent.adapter.continueConversation(conversation, async (ctx) => {
2709
- const res = await ctx.sendActivity(text);
2710
- response.id = res === null || res === void 0 ? void 0 : res.id;
2745
+ try {
2746
+ const res = await ctx.sendActivity(text);
2747
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2748
+ }
2749
+ catch (error) {
2750
+ if (onError) {
2751
+ await onError(ctx, error);
2752
+ }
2753
+ else {
2754
+ throw error;
2755
+ }
2756
+ }
2711
2757
  });
2712
2758
  });
2713
2759
  return response;
@@ -2716,17 +2762,29 @@ class Member {
2716
2762
  * Send an adaptive card message.
2717
2763
  *
2718
2764
  * @param card - the adaptive card raw JSON.
2765
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2766
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2719
2767
  * @returns the response of sending adaptive card message.
2720
2768
  */
2721
- async sendAdaptiveCard(card) {
2769
+ async sendAdaptiveCard(card, onError) {
2722
2770
  const response = {};
2723
2771
  await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
2724
2772
  const conversation = await this.newConversation(context);
2725
2773
  await this.parent.adapter.continueConversation(conversation, async (ctx) => {
2726
- const res = await ctx.sendActivity({
2727
- attachments: [CardFactory.adaptiveCard(card)],
2728
- });
2729
- response.id = res === null || res === void 0 ? void 0 : res.id;
2774
+ try {
2775
+ const res = await ctx.sendActivity({
2776
+ attachments: [CardFactory.adaptiveCard(card)],
2777
+ });
2778
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2779
+ }
2780
+ catch (error) {
2781
+ if (onError) {
2782
+ await onError(ctx, error);
2783
+ }
2784
+ else {
2785
+ throw error;
2786
+ }
2787
+ }
2730
2788
  });
2731
2789
  });
2732
2790
  return response;
@@ -2777,13 +2835,25 @@ class TeamsBotInstallation {
2777
2835
  * Send a plain text message.
2778
2836
  *
2779
2837
  * @param text - the plain text message.
2838
+ * @param onError - an optional error handler that can catch exceptions during message sending.
2839
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2780
2840
  * @returns the response of sending message.
2781
2841
  */
2782
- async sendMessage(text) {
2842
+ async sendMessage(text, onError) {
2783
2843
  const response = {};
2784
2844
  await this.adapter.continueConversation(this.conversationReference, async (context) => {
2785
- const res = await context.sendActivity(text);
2786
- response.id = res === null || res === void 0 ? void 0 : res.id;
2845
+ try {
2846
+ const res = await context.sendActivity(text);
2847
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2848
+ }
2849
+ catch (error) {
2850
+ if (onError) {
2851
+ await onError(context, error);
2852
+ }
2853
+ else {
2854
+ throw error;
2855
+ }
2856
+ }
2787
2857
  });
2788
2858
  return response;
2789
2859
  }
@@ -2791,15 +2861,27 @@ class TeamsBotInstallation {
2791
2861
  * Send an adaptive card message.
2792
2862
  *
2793
2863
  * @param card - the adaptive card raw JSON.
2864
+ * @param onError - an optional error handler that can catch exceptions during adaptive card sending.
2865
+ * If not defined, error will be handled by `BotAdapter.onTurnError`.
2794
2866
  * @returns the response of sending adaptive card message.
2795
2867
  */
2796
- async sendAdaptiveCard(card) {
2868
+ async sendAdaptiveCard(card, onError) {
2797
2869
  const response = {};
2798
2870
  await this.adapter.continueConversation(this.conversationReference, async (context) => {
2799
- const res = await context.sendActivity({
2800
- attachments: [CardFactory.adaptiveCard(card)],
2801
- });
2802
- response.id = res === null || res === void 0 ? void 0 : res.id;
2871
+ try {
2872
+ const res = await context.sendActivity({
2873
+ attachments: [CardFactory.adaptiveCard(card)],
2874
+ });
2875
+ response.id = res === null || res === void 0 ? void 0 : res.id;
2876
+ }
2877
+ catch (error) {
2878
+ if (onError) {
2879
+ await onError(context, error);
2880
+ }
2881
+ else {
2882
+ throw error;
2883
+ }
2884
+ }
2803
2885
  });
2804
2886
  return response;
2805
2887
  }