ais_auth_lib 1.0.1 → 1.0.2
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/filter.d.ts +1 -0
- package/dist/filter.js +26 -22
- package/package.json +1 -1
package/dist/filter.d.ts
CHANGED
package/dist/filter.js
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.filterObjects = void 0;
|
|
3
|
+
exports.checkResourceMatchWithRules = exports.filterObjects = void 0;
|
|
4
4
|
const conditions_1 = require("./conditions");
|
|
5
5
|
function filterObjects(objects, rules) {
|
|
6
6
|
return objects.filter((obj) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
return checkResourceMatchWithRules(obj, rules);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
exports.filterObjects = filterObjects;
|
|
11
|
+
function checkResourceMatchWithRules(obj, rules) {
|
|
12
|
+
let overallResult = false;
|
|
13
|
+
const actions = new Set();
|
|
14
|
+
for (const rule of rules) {
|
|
15
|
+
let ruleResult = (0, conditions_1.evaluateConditionGroup)(obj, rule.conditionGroups[0]);
|
|
16
|
+
for (let i = 1; i < rule.conditionGroups.length; i++) {
|
|
17
|
+
const group = rule.conditionGroups[i];
|
|
18
|
+
const currentResult = (0, conditions_1.evaluateConditionGroup)(obj, group);
|
|
19
|
+
if (group.logicalCondition === "ИЛИ") {
|
|
20
|
+
ruleResult = ruleResult || currentResult;
|
|
20
21
|
}
|
|
21
|
-
if (
|
|
22
|
-
|
|
22
|
+
else if (group.logicalCondition === "И") {
|
|
23
|
+
ruleResult = ruleResult && currentResult;
|
|
23
24
|
}
|
|
24
|
-
overallResult = overallResult || ruleResult;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (ruleResult) {
|
|
27
|
+
actions.add(rule.action);
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
}
|
|
29
|
+
overallResult = overallResult || ruleResult;
|
|
30
|
+
}
|
|
31
|
+
if (overallResult) {
|
|
32
|
+
obj.actions = Array.from(actions);
|
|
33
|
+
}
|
|
34
|
+
return overallResult ? obj : null;
|
|
31
35
|
}
|
|
32
|
-
exports.
|
|
36
|
+
exports.checkResourceMatchWithRules = checkResourceMatchWithRules;
|