ais_auth_lib 1.0.19 → 1.0.21

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,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) {
@@ -77,6 +89,12 @@ function evaluateCondition(obj, condition, context) {
77
89
  return attributeValues.some((v) => typeof v === "string" && compareValues.some((c) => v.includes(c)));
78
90
  case "Не содержит":
79
91
  return attributeValues.every((v) => typeof v === "string" && compareValues.every((c) => !v.includes(c)));
92
+ case "Пусто":
93
+ const isEmpty = attributeValues.every((v) => v === null ||
94
+ v === undefined ||
95
+ v === "" ||
96
+ (Array.isArray(v) && v.length === 0));
97
+ return condition.value === true ? isEmpty : !isEmpty;
80
98
  default:
81
99
  return false;
82
100
  }
@@ -2,7 +2,7 @@ import { ConditionGroup } from "./condition-group";
2
2
  export interface Condition {
3
3
  uid: string;
4
4
  attribute: string;
5
- value: string;
5
+ value: string | boolean;
6
6
  operator: string;
7
7
  valueType: "static" | "dynamic";
8
8
  orderIndex: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ais_auth_lib",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "auth lib for microservices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",