flowquery 1.0.57 → 1.0.59

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 (42) hide show
  1. package/README.md +45 -6
  2. package/dist/flowquery.min.js +1 -1
  3. package/dist/graph/database.d.ts.map +1 -1
  4. package/dist/graph/database.js +37 -8
  5. package/dist/graph/database.js.map +1 -1
  6. package/dist/graph/node.d.ts +3 -0
  7. package/dist/graph/node.d.ts.map +1 -1
  8. package/dist/graph/node.js +13 -1
  9. package/dist/graph/node.js.map +1 -1
  10. package/dist/graph/node_reference.d.ts.map +1 -1
  11. package/dist/graph/node_reference.js +1 -0
  12. package/dist/graph/node_reference.js.map +1 -1
  13. package/dist/index.browser.d.ts +2 -2
  14. package/dist/index.browser.d.ts.map +1 -1
  15. package/dist/parsing/expressions/expression.d.ts.map +1 -1
  16. package/dist/parsing/expressions/expression.js +2 -2
  17. package/dist/parsing/expressions/expression.js.map +1 -1
  18. package/dist/parsing/expressions/expression_map.d.ts +1 -0
  19. package/dist/parsing/expressions/expression_map.d.ts.map +1 -1
  20. package/dist/parsing/expressions/expression_map.js +5 -0
  21. package/dist/parsing/expressions/expression_map.js.map +1 -1
  22. package/dist/parsing/expressions/operator.d.ts +6 -6
  23. package/dist/parsing/expressions/operator.d.ts.map +1 -1
  24. package/dist/parsing/expressions/operator.js +18 -0
  25. package/dist/parsing/expressions/operator.js.map +1 -1
  26. package/dist/parsing/functions/function_factory.d.ts +4 -2
  27. package/dist/parsing/functions/function_factory.d.ts.map +1 -1
  28. package/dist/parsing/functions/function_factory.js +1 -0
  29. package/dist/parsing/functions/function_factory.js.map +1 -1
  30. package/dist/parsing/functions/labels.d.ts +7 -0
  31. package/dist/parsing/functions/labels.d.ts.map +1 -0
  32. package/dist/parsing/functions/labels.js +43 -0
  33. package/dist/parsing/functions/labels.js.map +1 -0
  34. package/dist/parsing/functions/properties.js +2 -2
  35. package/dist/parsing/functions/properties.js.map +1 -1
  36. package/dist/parsing/operations/call.d.ts.map +1 -1
  37. package/dist/parsing/operations/call.js +1 -0
  38. package/dist/parsing/operations/call.js.map +1 -1
  39. package/dist/parsing/parser.d.ts.map +1 -1
  40. package/dist/parsing/parser.js +21 -3
  41. package/dist/parsing/parser.js.map +1 -1
  42. package/package.json +2 -2
package/README.md CHANGED
@@ -13,11 +13,18 @@ Beyond graphs, FlowQuery provides a full data processing pipeline language with
13
13
  The combination of graph querying and pipeline processing makes FlowQuery ideal for the retrieval stage of Retrieval Augmented Generation (RAG). A typical graph RAG flow works as follows:
14
14
 
15
15
  1. **User query** — The user asks a question in natural language.
16
- 2. **Query generation** — The LLM, with knowledge of the virtual graph schema, generates a precise OpenCypher query to retrieve the grounding data needed to answer the question.
17
- 3. **Query execution** — The FlowQuery engine executes the generated OpenCypher query against the virtual graph and returns the results as grounding data.
18
- 4. **Response formulation** — The LLM formulates a final response informed by the grounding data.
19
-
20
- ```
16
+ 2. **Schema retrieval** — The application retrieves the virtual graph schema via `CALL schema()` and injects it into the system instructions of the query-generation LLM, so it knows which node labels, relationship types, and properties are available.
17
+ 3. **Query generation** — The LLM, grounded in the schema, generates a precise OpenCypher query to retrieve the data needed to answer the question.
18
+ 4. **Query execution** — The FlowQuery engine executes the generated OpenCypher query against the virtual graph and returns the results as grounding data.
19
+ 5. **Response formulation** — The LLM formulates a final response informed by the grounding data.
20
+
21
+ ```
22
+ ┌───────────────────┐
23
+ │ Graph Schema │
24
+ │ (via schema()) │
25
+ └────────┬──────────┘
26
+ │ system instructions
27
+ v
21
28
  ┌──────────┐ ┌───────────────┐ ┌─────────────────┐ ┌───────────────┐
22
29
  │ User │────>│ LLM │────>│ FlowQuery │────>│ LLM │
23
30
  │ Question │ │ Generate Query│ │ Execute Query │ │ Formulate │
@@ -30,6 +37,22 @@ The combination of graph querying and pipeline processing makes FlowQuery ideal
30
37
  └──────────┘
31
38
  ```
32
39
 
40
+ The schema is retrieved using FlowQuery's built-in `schema()` function, which returns the structure of all registered virtual nodes and relationships — including labels, types, endpoint labels, property names, and sample values. This schema is then included in the LLM's system instructions so it can generate correct queries grounded in the actual graph model:
41
+
42
+ ```cypher
43
+ CALL schema() YIELD kind, label, type, from_label, to_label, properties, sample
44
+ RETURN kind, label, type, from_label, to_label, properties
45
+ ```
46
+
47
+ For the [Virtual Org Chart](#virtual-org-chart) example, this returns:
48
+
49
+ | kind | label | type | from_label | to_label | properties |
50
+ | ------------ | -------- | ---------- | ---------- | -------- | ------------------------------------------- |
51
+ | Node | Employee | N/A | N/A | N/A | [name, jobTitle, department, phone, skills] |
52
+ | Relationship | N/A | REPORTS_TO | Employee | Employee | N/A |
53
+
54
+ Node rows carry `label` and `properties`; relationship rows carry `type`, `from_label`, `to_label`, and `properties`. Fields not applicable to a row are `null`.
55
+
33
56
  See the [Language Reference](#language-reference) and [Quick Cheat Sheet](#quick-cheat-sheet) for full syntax documentation. For a complete worked example, see [Virtual Org Chart](#virtual-org-chart).
34
57
 
35
58
  FlowQuery is written in TypeScript and runs both in the browser and in Node.js as a self-contained single-file JavaScript library. A pure Python implementation of FlowQuery with full functional fidelity is also available in the [flowquery-py](./flowquery-py) sub-folder (`pip install flowquery`).
@@ -468,6 +491,7 @@ UNWIND ["a", "b", "a", "c"] AS s RETURN count(DISTINCT s) AS cnt // 3
468
491
  | `last(list)` | Last element | `last([1,2,3])` → `3` |
469
492
  | `id(node_or_rel)` | ID of a node or type of a relationship | `id(n)` |
470
493
  | `elementId(node)` | String ID of a node | `elementId(n)` → `"1"` |
494
+ | `labels(node)` | Labels of a node as an array | `labels(n)` → `["Person"]` |
471
495
 
472
496
  All scalar functions propagate `null`: if the primary input is `null`, the result is `null`.
473
497
 
@@ -541,6 +565,19 @@ MATCH (n:Person {name: 'Alice'}) RETURN n
541
565
  MATCH (a:Person)-[:KNOWS]->(b:Person) RETURN a.name, b.name
542
566
  ```
543
567
 
568
+ **Unlabeled node matching:** Omit the label to match all nodes in the graph.
569
+
570
+ ```cypher
571
+ MATCH (n) RETURN n // all nodes
572
+ MATCH (n {name: 'Alice'}) RETURN n // all nodes with name='Alice'
573
+ ```
574
+
575
+ **ORed node labels:** Match nodes with any of the specified labels.
576
+
577
+ ```cypher
578
+ MATCH (n:Person|Animal) RETURN n, labels(n) AS lbls
579
+ ```
580
+
544
581
  **Leftward direction:** `<-[:TYPE]-` reverses traversal direction.
545
582
 
546
583
  ```cypher
@@ -719,6 +756,8 @@ RETURN f.name, f.description, f.category
719
756
  │ DELETE VIRTUAL (:Label) │
720
757
  │ DELETE VIRTUAL (:L1)-[:TYPE]-(:L2) │
721
758
  │ MATCH (n:Label {prop: val}), ... [WHERE cond] │
759
+ │ MATCH (n) ... -- unlabeled (all) │
760
+ │ MATCH (n:L1|L2) ... -- ORed node labels │
722
761
  │ MATCH (a)-[:TYPE]->(b) -- rightward │
723
762
  │ MATCH (a)<-[:TYPE]-(b) -- leftward │
724
763
  │ MATCH (a)-[:TYPE*0..3]->(b) -- variable length │
@@ -771,7 +810,7 @@ RETURN f.name, f.description, f.category
771
810
  │ size range round rand split join replace │
772
811
  │ toLower trim substring toString toInteger toFloat │
773
812
  │ tojson stringify string_distance keys properties │
774
- │ type coalesce head tail last id elementId
813
+ │ type coalesce head tail last id elementId labels
775
814
  ├─────────────────────────────────────────────────────────────┤
776
815
  │ TEMPORAL FUNCTIONS │
777
816
  ├─────────────────────────────────────────────────────────────┤