ais_auth_lib 1.0.18 → 1.0.20

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.
Files changed (2) hide show
  1. package/dist/conditions.js +17 -1
  2. package/package.json +1 -1
@@ -50,7 +50,19 @@ 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
- const normalize = (v) => typeof v === "string" && !isNaN(Number(v)) ? Number(v) : v;
53
+ const normalize = (v) => {
54
+ if (typeof v === "string") {
55
+ const trimmed = v.trim();
56
+ // 👇 prevent "" from becoming 0
57
+ if (trimmed === "")
58
+ return v;
59
+ // convert only real numeric strings
60
+ if (!isNaN(Number(trimmed))) {
61
+ return Number(trimmed);
62
+ }
63
+ }
64
+ return v;
65
+ };
54
66
  const attributeValues = (0, exports.getPropertiesByPath)(obj, attribute).map(normalize);
55
67
  console.log("ATTR VAL", attributeValues);
56
68
  if (valueType === "dynamic" && !context) {
@@ -69,6 +81,10 @@ function evaluateCondition(obj, condition, context) {
69
81
  return attributeValues.some((v) => compareValues.includes(v));
70
82
  case "Не равно":
71
83
  return attributeValues.every((v) => !compareValues.includes(v));
84
+ case "До":
85
+ return attributeValues.some((v) => typeof v === "number" && v < compareValues[0]);
86
+ case "После":
87
+ return attributeValues.some((v) => typeof v === "number" && v > compareValues[0]);
72
88
  case "Содержит":
73
89
  return attributeValues.some((v) => typeof v === "string" && compareValues.some((c) => v.includes(c)));
74
90
  case "Не содержит":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ais_auth_lib",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "auth lib for microservices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",