@posiwise/common-services 0.1.41 → 0.1.43
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/date-formatter.service.mjs +1 -2
- package/esm2022/lib/notification.service.mjs +9 -5
- package/esm2022/lib/permission.service.mjs +40 -11
- package/esm2022/lib/sentry.service.mjs +6 -3
- package/fesm2022/posiwise-common-services.mjs +54 -19
- package/fesm2022/posiwise-common-services.mjs.map +1 -1
- package/lib/common.service.d.ts +1 -1
- package/lib/notification.service.d.ts +3 -2
- package/lib/permission.service.d.ts +3 -2
- package/lib/sentry.service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -868,7 +868,7 @@ 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
872
|
if (this.user) {
|
|
873
873
|
const { user } = this;
|
|
874
874
|
// Admin have access to all the menus.
|
|
@@ -876,6 +876,20 @@ class PermissionService {
|
|
|
876
876
|
if (this.isSuperAdmin()) {
|
|
877
877
|
return true;
|
|
878
878
|
}
|
|
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
|
+
}
|
|
892
|
+
}
|
|
879
893
|
// Returning true if user has a given permission
|
|
880
894
|
// E.g., Pages.Role.CloudOlive.SalesManager
|
|
881
895
|
// or Pages.Beta or Pages.Alpha
|
|
@@ -917,7 +931,7 @@ class PermissionService {
|
|
|
917
931
|
grantedPermissionNames: Object.keys(data.granted)
|
|
918
932
|
};
|
|
919
933
|
}
|
|
920
|
-
evaluatePermissions(permission, productKey = null, permission_key = null) {
|
|
934
|
+
evaluatePermissions(permission, productKey = null, permission_key = null, productSlug = null) {
|
|
921
935
|
if (!permission) {
|
|
922
936
|
return false;
|
|
923
937
|
}
|
|
@@ -956,7 +970,7 @@ class PermissionService {
|
|
|
956
970
|
let raw = x;
|
|
957
971
|
if (x.includes('Pages')) {
|
|
958
972
|
if (productKey) {
|
|
959
|
-
raw = `this.isGranted('${x}', '${productKey}', '${permission_key}')`;
|
|
973
|
+
raw = `this.isGranted('${x}', '${productKey}', '${permission_key}', '${productSlug}')`;
|
|
960
974
|
}
|
|
961
975
|
else {
|
|
962
976
|
raw = `this.isGranted('${x}')`;
|
|
@@ -987,7 +1001,9 @@ class PermissionService {
|
|
|
987
1001
|
if (!product) {
|
|
988
1002
|
product = this.getCurrentProduct();
|
|
989
1003
|
}
|
|
990
|
-
|
|
1004
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1005
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1006
|
+
return !!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionOwner`];
|
|
991
1007
|
}
|
|
992
1008
|
/**
|
|
993
1009
|
* Any Product Admin regardless of the product being master product or not.
|
|
@@ -998,8 +1014,10 @@ class PermissionService {
|
|
|
998
1014
|
if (!product) {
|
|
999
1015
|
product = this.getCurrentProduct();
|
|
1000
1016
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1017
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1018
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1019
|
+
return (!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionAdmin`] ||
|
|
1020
|
+
!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionOwner`]);
|
|
1003
1021
|
}
|
|
1004
1022
|
/**
|
|
1005
1023
|
* Any Product Admin of the product being the master product
|
|
@@ -1008,8 +1026,16 @@ class PermissionService {
|
|
|
1008
1026
|
if (!product) {
|
|
1009
1027
|
product = this.getCurrentProduct();
|
|
1010
1028
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1029
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1030
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1031
|
+
return (!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`] ||
|
|
1032
|
+
!!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperOwner`]);
|
|
1033
|
+
}
|
|
1034
|
+
isUserMasterSubscriptionSuperAdmin(product) {
|
|
1035
|
+
if (!product) {
|
|
1036
|
+
product = this.getCurrentProduct();
|
|
1037
|
+
}
|
|
1038
|
+
return !!this.user.auth.granted[`Pages.Product.${product.permission_key}.${product.feature_key}.SubscriptionSuperAdmin`];
|
|
1013
1039
|
}
|
|
1014
1040
|
/**
|
|
1015
1041
|
* Any Product Admin of the product being the master product
|
|
@@ -1018,14 +1044,17 @@ class PermissionService {
|
|
|
1018
1044
|
if (!product) {
|
|
1019
1045
|
product = this.getCurrentProduct();
|
|
1020
1046
|
}
|
|
1021
|
-
|
|
1047
|
+
const selectedProduct = PermissionService?.selectedProduct;
|
|
1048
|
+
const subscriptionSlug = selectedProduct?.subscription_slug;
|
|
1049
|
+
return !!this.user.auth.granted[`Pages.Product.${subscriptionSlug}.${product.permission_key}.${product.feature_key}.SubscriptionSuperOwner`];
|
|
1022
1050
|
}
|
|
1023
1051
|
setCurrentProduct(product) {
|
|
1024
1052
|
localStorage.setItem('product', JSON.stringify({
|
|
1025
1053
|
id: product.id,
|
|
1026
1054
|
permission_key: product.permission_key,
|
|
1027
1055
|
feature_key: product.feature_key,
|
|
1028
|
-
subscriptionId: product.subscriptionId
|
|
1056
|
+
subscriptionId: product.subscriptionId,
|
|
1057
|
+
subscription_slug: product.subscription_slug
|
|
1029
1058
|
}));
|
|
1030
1059
|
}
|
|
1031
1060
|
getCurrentProduct() {
|
|
@@ -1585,10 +1614,10 @@ class CommonService {
|
|
|
1585
1614
|
...HelperService.getPagingParams(paging)
|
|
1586
1615
|
});
|
|
1587
1616
|
}
|
|
1588
|
-
getIncidentsAdmin(paging,
|
|
1617
|
+
getIncidentsAdmin(paging, subscriptionId) {
|
|
1589
1618
|
return this.api.getWithParams(`${INCIDENTS_PATH_ADMIN}/get_all`, {
|
|
1590
1619
|
...HelperService.getPagingParams(paging),
|
|
1591
|
-
subscription_id:
|
|
1620
|
+
subscription_id: subscriptionId
|
|
1592
1621
|
});
|
|
1593
1622
|
}
|
|
1594
1623
|
addIncident(data) {
|
|
@@ -1759,7 +1788,6 @@ class NgbDateCustomParserFormatter extends NgbDateParserFormatter {
|
|
|
1759
1788
|
const day = isNumber(date.day) ? padNumber(date.day) : '';
|
|
1760
1789
|
const month = isNumber(date.month) ? monthNames[date.month] : '';
|
|
1761
1790
|
const year = date.year;
|
|
1762
|
-
console.log("In thi");
|
|
1763
1791
|
return `${day}-${month}-${year}`;
|
|
1764
1792
|
}
|
|
1765
1793
|
dateFormatForPicker(date) {
|
|
@@ -2169,11 +2197,15 @@ class NotificationService {
|
|
|
2169
2197
|
this.endpoint = 'notes_read';
|
|
2170
2198
|
this.notificationSubject$ = new BehaviorSubject([]);
|
|
2171
2199
|
}
|
|
2172
|
-
getNotifications() {
|
|
2173
|
-
return this.api.
|
|
2200
|
+
getNotifications(paging) {
|
|
2201
|
+
return this.api.getWithParams(`/notes?show_on_dashboard=true`, {
|
|
2202
|
+
...paging
|
|
2203
|
+
});
|
|
2174
2204
|
}
|
|
2175
|
-
getDismissedNotifications() {
|
|
2176
|
-
return this.api.
|
|
2205
|
+
getDismissedNotifications(paging) {
|
|
2206
|
+
return this.api.getWithParams(`/notes?dismissed=true`, {
|
|
2207
|
+
...paging
|
|
2208
|
+
});
|
|
2177
2209
|
}
|
|
2178
2210
|
showNotifications(data) {
|
|
2179
2211
|
this.notificationSubject$.next(data);
|
|
@@ -2507,7 +2539,7 @@ class SentryErrorHandler {
|
|
|
2507
2539
|
// Ensure all errors have a proper message
|
|
2508
2540
|
this.errorMessageFormatter(error);
|
|
2509
2541
|
// Existing Sentry initialization logic
|
|
2510
|
-
this.
|
|
2542
|
+
this.sentryInitialization(error, incomingError);
|
|
2511
2543
|
}
|
|
2512
2544
|
handleNonHttpErrorResponse(error) {
|
|
2513
2545
|
if (typeof error === 'object' && 'message' in error) {
|
|
@@ -2531,7 +2563,7 @@ class SentryErrorHandler {
|
|
|
2531
2563
|
error = new Error(enhancedErrorMessage); // NOSONAR
|
|
2532
2564
|
}
|
|
2533
2565
|
}
|
|
2534
|
-
|
|
2566
|
+
sentryInitialization(error, incomingError) {
|
|
2535
2567
|
if (!SentryErrorHandler.sentryInitialized) {
|
|
2536
2568
|
this.initializeSentryAsync()
|
|
2537
2569
|
.then(() => {
|
|
@@ -2576,6 +2608,9 @@ class SentryErrorHandler {
|
|
|
2576
2608
|
});
|
|
2577
2609
|
}
|
|
2578
2610
|
handleNonStandardError(error) {
|
|
2611
|
+
if ('isTrusted' in error) {
|
|
2612
|
+
return;
|
|
2613
|
+
}
|
|
2579
2614
|
// If it's an object but not a standard Error, attempt to log its properties safely
|
|
2580
2615
|
let errorMessage = 'Captured non-standard error with no message'; // NOSONAR
|
|
2581
2616
|
// Try to extract any message-like property safely
|