@posiwise/common-services 0.1.48 → 0.1.50
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/esm2022/lib/common.service.mjs +3 -3
- package/esm2022/lib/permission.service.mjs +23 -14
- package/esm2022/lib/sentry.service.mjs +6 -3
- package/esm2022/lib/subscription.service.mjs +3 -3
- package/fesm2022/posiwise-common-services.mjs +31 -19
- package/fesm2022/posiwise-common-services.mjs.map +1 -1
- package/lib/common.service.d.ts +1 -1
- package/lib/permission.service.d.ts +2 -0
- package/lib/sentry.service.d.ts +1 -1
- package/lib/subscription.service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -877,18 +877,7 @@ class PermissionService {
|
|
|
877
877
|
return true;
|
|
878
878
|
}
|
|
879
879
|
if (permissionName) {
|
|
880
|
-
|
|
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 => {
|
|
@@ -983,7 +987,6 @@ class PermissionService {
|
|
|
983
987
|
}
|
|
984
988
|
// eslint-disable-next-line no-eval
|
|
985
989
|
// NOSONAR: Trusted eval function is handled safely here
|
|
986
|
-
console.log('eval(expr)', eval(expr));
|
|
987
990
|
return eval(expr); // NOSONAR
|
|
988
991
|
}
|
|
989
992
|
getPermissionByRole(roleId) {
|
|
@@ -1035,6 +1038,12 @@ class PermissionService {
|
|
|
1035
1038
|
return (!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`] ||
|
|
1036
1039
|
!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperOwner`]);
|
|
1037
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
|
+
}
|
|
1038
1047
|
/**
|
|
1039
1048
|
* Any Product Admin of the product being the master product
|
|
1040
1049
|
*/
|
|
@@ -1354,8 +1363,8 @@ class SubscriptionService {
|
|
|
1354
1363
|
updateCardDetails(data, subscription_id) {
|
|
1355
1364
|
return this.api.post(`/subscriptions/${subscription_id}/update_card`, data);
|
|
1356
1365
|
}
|
|
1357
|
-
getEnterpriseInsight(subscriptionId) {
|
|
1358
|
-
return this.api.
|
|
1366
|
+
getEnterpriseInsight(subscriptionId, starting_at, ending_at) {
|
|
1367
|
+
return this.api.getWithParams(`/subscriptions/${subscriptionId}/enterprise_analytics?type=summary`, { starting_at, ending_at });
|
|
1359
1368
|
}
|
|
1360
1369
|
postSubscriptionCredential(data) {
|
|
1361
1370
|
return this.api.post(`/subscription_credentials`, data);
|
|
@@ -1612,10 +1621,10 @@ class CommonService {
|
|
|
1612
1621
|
...HelperService.getPagingParams(paging)
|
|
1613
1622
|
});
|
|
1614
1623
|
}
|
|
1615
|
-
getIncidentsAdmin(paging,
|
|
1624
|
+
getIncidentsAdmin(paging, subscriptionId) {
|
|
1616
1625
|
return this.api.getWithParams(`${INCIDENTS_PATH_ADMIN}/get_all`, {
|
|
1617
1626
|
...HelperService.getPagingParams(paging),
|
|
1618
|
-
subscription_id:
|
|
1627
|
+
subscription_id: subscriptionId
|
|
1619
1628
|
});
|
|
1620
1629
|
}
|
|
1621
1630
|
addIncident(data) {
|
|
@@ -2537,7 +2546,7 @@ class SentryErrorHandler {
|
|
|
2537
2546
|
// Ensure all errors have a proper message
|
|
2538
2547
|
this.errorMessageFormatter(error);
|
|
2539
2548
|
// Existing Sentry initialization logic
|
|
2540
|
-
this.
|
|
2549
|
+
this.sentryInitialization(error, incomingError);
|
|
2541
2550
|
}
|
|
2542
2551
|
handleNonHttpErrorResponse(error) {
|
|
2543
2552
|
if (typeof error === 'object' && 'message' in error) {
|
|
@@ -2561,7 +2570,7 @@ class SentryErrorHandler {
|
|
|
2561
2570
|
error = new Error(enhancedErrorMessage); // NOSONAR
|
|
2562
2571
|
}
|
|
2563
2572
|
}
|
|
2564
|
-
|
|
2573
|
+
sentryInitialization(error, incomingError) {
|
|
2565
2574
|
if (!SentryErrorHandler.sentryInitialized) {
|
|
2566
2575
|
this.initializeSentryAsync()
|
|
2567
2576
|
.then(() => {
|
|
@@ -2606,6 +2615,9 @@ class SentryErrorHandler {
|
|
|
2606
2615
|
});
|
|
2607
2616
|
}
|
|
2608
2617
|
handleNonStandardError(error) {
|
|
2618
|
+
if ('isTrusted' in error) {
|
|
2619
|
+
return;
|
|
2620
|
+
}
|
|
2609
2621
|
// If it's an object but not a standard Error, attempt to log its properties safely
|
|
2610
2622
|
let errorMessage = 'Captured non-standard error with no message'; // NOSONAR
|
|
2611
2623
|
// Try to extract any message-like property safely
|