av6-core 1.8.7 → 1.9.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.js CHANGED
@@ -2601,7 +2601,7 @@ var ApprovalService = class {
2601
2601
  }
2602
2602
  });
2603
2603
  setImmediate(
2604
- () => this.emitEvents({
2604
+ async () => await this.emitEvents({
2605
2605
  instance: updated,
2606
2606
  flowType: inst.flow?.flowType,
2607
2607
  approverId,
@@ -2712,60 +2712,68 @@ var ApprovalService = class {
2712
2712
  service: instance.service
2713
2713
  });
2714
2714
  } else {
2715
- const client = externalInterceptor();
2716
- switch (instance.status) {
2717
- case "APPROVED" /* APPROVED */:
2718
- if (approvalFlow.approveActionUrl) {
2719
- const res = await client.post(
2720
- approvalFlow.approveActionUrl,
2721
- { id: instance.id, subjectId: instance.subjectId },
2722
- {
2723
- validateStatus: (s) => s === 200 || s === 404
2724
- }
2725
- );
2726
- if (res.status !== 200) {
2727
- this.deps.logger.error(
2728
- "[Approval Service] Approve action URL webhook failed",
2729
- res.status,
2730
- res.statusText
2715
+ try {
2716
+ const client = externalInterceptor();
2717
+ switch (instance.status) {
2718
+ case "APPROVED" /* APPROVED */:
2719
+ if (approvalFlow.approveActionUrl) {
2720
+ const res = await client.post(
2721
+ approvalFlow.approveActionUrl,
2722
+ { id: instance.id, subjectId: instance.subjectId },
2723
+ {
2724
+ validateStatus: (s) => s === 200 || s === 404
2725
+ }
2731
2726
  );
2732
- }
2733
- }
2734
- break;
2735
- case "REJECTED" /* REJECTED */:
2736
- if (approvalFlow.rejectActionUrl) {
2737
- const res = await client.post(
2738
- approvalFlow.rejectActionUrl,
2739
- { id: instance.id, subjectId: instance.subjectId },
2740
- {
2741
- validateStatus: (s) => s === 200 || s === 404
2727
+ if (res.status !== 200) {
2728
+ this.deps.logger.error(
2729
+ "[Approval Service] Approve action URL webhook failed",
2730
+ res.status,
2731
+ res.statusText
2732
+ );
2742
2733
  }
2743
- );
2744
- if (res.status !== 200) {
2745
- this.deps.logger.error("[Approval Service] Reject action URL webhook failed", res.status, res.statusText);
2746
2734
  }
2747
- }
2748
- break;
2749
- case "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */:
2750
- if (approvalFlow.partiallyApproveActionUrl) {
2751
- const res = await client.post(
2752
- approvalFlow.partiallyApproveActionUrl,
2753
- { id: instance.id, subjectId: instance.subjectId },
2754
- {
2755
- validateStatus: (s) => s === 200 || s === 404
2735
+ break;
2736
+ case "REJECTED" /* REJECTED */:
2737
+ if (approvalFlow.rejectActionUrl) {
2738
+ const res = await client.post(
2739
+ approvalFlow.rejectActionUrl,
2740
+ { id: instance.id, subjectId: instance.subjectId },
2741
+ {
2742
+ validateStatus: (s) => s === 200 || s === 404
2743
+ }
2744
+ );
2745
+ if (res.status !== 200) {
2746
+ this.deps.logger.error(
2747
+ "[Approval Service] Reject action URL webhook failed",
2748
+ res.status,
2749
+ res.statusText
2750
+ );
2756
2751
  }
2757
- );
2758
- if (res.status !== 200) {
2759
- this.deps.logger.error(
2760
- "[Approval Service] Partially approve action URL webhook failed",
2761
- res.status,
2762
- res.statusText
2752
+ }
2753
+ break;
2754
+ case "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */:
2755
+ if (approvalFlow.partiallyApproveActionUrl) {
2756
+ const res = await client.post(
2757
+ approvalFlow.partiallyApproveActionUrl,
2758
+ { id: instance.id, subjectId: instance.subjectId },
2759
+ {
2760
+ validateStatus: (s) => s === 200 || s === 404
2761
+ }
2763
2762
  );
2763
+ if (res.status !== 200) {
2764
+ this.deps.logger.error(
2765
+ "[Approval Service] Partially approve action URL webhook failed",
2766
+ res.status,
2767
+ res.statusText
2768
+ );
2769
+ }
2764
2770
  }
2765
- }
2766
- break;
2767
- default:
2768
- break;
2771
+ break;
2772
+ default:
2773
+ break;
2774
+ }
2775
+ } catch (error) {
2776
+ this.deps.logger.error("[Approval Service] Error emitting events", error);
2769
2777
  }
2770
2778
  }
2771
2779
  }
package/dist/index.mjs CHANGED
@@ -2538,7 +2538,7 @@ var ApprovalService = class {
2538
2538
  }
2539
2539
  });
2540
2540
  setImmediate(
2541
- () => this.emitEvents({
2541
+ async () => await this.emitEvents({
2542
2542
  instance: updated,
2543
2543
  flowType: inst.flow?.flowType,
2544
2544
  approverId,
@@ -2649,60 +2649,68 @@ var ApprovalService = class {
2649
2649
  service: instance.service
2650
2650
  });
2651
2651
  } else {
2652
- const client = externalInterceptor();
2653
- switch (instance.status) {
2654
- case "APPROVED" /* APPROVED */:
2655
- if (approvalFlow.approveActionUrl) {
2656
- const res = await client.post(
2657
- approvalFlow.approveActionUrl,
2658
- { id: instance.id, subjectId: instance.subjectId },
2659
- {
2660
- validateStatus: (s) => s === 200 || s === 404
2661
- }
2662
- );
2663
- if (res.status !== 200) {
2664
- this.deps.logger.error(
2665
- "[Approval Service] Approve action URL webhook failed",
2666
- res.status,
2667
- res.statusText
2652
+ try {
2653
+ const client = externalInterceptor();
2654
+ switch (instance.status) {
2655
+ case "APPROVED" /* APPROVED */:
2656
+ if (approvalFlow.approveActionUrl) {
2657
+ const res = await client.post(
2658
+ approvalFlow.approveActionUrl,
2659
+ { id: instance.id, subjectId: instance.subjectId },
2660
+ {
2661
+ validateStatus: (s) => s === 200 || s === 404
2662
+ }
2668
2663
  );
2669
- }
2670
- }
2671
- break;
2672
- case "REJECTED" /* REJECTED */:
2673
- if (approvalFlow.rejectActionUrl) {
2674
- const res = await client.post(
2675
- approvalFlow.rejectActionUrl,
2676
- { id: instance.id, subjectId: instance.subjectId },
2677
- {
2678
- validateStatus: (s) => s === 200 || s === 404
2664
+ if (res.status !== 200) {
2665
+ this.deps.logger.error(
2666
+ "[Approval Service] Approve action URL webhook failed",
2667
+ res.status,
2668
+ res.statusText
2669
+ );
2679
2670
  }
2680
- );
2681
- if (res.status !== 200) {
2682
- this.deps.logger.error("[Approval Service] Reject action URL webhook failed", res.status, res.statusText);
2683
2671
  }
2684
- }
2685
- break;
2686
- case "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */:
2687
- if (approvalFlow.partiallyApproveActionUrl) {
2688
- const res = await client.post(
2689
- approvalFlow.partiallyApproveActionUrl,
2690
- { id: instance.id, subjectId: instance.subjectId },
2691
- {
2692
- validateStatus: (s) => s === 200 || s === 404
2672
+ break;
2673
+ case "REJECTED" /* REJECTED */:
2674
+ if (approvalFlow.rejectActionUrl) {
2675
+ const res = await client.post(
2676
+ approvalFlow.rejectActionUrl,
2677
+ { id: instance.id, subjectId: instance.subjectId },
2678
+ {
2679
+ validateStatus: (s) => s === 200 || s === 404
2680
+ }
2681
+ );
2682
+ if (res.status !== 200) {
2683
+ this.deps.logger.error(
2684
+ "[Approval Service] Reject action URL webhook failed",
2685
+ res.status,
2686
+ res.statusText
2687
+ );
2693
2688
  }
2694
- );
2695
- if (res.status !== 200) {
2696
- this.deps.logger.error(
2697
- "[Approval Service] Partially approve action URL webhook failed",
2698
- res.status,
2699
- res.statusText
2689
+ }
2690
+ break;
2691
+ case "PARTIALLY_APPROVED" /* PARTIALLY_APPROVED */:
2692
+ if (approvalFlow.partiallyApproveActionUrl) {
2693
+ const res = await client.post(
2694
+ approvalFlow.partiallyApproveActionUrl,
2695
+ { id: instance.id, subjectId: instance.subjectId },
2696
+ {
2697
+ validateStatus: (s) => s === 200 || s === 404
2698
+ }
2700
2699
  );
2700
+ if (res.status !== 200) {
2701
+ this.deps.logger.error(
2702
+ "[Approval Service] Partially approve action URL webhook failed",
2703
+ res.status,
2704
+ res.statusText
2705
+ );
2706
+ }
2701
2707
  }
2702
- }
2703
- break;
2704
- default:
2705
- break;
2708
+ break;
2709
+ default:
2710
+ break;
2711
+ }
2712
+ } catch (error) {
2713
+ this.deps.logger.error("[Approval Service] Error emitting events", error);
2706
2714
  }
2707
2715
  }
2708
2716
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-core",
3
- "version": "1.8.7",
3
+ "version": "1.9.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",