@universis/janitor 2.5.0 → 2.5.1

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
@@ -2016,6 +2016,30 @@ class EnableReadAccessScope extends common.ApplicationService {
2016
2016
  }
2017
2017
  }
2018
2018
  }
2019
+
2020
+ // get views with scope based privileges
2021
+ // noinspection JSUnresolvedReference
2022
+ if (Array.isArray(definition.views)) {
2023
+ // noinspection JSUnresolvedReference
2024
+ const views = definition.views.filter((item) => {
2025
+ return Array.isArray(item.privileges);
2026
+ });
2027
+ for (const view of views) {
2028
+ const privileges = view.privileges.filter((privilege) => {
2029
+ return privilege.mask === 1 && Array.isArray(privilege.scope) && privilege.scope.includes(searchScope);
2030
+ });
2031
+ if (privileges.length > 0) {
2032
+ shouldUpdate = true;
2033
+ for (const privilege of privileges) {
2034
+ if (!privilege.scope.includes(targetScope)) {
2035
+ privilege.scope.push(targetScope);
2036
+ }
2037
+ }
2038
+ }
2039
+ }
2040
+ }
2041
+
2042
+
2019
2043
  if (shouldUpdate) {
2020
2044
  updated++;
2021
2045
  // update model definition