@posiwise/common-services 0.1.42 → 0.1.44
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 +43 -11
- package/esm2022/lib/sentry.service.mjs +6 -3
- package/fesm2022/posiwise-common-services.mjs +49 -14
- package/fesm2022/posiwise-common-services.mjs.map +1 -1
- package/lib/common.service.d.ts +1 -1
- package/lib/permission.service.d.ts +3 -2
- package/lib/sentry.service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -868,7 +868,8 @@ class PermissionService {
|
|
|
868
868
|
setCurrentSubscription(subscription) {
|
|
869
869
|
PermissionService.selectedSubscription = subscription;
|
|
870
870
|
}
|
|
871
|
-
isGranted(permissionName, productKey = null, permission_key = null) {
|
|
871
|
+
isGranted(permissionName, productKey = null, permission_key = null, productSlug = null) {
|
|
872
|
+
console.log("Granted Permissions", permissionName, productKey, permission_key, productSlug);
|
|
872
873
|
if (this.user) {
|
|
873
874
|
const { user } = this;
|
|
874
875
|
// Admin have access to all the menus.
|
|
@@ -876,6 +877,21 @@ class PermissionService {
|
|
|
876
877
|
if (this.isSuperAdmin()) {
|
|
877
878
|
return true;
|
|
878
879
|
}
|
|
880
|
+
if (permissionName) {
|
|
881
|
+
const selectedProduct = PermissionService?.selectedProduct || this.getCurrentProduct();
|
|
882
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
883
|
+
let slugToCheck;
|
|
884
|
+
if (!productSlug) {
|
|
885
|
+
slugToCheck = `Pages.Product.${subscriptionSlug}.`;
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
slugToCheck = productSlug;
|
|
889
|
+
}
|
|
890
|
+
console.log("In If Of granted Permission", slugToCheck);
|
|
891
|
+
if (!permissionName.includes(slugToCheck)) {
|
|
892
|
+
permissionName = permissionName.replace('Pages.Product.', slugToCheck);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
879
895
|
// Returning true if user has a given permission
|
|
880
896
|
// E.g., Pages.Role.CloudOlive.SalesManager
|
|
881
897
|
// or Pages.Beta or Pages.Alpha
|
|
@@ -917,7 +933,8 @@ class PermissionService {
|
|
|
917
933
|
grantedPermissionNames: Object.keys(data.granted)
|
|
918
934
|
};
|
|
919
935
|
}
|
|
920
|
-
evaluatePermissions(permission, productKey = null, permission_key = null) {
|
|
936
|
+
evaluatePermissions(permission, productKey = null, permission_key = null, productSlug = null) {
|
|
937
|
+
console.log("Evaluate Permission", permission, productKey, permission_key, productSlug);
|
|
921
938
|
if (!permission) {
|
|
922
939
|
return false;
|
|
923
940
|
}
|
|
@@ -956,7 +973,7 @@ class PermissionService {
|
|
|
956
973
|
let raw = x;
|
|
957
974
|
if (x.includes('Pages')) {
|
|
958
975
|
if (productKey) {
|
|
959
|
-
raw = `this.isGranted('${x}', '${productKey}', '${permission_key}')`;
|
|
976
|
+
raw = `this.isGranted('${x}', '${productKey}', '${permission_key}', '${productSlug}')`;
|
|
960
977
|
}
|
|
961
978
|
else {
|
|
962
979
|
raw = `this.isGranted('${x}')`;
|
|
@@ -987,7 +1004,9 @@ class PermissionService {
|
|
|
987
1004
|
if (!product) {
|
|
988
1005
|
product = this.getCurrentProduct();
|
|
989
1006
|
}
|
|
990
|
-
|
|
1007
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1008
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1009
|
+
return !!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionOwner`];
|
|
991
1010
|
}
|
|
992
1011
|
/**
|
|
993
1012
|
* Any Product Admin regardless of the product being master product or not.
|
|
@@ -998,8 +1017,10 @@ class PermissionService {
|
|
|
998
1017
|
if (!product) {
|
|
999
1018
|
product = this.getCurrentProduct();
|
|
1000
1019
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1020
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1021
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1022
|
+
return (!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionAdmin`] ||
|
|
1023
|
+
!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionOwner`]);
|
|
1003
1024
|
}
|
|
1004
1025
|
/**
|
|
1005
1026
|
* Any Product Admin of the product being the master product
|
|
@@ -1008,8 +1029,16 @@ class PermissionService {
|
|
|
1008
1029
|
if (!product) {
|
|
1009
1030
|
product = this.getCurrentProduct();
|
|
1010
1031
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1032
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1033
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1034
|
+
return (!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`] ||
|
|
1035
|
+
!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperOwner`]);
|
|
1036
|
+
}
|
|
1037
|
+
isUserMasterSubscriptionSuperAdmin(product) {
|
|
1038
|
+
if (!product) {
|
|
1039
|
+
product = this.getCurrentProduct();
|
|
1040
|
+
}
|
|
1041
|
+
return !!this.user.auth.granted[`Pages.Product.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`];
|
|
1013
1042
|
}
|
|
1014
1043
|
/**
|
|
1015
1044
|
* Any Product Admin of the product being the master product
|
|
@@ -1018,14 +1047,17 @@ class PermissionService {
|
|
|
1018
1047
|
if (!product) {
|
|
1019
1048
|
product = this.getCurrentProduct();
|
|
1020
1049
|
}
|
|
1021
|
-
|
|
1050
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1051
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1052
|
+
return !!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperOwner`];
|
|
1022
1053
|
}
|
|
1023
1054
|
setCurrentProduct(product) {
|
|
1024
1055
|
localStorage.setItem('product', JSON.stringify({
|
|
1025
1056
|
id: product.id,
|
|
1026
1057
|
permission_key: product.permission_key,
|
|
1027
1058
|
feature_key: product.feature_key,
|
|
1028
|
-
subscriptionId: product.subscriptionId
|
|
1059
|
+
subscriptionId: product.subscriptionId,
|
|
1060
|
+
subscription_slug: product.subscription_slug
|
|
1029
1061
|
}));
|
|
1030
1062
|
}
|
|
1031
1063
|
getCurrentProduct() {
|
|
@@ -1585,10 +1617,10 @@ class CommonService {
|
|
|
1585
1617
|
...HelperService.getPagingParams(paging)
|
|
1586
1618
|
});
|
|
1587
1619
|
}
|
|
1588
|
-
getIncidentsAdmin(paging,
|
|
1620
|
+
getIncidentsAdmin(paging, subscriptionId) {
|
|
1589
1621
|
return this.api.getWithParams(`${INCIDENTS_PATH_ADMIN}/get_all`, {
|
|
1590
1622
|
...HelperService.getPagingParams(paging),
|
|
1591
|
-
subscription_id:
|
|
1623
|
+
subscription_id: subscriptionId
|
|
1592
1624
|
});
|
|
1593
1625
|
}
|
|
1594
1626
|
addIncident(data) {
|
|
@@ -2510,7 +2542,7 @@ class SentryErrorHandler {
|
|
|
2510
2542
|
// Ensure all errors have a proper message
|
|
2511
2543
|
this.errorMessageFormatter(error);
|
|
2512
2544
|
// Existing Sentry initialization logic
|
|
2513
|
-
this.
|
|
2545
|
+
this.sentryInitialization(error, incomingError);
|
|
2514
2546
|
}
|
|
2515
2547
|
handleNonHttpErrorResponse(error) {
|
|
2516
2548
|
if (typeof error === 'object' && 'message' in error) {
|
|
@@ -2534,7 +2566,7 @@ class SentryErrorHandler {
|
|
|
2534
2566
|
error = new Error(enhancedErrorMessage); // NOSONAR
|
|
2535
2567
|
}
|
|
2536
2568
|
}
|
|
2537
|
-
|
|
2569
|
+
sentryInitialization(error, incomingError) {
|
|
2538
2570
|
if (!SentryErrorHandler.sentryInitialized) {
|
|
2539
2571
|
this.initializeSentryAsync()
|
|
2540
2572
|
.then(() => {
|
|
@@ -2579,6 +2611,9 @@ class SentryErrorHandler {
|
|
|
2579
2611
|
});
|
|
2580
2612
|
}
|
|
2581
2613
|
handleNonStandardError(error) {
|
|
2614
|
+
if ('isTrusted' in error) {
|
|
2615
|
+
return;
|
|
2616
|
+
}
|
|
2582
2617
|
// If it's an object but not a standard Error, attempt to log its properties safely
|
|
2583
2618
|
let errorMessage = 'Captured non-standard error with no message'; // NOSONAR
|
|
2584
2619
|
// Try to extract any message-like property safely
|