@posiwise/common-services 0.1.49 → 0.1.51

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.
@@ -877,18 +877,7 @@ class PermissionService {
877
877
  return true;
878
878
  }
879
879
  if (permissionName) {
880
- const selectedProduct = PermissionService?.selectedProduct || this.getCurrentProduct();
881
- const subscriptionSlug = selectedProduct?.subscription_slug;
882
- let slugToCheck;
883
- if (!productSlug) {
884
- slugToCheck = `Pages.Product.${subscriptionSlug}.`;
885
- }
886
- else {
887
- slugToCheck = productSlug;
888
- }
889
- if (!permissionName.includes(slugToCheck)) {
890
- permissionName = permissionName.replace('Pages.Product.', slugToCheck);
891
- }
880
+ permissionName = this.getFormattedPermissionName(permissionName, productSlug);
892
881
  }
893
882
  // Returning true if user has a given permission
894
883
  // E.g., Pages.Role.CloudOlive.SalesManager
@@ -915,6 +904,21 @@ class PermissionService {
915
904
  // user not logged-in
916
905
  return false;
917
906
  }
907
+ getFormattedPermissionName(permissionName, productSlug) {
908
+ const selectedProduct = PermissionService?.selectedProduct || this.getCurrentProduct();
909
+ const subscriptionSlug = selectedProduct?.subscription_slug;
910
+ let slugToCheck;
911
+ if (!productSlug) {
912
+ slugToCheck = `Pages.Product.${subscriptionSlug}.`;
913
+ }
914
+ else {
915
+ slugToCheck = productSlug;
916
+ }
917
+ if (!permissionName.includes(slugToCheck)) {
918
+ permissionName = permissionName.replace('Pages.Product.', slugToCheck);
919
+ }
920
+ return permissionName;
921
+ }
918
922
  getPermissionTreeDataByRole(data) {
919
923
  const permissions = [];
920
924
  data.all.forEach(element => {
@@ -1034,6 +1038,12 @@ class PermissionService {
1034
1038
  return (!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`] ||
1035
1039
  !!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperOwner`]);
1036
1040
  }
1041
+ isUserMasterSubscriptionSuperAdmin(product) {
1042
+ if (!product) {
1043
+ product = this.getCurrentProduct();
1044
+ }
1045
+ return !!this.user.auth.granted[`Pages.Product.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`];
1046
+ }
1037
1047
  /**
1038
1048
  * Any Product Admin of the product being the master product
1039
1049
  */
@@ -1353,8 +1363,8 @@ class SubscriptionService {
1353
1363
  updateCardDetails(data, subscription_id) {
1354
1364
  return this.api.post(`/subscriptions/${subscription_id}/update_card`, data);
1355
1365
  }
1356
- getEnterpriseInsight(subscriptionId) {
1357
- return this.api.get(`/subscriptions/${subscriptionId}/enterprise_analytics?type=summary`);
1366
+ getEnterpriseInsight(subscriptionId, starting_at, ending_at) {
1367
+ return this.api.getWithParams(`/subscriptions/${subscriptionId}/enterprise_analytics?type=summary`, { starting_at, ending_at });
1358
1368
  }
1359
1369
  postSubscriptionCredential(data) {
1360
1370
  return this.api.post(`/subscription_credentials`, data);
@@ -1611,10 +1621,10 @@ class CommonService {
1611
1621
  ...HelperService.getPagingParams(paging)
1612
1622
  });
1613
1623
  }
1614
- getIncidentsAdmin(paging, subsriptionId) {
1624
+ getIncidentsAdmin(paging, subscriptionId) {
1615
1625
  return this.api.getWithParams(`${INCIDENTS_PATH_ADMIN}/get_all`, {
1616
1626
  ...HelperService.getPagingParams(paging),
1617
- subscription_id: subsriptionId
1627
+ subscription_id: subscriptionId
1618
1628
  });
1619
1629
  }
1620
1630
  addIncident(data) {
@@ -2536,7 +2546,7 @@ class SentryErrorHandler {
2536
2546
  // Ensure all errors have a proper message
2537
2547
  this.errorMessageFormatter(error);
2538
2548
  // Existing Sentry initialization logic
2539
- this.sentryIntilization(error, incomingError);
2549
+ this.sentryInitialization(error, incomingError);
2540
2550
  }
2541
2551
  handleNonHttpErrorResponse(error) {
2542
2552
  if (typeof error === 'object' && 'message' in error) {
@@ -2560,7 +2570,7 @@ class SentryErrorHandler {
2560
2570
  error = new Error(enhancedErrorMessage); // NOSONAR
2561
2571
  }
2562
2572
  }
2563
- sentryIntilization(error, incomingError) {
2573
+ sentryInitialization(error, incomingError) {
2564
2574
  if (!SentryErrorHandler.sentryInitialized) {
2565
2575
  this.initializeSentryAsync()
2566
2576
  .then(() => {
@@ -2605,6 +2615,9 @@ class SentryErrorHandler {
2605
2615
  });
2606
2616
  }
2607
2617
  handleNonStandardError(error) {
2618
+ if ('isTrusted' in error) {
2619
+ return;
2620
+ }
2608
2621
  // If it's an object but not a standard Error, attempt to log its properties safely
2609
2622
  let errorMessage = 'Captured non-standard error with no message'; // NOSONAR
2610
2623
  // Try to extract any message-like property safely