ais_auth_lib 1.0.17 → 1.0.19

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.
@@ -50,9 +50,8 @@ function resolveDynamicValue(condition, context) {
50
50
  exports.resolveDynamicValue = resolveDynamicValue;
51
51
  function evaluateCondition(obj, condition, context) {
52
52
  const { attribute, value, operator, valueType } = condition;
53
- console.log(condition);
54
- console.log("attr", (0, exports.getPropertiesByPath)(obj, attribute));
55
- const attributeValues = (0, exports.getPropertiesByPath)(obj, attribute);
53
+ const normalize = (v) => typeof v === "string" && !isNaN(Number(v)) ? Number(v) : v;
54
+ const attributeValues = (0, exports.getPropertiesByPath)(obj, attribute).map(normalize);
56
55
  console.log("ATTR VAL", attributeValues);
57
56
  if (valueType === "dynamic" && !context) {
58
57
  return false;
@@ -63,13 +62,17 @@ function evaluateCondition(obj, condition, context) {
63
62
  console.log("RESOLVED ", resolved);
64
63
  if (resolved === undefined)
65
64
  return false;
66
- const compareValues = Array.isArray(resolved) ? resolved : [resolved];
65
+ const compareValues = (Array.isArray(resolved) ? resolved : [resolved]).map(normalize);
67
66
  console.log("COMPARE V", compareValues);
68
67
  switch (operator) {
69
68
  case "Равно":
70
69
  return attributeValues.some((v) => compareValues.includes(v));
71
70
  case "Не равно":
72
71
  return attributeValues.every((v) => !compareValues.includes(v));
72
+ case "До":
73
+ return attributeValues.some((v) => typeof v === "number" && v < compareValues[0]);
74
+ case "После":
75
+ return attributeValues.some((v) => typeof v === "number" && v > compareValues[0]);
73
76
  case "Содержит":
74
77
  return attributeValues.some((v) => typeof v === "string" && compareValues.some((c) => v.includes(c)));
75
78
  case "Не содержит":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ais_auth_lib",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "auth lib for microservices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",