flowquery 1.0.53 → 1.0.54

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 (54) hide show
  1. package/README.md +67 -0
  2. package/dist/flowquery.min.js +1 -1
  3. package/dist/parsing/expressions/expression.d.ts +3 -0
  4. package/dist/parsing/expressions/expression.d.ts.map +1 -1
  5. package/dist/parsing/expressions/expression.js +8 -0
  6. package/dist/parsing/expressions/expression.js.map +1 -1
  7. package/dist/parsing/expressions/subquery_expression.d.ts +18 -0
  8. package/dist/parsing/expressions/subquery_expression.d.ts.map +1 -0
  9. package/dist/parsing/expressions/subquery_expression.js +98 -0
  10. package/dist/parsing/expressions/subquery_expression.js.map +1 -0
  11. package/dist/parsing/functions/function_factory.d.ts +11 -0
  12. package/dist/parsing/functions/function_factory.d.ts.map +1 -1
  13. package/dist/parsing/functions/function_factory.js +13 -0
  14. package/dist/parsing/functions/function_factory.js.map +1 -1
  15. package/dist/parsing/functions/predicate_all.d.ts +7 -0
  16. package/dist/parsing/functions/predicate_all.d.ts.map +1 -0
  17. package/dist/parsing/functions/predicate_all.js +58 -0
  18. package/dist/parsing/functions/predicate_all.js.map +1 -0
  19. package/dist/parsing/functions/predicate_any.d.ts +7 -0
  20. package/dist/parsing/functions/predicate_any.d.ts.map +1 -0
  21. package/dist/parsing/functions/predicate_any.js +58 -0
  22. package/dist/parsing/functions/predicate_any.js.map +1 -0
  23. package/dist/parsing/functions/predicate_function.d.ts +4 -1
  24. package/dist/parsing/functions/predicate_function.d.ts.map +1 -1
  25. package/dist/parsing/functions/predicate_function.js +18 -2
  26. package/dist/parsing/functions/predicate_function.js.map +1 -1
  27. package/dist/parsing/functions/predicate_none.d.ts +7 -0
  28. package/dist/parsing/functions/predicate_none.d.ts.map +1 -0
  29. package/dist/parsing/functions/predicate_none.js +58 -0
  30. package/dist/parsing/functions/predicate_none.js.map +1 -0
  31. package/dist/parsing/functions/predicate_single.d.ts +7 -0
  32. package/dist/parsing/functions/predicate_single.d.ts.map +1 -0
  33. package/dist/parsing/functions/predicate_single.js +61 -0
  34. package/dist/parsing/functions/predicate_single.js.map +1 -0
  35. package/dist/parsing/functions/predicate_sum.js.map +1 -1
  36. package/dist/parsing/operations/return.d.ts.map +1 -1
  37. package/dist/parsing/operations/return.js +3 -0
  38. package/dist/parsing/operations/return.js.map +1 -1
  39. package/dist/parsing/operations/where.d.ts.map +1 -1
  40. package/dist/parsing/operations/where.js +3 -0
  41. package/dist/parsing/operations/where.js.map +1 -1
  42. package/dist/parsing/parser.d.ts +2 -0
  43. package/dist/parsing/parser.d.ts.map +1 -1
  44. package/dist/parsing/parser.js +110 -9
  45. package/dist/parsing/parser.js.map +1 -1
  46. package/dist/tokenization/keyword.d.ts +2 -1
  47. package/dist/tokenization/keyword.d.ts.map +1 -1
  48. package/dist/tokenization/keyword.js +1 -0
  49. package/dist/tokenization/keyword.js.map +1 -1
  50. package/dist/tokenization/token.d.ts +2 -0
  51. package/dist/tokenization/token.d.ts.map +1 -1
  52. package/dist/tokenization/token.js +7 -0
  53. package/dist/tokenization/token.js.map +1 -1
  54. package/package.json +4 -1
package/README.md CHANGED
@@ -393,6 +393,29 @@ RETURN sum(n IN [1, 2, 3] | n) AS sum // 6
393
393
  RETURN sum(n IN [1+2+3, 2, 3] | n^2) AS sum // 49
394
394
  ```
395
395
 
396
+ ### Boolean Predicate Functions
397
+
398
+ Test list elements against a condition. Follow standard Cypher syntax.
399
+
400
+ ```cypher
401
+ // any — true if at least one element matches
402
+ RETURN any(n IN [1, 2, 3] WHERE n > 2) // true
403
+
404
+ // all — true if every element matches
405
+ RETURN all(n IN [2, 4, 6] WHERE n > 0) // true
406
+
407
+ // none — true if no element matches
408
+ RETURN none(n IN [1, 2, 3] WHERE n > 5) // true
409
+
410
+ // single — true if exactly one element matches
411
+ RETURN single(n IN [1, 2, 3] WHERE n > 2) // true
412
+
413
+ // In a WHERE clause
414
+ UNWIND [[1,2,3], [4,5,6]] AS nums
415
+ WITH nums WHERE any(n IN nums WHERE n > 4)
416
+ RETURN nums // [4, 5, 6]
417
+ ```
418
+
396
419
  ### Aggregate Functions
397
420
 
398
421
  Used in `RETURN` or `WITH` to group and reduce rows. Non-aggregated expressions define grouping keys. Aggregate functions cannot be nested.
@@ -552,6 +575,44 @@ MATCH (a:Person), (b:Person) WHERE (a)-[:KNOWS]->(b) RETURN a.name, b.name
552
575
  MATCH (a:Person) WHERE NOT (a)-[:KNOWS]->(:Person) RETURN a.name
553
576
  ```
554
577
 
578
+ **Subquery Expressions:** `EXISTS`, `COUNT`, and `COLLECT` evaluate a full subquery as an expression. The subquery can reference outer-scope variables and supports the complete FlowQuery pipeline (MATCH, WITH, WHERE, UNWIND, LOAD, etc.).
579
+
580
+ ```cypher
581
+ // EXISTS — returns true if the subquery produces any rows
582
+ MATCH (p:Person)
583
+ WHERE EXISTS {
584
+ MATCH (p)-[:KNOWS]->(friend:Person)
585
+ WHERE friend.age > 30
586
+ }
587
+ RETURN p.name
588
+
589
+ // NOT EXISTS — negate with NOT
590
+ MATCH (p:Person)
591
+ WHERE NOT EXISTS { MATCH (p)-[:KNOWS]->(:Person) }
592
+ RETURN p.name
593
+
594
+ // COUNT — returns the number of rows the subquery produces
595
+ MATCH (p:Person)
596
+ WHERE COUNT { MATCH (p)-[:KNOWS]->(:Person) } > 2
597
+ RETURN p.name
598
+
599
+ // COUNT in RETURN
600
+ MATCH (p:Person)
601
+ RETURN p.name, COUNT { MATCH (p)-[:KNOWS]->(:Person) } AS friendCount
602
+
603
+ // COLLECT — returns a list of single-column values from the subquery
604
+ MATCH (p:Person)
605
+ RETURN COLLECT {
606
+ MATCH (p)-[:KNOWS]->(friend:Person)
607
+ RETURN friend.name
608
+ } AS friends
609
+
610
+ // COLLECT with IN
611
+ MATCH (p:Person)
612
+ WHERE 'Alice' IN COLLECT { MATCH (p)-[:KNOWS]->(f:Person) RETURN f.name }
613
+ RETURN p.name
614
+ ```
615
+
555
616
  **Node reference reuse across MATCH clauses:**
556
617
 
557
618
  ```cypher
@@ -674,6 +735,8 @@ RETURN f.name, f.description, f.category
674
735
  │ CONTAINS · NOT CONTAINS │
675
736
  │ STARTS WITH · NOT STARTS WITH │
676
737
  │ ENDS WITH · NOT ENDS WITH │
738
+ │ EXISTS { subquery } · NOT EXISTS { subquery } │
739
+ │ COUNT { subquery } · COLLECT { subquery } │
677
740
  ├─────────────────────────────────────────────────────────────┤
678
741
  │ EXPRESSIONS │
679
742
  ├─────────────────────────────────────────────────────────────┤
@@ -698,6 +761,10 @@ RETURN f.name, f.description, f.category
698
761
  │ sum(x) avg(x) count(x) min(x) max(x) collect(x) │
699
762
  │ count(DISTINCT x) · collect(DISTINCT x) │
700
763
  │ sum(v IN list | expr [WHERE cond]) -- inline predicate │
764
+ │ any(v IN list WHERE cond) -- true if any match │
765
+ │ all(v IN list WHERE cond) -- true if all match │
766
+ │ none(v IN list WHERE cond) -- true if none match │
767
+ │ single(v IN list WHERE cond) -- true if one match │
701
768
  ├─────────────────────────────────────────────────────────────┤
702
769
  │ SCALAR FUNCTIONS │
703
770
  ├─────────────────────────────────────────────────────────────┤