@servicetitan/dte-unlayer 0.133.0 → 0.135.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/dte-unlayer",
3
- "version": "0.133.0",
3
+ "version": "0.135.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -97,6 +97,14 @@ function buildSingleConditionExpression(
97
97
  default:
98
98
  inner = `${defaulted} == ${literal}`;
99
99
  }
100
+ /*
101
+ * is_empty / is_not_empty embed space-delimited " or " / " and " in the expression.
102
+ * tokenizeGroupExpression splits on those at depth 0, so wrap once more so parse
103
+ * keeps each value-less condition as a single segment (see parseGroupExpression).
104
+ */
105
+ if (operator === 'is_empty' || operator === 'is_not_empty') {
106
+ return `((${inner}))`;
107
+ }
100
108
  return `(${inner})`;
101
109
  }
102
110
 
@@ -439,6 +447,24 @@ function parseSingleConditionExpression(
439
447
  return null;
440
448
  }
441
449
 
450
+ const parseSegmentToSingleCondition = (
451
+ rawSegment: string,
452
+ logicalOp?: LogicalOperator,
453
+ ): SingleCondition | null => {
454
+ let text = stripOuterParens(rawSegment.trim());
455
+ for (;;) {
456
+ const single = parseSingleConditionExpression(text, logicalOp);
457
+ if (single) {
458
+ return single;
459
+ }
460
+ const next = stripOuterParens(text);
461
+ if (next === text) {
462
+ return null;
463
+ }
464
+ text = next;
465
+ }
466
+ };
467
+
442
468
  /**
443
469
  * Parse a group expression into conditions with per-condition logical operators.
444
470
  */
@@ -451,9 +477,8 @@ function parseGroupExpression(groupExpr: string): SingleCondition[] | null {
451
477
  if (!cs) {
452
478
  continue;
453
479
  }
454
- const unwrapped = stripOuterParens(cs);
455
480
  const logicalOp = i > 0 ? operators[i - 1] : undefined;
456
- const single = parseSingleConditionExpression(unwrapped, logicalOp);
481
+ const single = parseSegmentToSingleCondition(cs, logicalOp);
457
482
  if (single) {
458
483
  conditions.push(single);
459
484
  }