flowquery 1.0.15 → 1.0.17

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 (333) hide show
  1. package/.github/workflows/python-publish.yml +97 -0
  2. package/dist/compute/runner.d.ts +3 -2
  3. package/dist/compute/runner.d.ts.map +1 -1
  4. package/dist/compute/runner.js +7 -7
  5. package/dist/compute/runner.js.map +1 -1
  6. package/dist/flowquery.min.js +1 -1
  7. package/dist/graph/data.d.ts +31 -0
  8. package/dist/graph/data.d.ts.map +1 -0
  9. package/dist/graph/data.js +110 -0
  10. package/dist/graph/data.js.map +1 -0
  11. package/dist/graph/database.d.ts +20 -0
  12. package/dist/graph/database.d.ts.map +1 -0
  13. package/dist/graph/database.js +77 -0
  14. package/dist/graph/database.js.map +1 -0
  15. package/dist/graph/hops.d.ts +11 -0
  16. package/dist/graph/hops.d.ts.map +1 -0
  17. package/dist/graph/hops.js +25 -0
  18. package/dist/graph/hops.js.map +1 -0
  19. package/dist/graph/node.d.ts +35 -0
  20. package/dist/graph/node.d.ts.map +1 -0
  21. package/dist/graph/node.js +113 -0
  22. package/dist/graph/node.js.map +1 -0
  23. package/dist/graph/node_data.d.ts +11 -0
  24. package/dist/graph/node_data.d.ts.map +1 -0
  25. package/dist/graph/node_data.js +20 -0
  26. package/dist/graph/node_data.js.map +1 -0
  27. package/dist/graph/node_reference.d.ts +10 -0
  28. package/dist/graph/node_reference.d.ts.map +1 -0
  29. package/dist/graph/node_reference.js +52 -0
  30. package/dist/graph/node_reference.js.map +1 -0
  31. package/dist/graph/pattern.d.ts +18 -0
  32. package/dist/graph/pattern.d.ts.map +1 -0
  33. package/dist/graph/pattern.js +114 -0
  34. package/dist/graph/pattern.js.map +1 -0
  35. package/dist/graph/pattern_expression.d.ts +14 -0
  36. package/dist/graph/pattern_expression.d.ts.map +1 -0
  37. package/dist/graph/pattern_expression.js +58 -0
  38. package/dist/graph/pattern_expression.js.map +1 -0
  39. package/dist/graph/patterns.d.ts +11 -0
  40. package/dist/graph/patterns.d.ts.map +1 -0
  41. package/dist/graph/patterns.js +49 -0
  42. package/dist/graph/patterns.js.map +1 -0
  43. package/dist/graph/physical_node.d.ts +10 -0
  44. package/dist/graph/physical_node.d.ts.map +1 -0
  45. package/dist/graph/physical_node.js +40 -0
  46. package/dist/graph/physical_node.js.map +1 -0
  47. package/dist/graph/physical_relationship.d.ts +10 -0
  48. package/dist/graph/physical_relationship.d.ts.map +1 -0
  49. package/dist/graph/physical_relationship.js +40 -0
  50. package/dist/graph/physical_relationship.js.map +1 -0
  51. package/dist/graph/relationship.d.ts +40 -0
  52. package/dist/graph/relationship.d.ts.map +1 -0
  53. package/dist/graph/relationship.js +124 -0
  54. package/dist/graph/relationship.js.map +1 -0
  55. package/dist/graph/relationship_data.d.ts +12 -0
  56. package/dist/graph/relationship_data.d.ts.map +1 -0
  57. package/dist/graph/relationship_data.js +40 -0
  58. package/dist/graph/relationship_data.js.map +1 -0
  59. package/dist/graph/relationship_match_collector.d.ts +19 -0
  60. package/dist/graph/relationship_match_collector.d.ts.map +1 -0
  61. package/dist/graph/relationship_match_collector.js +55 -0
  62. package/dist/graph/relationship_match_collector.js.map +1 -0
  63. package/dist/graph/relationship_reference.d.ts +8 -0
  64. package/dist/graph/relationship_reference.d.ts.map +1 -0
  65. package/dist/graph/relationship_reference.js +37 -0
  66. package/dist/graph/relationship_reference.js.map +1 -0
  67. package/dist/parsing/base_parser.d.ts +1 -0
  68. package/dist/parsing/base_parser.d.ts.map +1 -1
  69. package/dist/parsing/base_parser.js +4 -1
  70. package/dist/parsing/base_parser.js.map +1 -1
  71. package/dist/parsing/context.d.ts +2 -2
  72. package/dist/parsing/context.js +5 -5
  73. package/dist/parsing/expressions/boolean.d.ts +8 -0
  74. package/dist/parsing/expressions/boolean.d.ts.map +1 -0
  75. package/dist/parsing/expressions/boolean.js +26 -0
  76. package/dist/parsing/expressions/boolean.js.map +1 -0
  77. package/dist/parsing/expressions/expression.d.ts +4 -1
  78. package/dist/parsing/expressions/expression.d.ts.map +1 -1
  79. package/dist/parsing/expressions/expression.js +15 -8
  80. package/dist/parsing/expressions/expression.js.map +1 -1
  81. package/dist/parsing/expressions/expression_map.d.ts +1 -0
  82. package/dist/parsing/expressions/expression_map.d.ts.map +1 -1
  83. package/dist/parsing/expressions/expression_map.js +3 -0
  84. package/dist/parsing/expressions/expression_map.js.map +1 -1
  85. package/dist/parsing/expressions/operator.d.ts +1 -1
  86. package/dist/parsing/expressions/operator.d.ts.map +1 -1
  87. package/dist/parsing/expressions/operator.js.map +1 -1
  88. package/dist/parsing/functions/function_factory.d.ts +13 -13
  89. package/dist/parsing/functions/function_factory.d.ts.map +1 -1
  90. package/dist/parsing/functions/function_factory.js +20 -18
  91. package/dist/parsing/functions/function_factory.js.map +1 -1
  92. package/dist/parsing/operations/call.d.ts.map +1 -1
  93. package/dist/parsing/operations/call.js +3 -1
  94. package/dist/parsing/operations/call.js.map +1 -1
  95. package/dist/parsing/operations/create_node.d.ts +14 -0
  96. package/dist/parsing/operations/create_node.d.ts.map +1 -0
  97. package/dist/parsing/operations/create_node.js +51 -0
  98. package/dist/parsing/operations/create_node.js.map +1 -0
  99. package/dist/parsing/operations/create_relationship.d.ts +14 -0
  100. package/dist/parsing/operations/create_relationship.d.ts.map +1 -0
  101. package/dist/parsing/operations/create_relationship.js +51 -0
  102. package/dist/parsing/operations/create_relationship.js.map +1 -0
  103. package/dist/parsing/operations/match.d.ts +15 -0
  104. package/dist/parsing/operations/match.d.ts.map +1 -0
  105. package/dist/parsing/operations/match.js +45 -0
  106. package/dist/parsing/operations/match.js.map +1 -0
  107. package/dist/parsing/operations/operation.d.ts +1 -0
  108. package/dist/parsing/operations/operation.d.ts.map +1 -1
  109. package/dist/parsing/operations/operation.js +6 -0
  110. package/dist/parsing/operations/operation.js.map +1 -1
  111. package/dist/parsing/operations/return.d.ts +1 -0
  112. package/dist/parsing/operations/return.d.ts.map +1 -1
  113. package/dist/parsing/operations/return.js +7 -1
  114. package/dist/parsing/operations/return.js.map +1 -1
  115. package/dist/parsing/operations/where.d.ts +1 -1
  116. package/dist/parsing/operations/where.d.ts.map +1 -1
  117. package/dist/parsing/operations/where.js +4 -0
  118. package/dist/parsing/operations/where.js.map +1 -1
  119. package/dist/parsing/parser.d.ts +10 -0
  120. package/dist/parsing/parser.d.ts.map +1 -1
  121. package/dist/parsing/parser.js +344 -5
  122. package/dist/parsing/parser.js.map +1 -1
  123. package/dist/parsing/token_to_node.d.ts.map +1 -1
  124. package/dist/parsing/token_to_node.js +7 -0
  125. package/dist/parsing/token_to_node.js.map +1 -1
  126. package/dist/tokenization/keyword.d.ts +1 -0
  127. package/dist/tokenization/keyword.d.ts.map +1 -1
  128. package/dist/tokenization/keyword.js +1 -0
  129. package/dist/tokenization/keyword.js.map +1 -1
  130. package/dist/tokenization/token.d.ts +4 -0
  131. package/dist/tokenization/token.d.ts.map +1 -1
  132. package/dist/tokenization/token.js +14 -1
  133. package/dist/tokenization/token.js.map +1 -1
  134. package/dist/tokenization/token_type.d.ts +1 -0
  135. package/dist/tokenization/token_type.d.ts.map +1 -1
  136. package/dist/tokenization/token_type.js +1 -0
  137. package/dist/tokenization/token_type.js.map +1 -1
  138. package/dist/tokenization/tokenizer.d.ts +2 -1
  139. package/dist/tokenization/tokenizer.d.ts.map +1 -1
  140. package/dist/tokenization/tokenizer.js +25 -12
  141. package/dist/tokenization/tokenizer.js.map +1 -1
  142. package/docs/flowquery.min.js +1 -1
  143. package/flowquery-py/README.md +166 -0
  144. package/flowquery-py/pyproject.toml +75 -0
  145. package/flowquery-py/setup_env.ps1 +92 -0
  146. package/flowquery-py/setup_env.sh +87 -0
  147. package/flowquery-py/src/__init__.py +34 -0
  148. package/flowquery-py/src/__main__.py +10 -0
  149. package/flowquery-py/src/compute/__init__.py +5 -0
  150. package/flowquery-py/src/compute/runner.py +60 -0
  151. package/flowquery-py/src/extensibility.py +52 -0
  152. package/flowquery-py/src/graph/__init__.py +31 -0
  153. package/flowquery-py/src/graph/data.py +118 -0
  154. package/flowquery-py/src/graph/database.py +82 -0
  155. package/flowquery-py/src/graph/hops.py +43 -0
  156. package/flowquery-py/src/graph/node.py +112 -0
  157. package/flowquery-py/src/graph/node_data.py +26 -0
  158. package/flowquery-py/src/graph/node_reference.py +49 -0
  159. package/flowquery-py/src/graph/pattern.py +125 -0
  160. package/flowquery-py/src/graph/pattern_expression.py +62 -0
  161. package/flowquery-py/src/graph/patterns.py +42 -0
  162. package/flowquery-py/src/graph/physical_node.py +40 -0
  163. package/flowquery-py/src/graph/physical_relationship.py +36 -0
  164. package/flowquery-py/src/graph/relationship.py +135 -0
  165. package/flowquery-py/src/graph/relationship_data.py +33 -0
  166. package/flowquery-py/src/graph/relationship_match_collector.py +77 -0
  167. package/flowquery-py/src/graph/relationship_reference.py +21 -0
  168. package/flowquery-py/src/io/__init__.py +5 -0
  169. package/flowquery-py/src/io/command_line.py +67 -0
  170. package/flowquery-py/src/parsing/__init__.py +17 -0
  171. package/flowquery-py/src/parsing/alias.py +20 -0
  172. package/flowquery-py/src/parsing/alias_option.py +11 -0
  173. package/flowquery-py/src/parsing/ast_node.py +146 -0
  174. package/flowquery-py/src/parsing/base_parser.py +84 -0
  175. package/flowquery-py/src/parsing/components/__init__.py +19 -0
  176. package/flowquery-py/src/parsing/components/csv.py +8 -0
  177. package/flowquery-py/src/parsing/components/from_.py +10 -0
  178. package/flowquery-py/src/parsing/components/headers.py +12 -0
  179. package/flowquery-py/src/parsing/components/json.py +8 -0
  180. package/flowquery-py/src/parsing/components/null.py +10 -0
  181. package/flowquery-py/src/parsing/components/post.py +8 -0
  182. package/flowquery-py/src/parsing/components/text.py +8 -0
  183. package/flowquery-py/src/parsing/context.py +50 -0
  184. package/flowquery-py/src/parsing/data_structures/__init__.py +15 -0
  185. package/flowquery-py/src/parsing/data_structures/associative_array.py +41 -0
  186. package/flowquery-py/src/parsing/data_structures/json_array.py +30 -0
  187. package/flowquery-py/src/parsing/data_structures/key_value_pair.py +38 -0
  188. package/flowquery-py/src/parsing/data_structures/lookup.py +49 -0
  189. package/flowquery-py/src/parsing/data_structures/range_lookup.py +42 -0
  190. package/flowquery-py/src/parsing/expressions/__init__.py +57 -0
  191. package/flowquery-py/src/parsing/expressions/boolean.py +20 -0
  192. package/flowquery-py/src/parsing/expressions/expression.py +138 -0
  193. package/flowquery-py/src/parsing/expressions/expression_map.py +26 -0
  194. package/flowquery-py/src/parsing/expressions/f_string.py +27 -0
  195. package/flowquery-py/src/parsing/expressions/identifier.py +20 -0
  196. package/flowquery-py/src/parsing/expressions/number.py +32 -0
  197. package/flowquery-py/src/parsing/expressions/operator.py +169 -0
  198. package/flowquery-py/src/parsing/expressions/reference.py +47 -0
  199. package/flowquery-py/src/parsing/expressions/string.py +27 -0
  200. package/flowquery-py/src/parsing/functions/__init__.py +75 -0
  201. package/flowquery-py/src/parsing/functions/aggregate_function.py +60 -0
  202. package/flowquery-py/src/parsing/functions/async_function.py +62 -0
  203. package/flowquery-py/src/parsing/functions/avg.py +55 -0
  204. package/flowquery-py/src/parsing/functions/collect.py +75 -0
  205. package/flowquery-py/src/parsing/functions/function.py +68 -0
  206. package/flowquery-py/src/parsing/functions/function_factory.py +173 -0
  207. package/flowquery-py/src/parsing/functions/function_metadata.py +149 -0
  208. package/flowquery-py/src/parsing/functions/functions.py +59 -0
  209. package/flowquery-py/src/parsing/functions/join.py +47 -0
  210. package/flowquery-py/src/parsing/functions/keys.py +34 -0
  211. package/flowquery-py/src/parsing/functions/predicate_function.py +46 -0
  212. package/flowquery-py/src/parsing/functions/predicate_sum.py +47 -0
  213. package/flowquery-py/src/parsing/functions/rand.py +28 -0
  214. package/flowquery-py/src/parsing/functions/range_.py +34 -0
  215. package/flowquery-py/src/parsing/functions/reducer_element.py +15 -0
  216. package/flowquery-py/src/parsing/functions/replace.py +37 -0
  217. package/flowquery-py/src/parsing/functions/round_.py +32 -0
  218. package/flowquery-py/src/parsing/functions/size.py +32 -0
  219. package/flowquery-py/src/parsing/functions/split.py +47 -0
  220. package/flowquery-py/src/parsing/functions/stringify.py +47 -0
  221. package/flowquery-py/src/parsing/functions/sum.py +51 -0
  222. package/flowquery-py/src/parsing/functions/to_json.py +33 -0
  223. package/flowquery-py/src/parsing/functions/type_.py +47 -0
  224. package/flowquery-py/src/parsing/functions/value_holder.py +24 -0
  225. package/flowquery-py/src/parsing/logic/__init__.py +15 -0
  226. package/flowquery-py/src/parsing/logic/case.py +29 -0
  227. package/flowquery-py/src/parsing/logic/else_.py +12 -0
  228. package/flowquery-py/src/parsing/logic/end.py +8 -0
  229. package/flowquery-py/src/parsing/logic/then.py +12 -0
  230. package/flowquery-py/src/parsing/logic/when.py +10 -0
  231. package/flowquery-py/src/parsing/operations/__init__.py +35 -0
  232. package/flowquery-py/src/parsing/operations/aggregated_return.py +24 -0
  233. package/flowquery-py/src/parsing/operations/aggregated_with.py +22 -0
  234. package/flowquery-py/src/parsing/operations/call.py +74 -0
  235. package/flowquery-py/src/parsing/operations/create_node.py +34 -0
  236. package/flowquery-py/src/parsing/operations/create_relationship.py +34 -0
  237. package/flowquery-py/src/parsing/operations/group_by.py +130 -0
  238. package/flowquery-py/src/parsing/operations/limit.py +22 -0
  239. package/flowquery-py/src/parsing/operations/load.py +140 -0
  240. package/flowquery-py/src/parsing/operations/match.py +29 -0
  241. package/flowquery-py/src/parsing/operations/operation.py +69 -0
  242. package/flowquery-py/src/parsing/operations/projection.py +21 -0
  243. package/flowquery-py/src/parsing/operations/return_op.py +50 -0
  244. package/flowquery-py/src/parsing/operations/unwind.py +37 -0
  245. package/flowquery-py/src/parsing/operations/where.py +41 -0
  246. package/flowquery-py/src/parsing/operations/with_op.py +18 -0
  247. package/flowquery-py/src/parsing/parser.py +1011 -0
  248. package/flowquery-py/src/parsing/token_to_node.py +109 -0
  249. package/flowquery-py/src/tokenization/__init__.py +23 -0
  250. package/flowquery-py/src/tokenization/keyword.py +48 -0
  251. package/flowquery-py/src/tokenization/operator.py +29 -0
  252. package/flowquery-py/src/tokenization/string_walker.py +158 -0
  253. package/flowquery-py/src/tokenization/symbol.py +19 -0
  254. package/flowquery-py/src/tokenization/token.py +659 -0
  255. package/flowquery-py/src/tokenization/token_mapper.py +52 -0
  256. package/flowquery-py/src/tokenization/token_type.py +21 -0
  257. package/flowquery-py/src/tokenization/tokenizer.py +214 -0
  258. package/flowquery-py/src/tokenization/trie.py +124 -0
  259. package/flowquery-py/src/utils/__init__.py +6 -0
  260. package/flowquery-py/src/utils/object_utils.py +20 -0
  261. package/flowquery-py/src/utils/string_utils.py +113 -0
  262. package/flowquery-py/tests/__init__.py +1 -0
  263. package/flowquery-py/tests/compute/__init__.py +1 -0
  264. package/flowquery-py/tests/compute/test_runner.py +1335 -0
  265. package/flowquery-py/tests/graph/__init__.py +1 -0
  266. package/flowquery-py/tests/graph/test_create.py +56 -0
  267. package/flowquery-py/tests/graph/test_data.py +73 -0
  268. package/flowquery-py/tests/graph/test_match.py +40 -0
  269. package/flowquery-py/tests/parsing/__init__.py +1 -0
  270. package/flowquery-py/tests/parsing/test_context.py +34 -0
  271. package/flowquery-py/tests/parsing/test_expression.py +49 -0
  272. package/flowquery-py/tests/parsing/test_parser.py +674 -0
  273. package/flowquery-py/tests/test_extensibility.py +611 -0
  274. package/flowquery-py/tests/tokenization/__init__.py +1 -0
  275. package/flowquery-py/tests/tokenization/test_token_mapper.py +60 -0
  276. package/flowquery-py/tests/tokenization/test_tokenizer.py +164 -0
  277. package/flowquery-py/tests/tokenization/test_trie.py +30 -0
  278. package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
  279. package/misc/apps/RAG/package.json +1 -1
  280. package/misc/apps/RAG/src/components/AdaptiveCardRenderer.tsx +76 -8
  281. package/misc/apps/RAG/src/components/index.ts +19 -10
  282. package/misc/apps/RAG/src/plugins/loaders/CatFacts.ts +21 -26
  283. package/misc/apps/RAG/src/plugins/loaders/FetchJson.ts +24 -25
  284. package/misc/apps/RAG/src/plugins/loaders/Form.ts +163 -147
  285. package/misc/apps/RAG/src/plugins/loaders/Llm.ts +103 -90
  286. package/misc/apps/RAG/src/plugins/loaders/MockData.ts +80 -130
  287. package/misc/apps/RAG/src/plugins/loaders/Table.ts +104 -101
  288. package/misc/apps/RAG/src/plugins/loaders/Weather.ts +47 -36
  289. package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +89 -78
  290. package/package.json +1 -1
  291. package/src/compute/runner.ts +24 -19
  292. package/src/graph/data.ts +112 -0
  293. package/src/graph/database.ts +63 -0
  294. package/src/graph/hops.ts +22 -0
  295. package/src/graph/node.ts +99 -0
  296. package/src/graph/node_data.ts +18 -0
  297. package/src/graph/node_reference.ts +33 -0
  298. package/src/graph/pattern.ts +101 -0
  299. package/src/graph/pattern_expression.ts +37 -0
  300. package/src/graph/patterns.ts +36 -0
  301. package/src/graph/physical_node.ts +23 -0
  302. package/src/graph/physical_relationship.ts +23 -0
  303. package/src/graph/relationship.ts +116 -0
  304. package/src/graph/relationship_data.ts +27 -0
  305. package/src/graph/relationship_match_collector.ts +58 -0
  306. package/src/graph/relationship_reference.ts +24 -0
  307. package/src/parsing/base_parser.ts +20 -14
  308. package/src/parsing/context.ts +14 -14
  309. package/src/parsing/expressions/boolean.ts +21 -0
  310. package/src/parsing/expressions/expression.ts +34 -26
  311. package/src/parsing/expressions/expression_map.ts +3 -0
  312. package/src/parsing/expressions/operator.ts +19 -1
  313. package/src/parsing/functions/function_factory.ts +45 -45
  314. package/src/parsing/operations/call.ts +3 -1
  315. package/src/parsing/operations/create_node.ts +39 -0
  316. package/src/parsing/operations/create_relationship.ts +38 -0
  317. package/src/parsing/operations/match.ts +31 -0
  318. package/src/parsing/operations/operation.ts +3 -0
  319. package/src/parsing/operations/return.ts +11 -7
  320. package/src/parsing/operations/where.ts +10 -6
  321. package/src/parsing/parser.ts +346 -8
  322. package/src/parsing/token_to_node.ts +6 -0
  323. package/src/tokenization/keyword.ts +41 -40
  324. package/src/tokenization/token.ts +21 -1
  325. package/src/tokenization/token_type.ts +2 -1
  326. package/src/tokenization/tokenizer.ts +52 -31
  327. package/tests/compute/runner.test.ts +660 -6
  328. package/tests/extensibility.test.ts +97 -93
  329. package/tests/graph/create.test.ts +36 -0
  330. package/tests/graph/data.test.ts +58 -0
  331. package/tests/graph/match.test.ts +29 -0
  332. package/tests/parsing/parser.test.ts +276 -8
  333. package/tests/tokenization/tokenizer.test.ts +107 -17
@@ -3,7 +3,7 @@ import Tokenizer from "../tokenization/tokenizer";
3
3
 
4
4
  /**
5
5
  * Base class for parsers providing common token manipulation functionality.
6
- *
6
+ *
7
7
  * This class handles tokenization and provides utility methods for navigating
8
8
  * through tokens, peeking ahead, and checking token sequences.
9
9
  */
@@ -11,9 +11,15 @@ class BaseParser {
11
11
  private tokens: Token[] = <Token[]>[];
12
12
  private tokenIndex: number = 0;
13
13
 
14
+ constructor(tokens: Token[] | null = null) {
15
+ if (tokens !== null) {
16
+ this.tokens = tokens;
17
+ }
18
+ }
19
+
14
20
  /**
15
21
  * Tokenizes a statement and initializes the token array.
16
- *
22
+ *
17
23
  * @param statement - The input statement to tokenize
18
24
  */
19
25
  protected tokenize(statement: string): void {
@@ -30,11 +36,11 @@ class BaseParser {
30
36
 
31
37
  /**
32
38
  * Peeks at the next token without advancing the current position.
33
- *
39
+ *
34
40
  * @returns The next token, or null if at the end of the token stream
35
41
  */
36
42
  protected peek(): Token | null {
37
- if(this.tokenIndex + 1 >= this.tokens.length) {
43
+ if (this.tokenIndex + 1 >= this.tokens.length) {
38
44
  return null;
39
45
  }
40
46
  return this.tokens[this.tokenIndex + 1];
@@ -42,22 +48,22 @@ class BaseParser {
42
48
 
43
49
  /**
44
50
  * Checks if a sequence of tokens appears ahead in the token stream.
45
- *
51
+ *
46
52
  * @param tokens - The sequence of tokens to look for
47
53
  * @param skipWhitespaceAndComments - Whether to skip whitespace and comments when matching
48
54
  * @returns True if the token sequence is found ahead, false otherwise
49
55
  */
50
56
  protected ahead(tokens: Token[], skipWhitespaceAndComments: boolean = true): boolean {
51
57
  let j = 0;
52
- for(let i=this.tokenIndex; i<this.tokens.length; i++) {
53
- if(skipWhitespaceAndComments && this.tokens[i].isWhitespaceOrComment()) {
58
+ for (let i = this.tokenIndex; i < this.tokens.length; i++) {
59
+ if (skipWhitespaceAndComments && this.tokens[i].isWhitespaceOrComment()) {
54
60
  continue;
55
61
  }
56
- if(!this.tokens[i].equals(tokens[j])) {
62
+ if (!this.tokens[i].equals(tokens[j])) {
57
63
  return false;
58
64
  }
59
65
  j++;
60
- if(j === tokens.length) {
66
+ if (j === tokens.length) {
61
67
  break;
62
68
  }
63
69
  }
@@ -66,11 +72,11 @@ class BaseParser {
66
72
 
67
73
  /**
68
74
  * Gets the current token.
69
- *
75
+ *
70
76
  * @returns The current token, or EOF if at the end
71
77
  */
72
78
  protected get token(): Token {
73
- if(this.tokenIndex >= this.tokens.length) {
79
+ if (this.tokenIndex >= this.tokens.length) {
74
80
  return Token.EOF;
75
81
  }
76
82
  return this.tokens[this.tokenIndex];
@@ -78,15 +84,15 @@ class BaseParser {
78
84
 
79
85
  /**
80
86
  * Gets the previous token.
81
- *
87
+ *
82
88
  * @returns The previous token, or EOF if at the beginning
83
89
  */
84
90
  protected get previousToken(): Token {
85
- if(this.tokenIndex - 1 < 0) {
91
+ if (this.tokenIndex - 1 < 0) {
86
92
  return Token.EOF;
87
93
  }
88
94
  return this.tokens[this.tokenIndex - 1];
89
95
  }
90
96
  }
91
97
 
92
- export default BaseParser;
98
+ export default BaseParser;
@@ -2,10 +2,10 @@ import ASTNode from "./ast_node";
2
2
 
3
3
  /**
4
4
  * Maintains a stack of AST nodes to track parsing context.
5
- *
5
+ *
6
6
  * Used during parsing to maintain the current context and check for specific node types
7
7
  * in the parsing hierarchy, which helps with context-sensitive parsing decisions.
8
- *
8
+ *
9
9
  * @example
10
10
  * ```typescript
11
11
  * const context = new Context();
@@ -14,35 +14,35 @@ import ASTNode from "./ast_node";
14
14
  * ```
15
15
  */
16
16
  class Context {
17
- private stack: ASTNode[] = [];
18
-
17
+ private nodes: ASTNode[] = [];
18
+
19
19
  /**
20
20
  * Pushes a node onto the context stack.
21
- *
21
+ *
22
22
  * @param node - The AST node to push
23
23
  */
24
24
  public push(node: ASTNode): void {
25
- this.stack.push(node);
25
+ this.nodes.push(node);
26
26
  }
27
-
27
+
28
28
  /**
29
29
  * Pops the top node from the context stack.
30
- *
30
+ *
31
31
  * @returns The popped node, or undefined if the stack is empty
32
32
  */
33
33
  public pop(): ASTNode | undefined {
34
- return this.stack.pop();
34
+ return this.nodes.pop();
35
35
  }
36
-
36
+
37
37
  /**
38
- * Checks if the stack contains a node of the specified type.
39
- *
38
+ * Checks if the nodes stack contains a node of the specified type.
39
+ *
40
40
  * @param type - The constructor of the node type to search for
41
41
  * @returns True if a node of the specified type is found in the stack, false otherwise
42
42
  */
43
43
  public containsType(type: new (...args: any[]) => ASTNode): boolean {
44
- return this.stack.some((v) => v instanceof type);
44
+ return this.nodes.some((v) => v instanceof type);
45
45
  }
46
46
  }
47
47
 
48
- export default Context;
48
+ export default Context;
@@ -0,0 +1,21 @@
1
+ import ASTNode from "../ast_node";
2
+
3
+ class Boolean extends ASTNode {
4
+ private _value: boolean;
5
+ constructor(value: string) {
6
+ super();
7
+ const _value = value.toUpperCase();
8
+ if (_value === "TRUE") {
9
+ this._value = true;
10
+ } else if (_value === "FALSE") {
11
+ this._value = false;
12
+ } else {
13
+ throw new Error(`Invalid boolean value: ${value}`);
14
+ }
15
+ }
16
+ public value(): boolean {
17
+ return this._value;
18
+ }
19
+ }
20
+
21
+ export default Boolean;
@@ -1,14 +1,15 @@
1
+ import PatternExpression from "../../graph/pattern_expression";
1
2
  import ASTNode from "../ast_node";
2
3
  import AggregateFunction from "../functions/aggregate_function";
3
4
  import Reference from "./reference";
4
5
 
5
6
  /**
6
7
  * Represents an expression in the FlowQuery AST.
7
- *
8
+ *
8
9
  * Expressions are built using the Shunting Yard algorithm to handle operator
9
10
  * precedence and associativity. They can contain operands (numbers, strings, identifiers)
10
11
  * and operators (arithmetic, logical, comparison).
11
- *
12
+ *
12
13
  * @example
13
14
  * ```typescript
14
15
  * const expr = new Expression();
@@ -24,23 +25,24 @@ class Expression extends ASTNode {
24
25
  private _alias: string | null = null;
25
26
  private _overridden: any | null = null;
26
27
  private _reducers: AggregateFunction[] | null = null;
28
+ private _patterns: PatternExpression[] | null = null;
27
29
 
28
30
  /**
29
31
  * Adds a node (operand or operator) to the expression.
30
- *
32
+ *
31
33
  * Uses the Shunting Yard algorithm to maintain correct operator precedence.
32
- *
34
+ *
33
35
  * @param node - The AST node to add (operand or operator)
34
36
  */
35
37
  public addNode(node: ASTNode): void {
36
38
  /* Implements the Shunting Yard algorithm */
37
- if(node.isOperand()) {
39
+ if (node.isOperand()) {
38
40
  this.output.push(node);
39
- } else if(node.isOperator()) {
41
+ } else if (node.isOperator()) {
40
42
  const operator1: ASTNode = node;
41
- while(this.operators.length > 0) {
43
+ while (this.operators.length > 0) {
42
44
  let operator2 = this.operators[this.operators.length - 1];
43
- if(
45
+ if (
44
46
  operator2.precedence > operator1.precedence ||
45
47
  (operator2.precedence === operator1.precedence && operator1.leftAssociative)
46
48
  ) {
@@ -56,25 +58,25 @@ class Expression extends ASTNode {
56
58
 
57
59
  /**
58
60
  * Finalizes the expression by converting it to a tree structure.
59
- *
61
+ *
60
62
  * Should be called after all nodes have been added.
61
63
  */
62
64
  public finish(): void {
63
65
  let last: ASTNode | undefined;
64
- while(last = this.operators.pop()) {
66
+ while ((last = this.operators.pop())) {
65
67
  this.output.push(last);
66
- };
68
+ }
67
69
  this.addChild(this.toTree());
68
70
  }
69
71
 
70
72
  private toTree(): ASTNode {
71
73
  const node = this.output.pop() || new ASTNode();
72
- if(node.isOperator()) {
74
+ if (node.isOperator()) {
73
75
  const rhs = this.toTree();
74
76
  const lhs = this.toTree();
75
77
  node.addChild(lhs);
76
78
  node.addChild(rhs);
77
- }
79
+ }
78
80
  return node;
79
81
  }
80
82
 
@@ -83,11 +85,11 @@ class Expression extends ASTNode {
83
85
  }
84
86
 
85
87
  public value(): any {
86
- if(this._overridden !== null) {
88
+ if (this._overridden !== null) {
87
89
  return this._overridden;
88
90
  }
89
- if(this.childCount() !== 1) {
90
- throw new Error('Expected one child');
91
+ if (this.childCount() !== 1) {
92
+ throw new Error("Expected one child");
91
93
  }
92
94
  return this.children[0].value();
93
95
  }
@@ -101,31 +103,37 @@ class Expression extends ASTNode {
101
103
  }
102
104
 
103
105
  public get alias(): string | null {
104
- if(this.firstChild() instanceof Reference && this._alias === null) {
106
+ if (this.firstChild() instanceof Reference && this._alias === null) {
105
107
  return (<Reference>this.firstChild()).identifier;
106
108
  }
107
109
  return this._alias;
108
110
  }
109
111
 
110
112
  public toString(): string {
111
- if(this._alias !== null) {
113
+ if (this._alias !== null) {
112
114
  return `Expression (${this._alias})`;
113
115
  } else {
114
- return 'Expression';
116
+ return "Expression";
115
117
  }
116
118
  }
117
119
  public reducers(): AggregateFunction[] {
118
- if(this._reducers === null) {
119
- this._reducers = [...this._extract_reducers()];
120
+ if (this._reducers === null) {
121
+ this._reducers = [...this._extract(this, AggregateFunction)];
120
122
  }
121
123
  return this._reducers;
122
124
  }
123
- private *_extract_reducers(node: ASTNode = this): Generator<AggregateFunction> {
124
- if(node instanceof AggregateFunction) {
125
+ public patterns(): PatternExpression[] {
126
+ if (this._patterns === null) {
127
+ this._patterns = [...this._extract(this, PatternExpression)];
128
+ }
129
+ return this._patterns;
130
+ }
131
+ private *_extract(node: ASTNode = this, of_type: any): Generator<any> {
132
+ if (node instanceof of_type) {
125
133
  yield node;
126
134
  }
127
- for(const child of node.getChildren()) {
128
- yield* this._extract_reducers(child);
135
+ for (const child of node.getChildren()) {
136
+ yield* this._extract(child, of_type);
129
137
  }
130
138
  }
131
139
  public mappable(): boolean {
@@ -139,4 +147,4 @@ class Expression extends ASTNode {
139
147
  }
140
148
  }
141
149
 
142
- export default Expression;
150
+ export default Expression;
@@ -5,6 +5,9 @@ class ExpressionMap {
5
5
  public get(alias: string): Expression | undefined {
6
6
  return this._map.get(alias);
7
7
  }
8
+ public has(alias: string): boolean {
9
+ return this._map.has(alias);
10
+ }
8
11
  public set map(expressions: Expression[]) {
9
12
  this._map.clear();
10
13
  for (const expr of expressions) {
@@ -176,4 +176,22 @@ class Is extends Operator {
176
176
  }
177
177
  }
178
178
 
179
- export { Operator, Add, Subtract, Multiply, Divide, Modulo, Power, Equals, NotEquals, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, And, Or, Not, Is };
179
+ export {
180
+ Operator,
181
+ Add,
182
+ Subtract,
183
+ Multiply,
184
+ Divide,
185
+ Modulo,
186
+ Power,
187
+ Equals,
188
+ NotEquals,
189
+ GreaterThan,
190
+ LessThan,
191
+ GreaterThanOrEqual,
192
+ LessThanOrEqual,
193
+ And,
194
+ Or,
195
+ Not,
196
+ Is,
197
+ };
@@ -1,42 +1,41 @@
1
+ import AsyncFunction from "./async_function";
2
+ import "./avg";
3
+ import "./collect";
1
4
  import Function from "./function";
5
+ import {
6
+ AsyncDataProvider,
7
+ FunctionMetadata,
8
+ getFunctionMetadata,
9
+ getRegisteredFunctionFactory,
10
+ getRegisteredFunctionMetadata,
11
+ } from "./function_metadata";
12
+ import "./functions";
13
+ import "./join";
14
+ import "./keys";
2
15
  import PredicateFunction from "./predicate_function";
3
- // Import built-in functions to ensure their @FunctionDef decorators run
4
- import "./sum";
5
- import "./collect";
6
- import "./avg";
7
- import "./range";
16
+ import "./predicate_sum";
8
17
  import "./rand";
18
+ import "./range";
19
+ import "./replace";
9
20
  import "./round";
21
+ import "./size";
10
22
  import "./split";
11
- import "./join";
12
- import "./keys";
13
- import "./to_json";
14
- import "./replace";
15
23
  import "./stringify";
16
- import "./size";
17
- import "./functions";
18
- import "./predicate_sum";
24
+ // Import built-in functions to ensure their @FunctionDef decorators run
25
+ import "./sum";
26
+ import "./to_json";
19
27
  import "./type";
20
- import {
21
- FunctionMetadata,
22
- getRegisteredFunctionMetadata,
23
- getFunctionMetadata,
24
- getRegisteredFunctionFactory,
25
- AsyncDataProvider
26
- } from "./function_metadata";
27
- import AsyncFunction from "./async_function";
28
- import { get } from "node:http";
29
28
 
30
29
  // Re-export AsyncDataProvider for backwards compatibility
31
30
  export { AsyncDataProvider };
32
31
 
33
32
  /**
34
33
  * Factory for creating function instances by name.
35
- *
34
+ *
36
35
  * All functions are registered via the @FunctionDef decorator.
37
36
  * Maps function names (case-insensitive) to their corresponding implementation classes.
38
37
  * Supports built-in functions like sum, avg, collect, range, split, join, etc.
39
- *
38
+ *
40
39
  * @example
41
40
  * ```typescript
42
41
  * const sumFunc = FunctionFactory.create("sum");
@@ -46,7 +45,7 @@ export { AsyncDataProvider };
46
45
  class FunctionFactory {
47
46
  /**
48
47
  * Gets an async data provider by name.
49
- *
48
+ *
50
49
  * @param name - The function name (case-insensitive)
51
50
  * @returns The async data provider, or undefined if not found
52
51
  */
@@ -56,7 +55,7 @@ class FunctionFactory {
56
55
 
57
56
  /**
58
57
  * Checks if a function name is registered as an async data provider.
59
- *
58
+ *
60
59
  * @param name - The function name (case-insensitive)
61
60
  * @returns True if the function is an async data provider
62
61
  */
@@ -66,7 +65,7 @@ class FunctionFactory {
66
65
 
67
66
  /**
68
67
  * Gets metadata for a specific function.
69
- *
68
+ *
70
69
  * @param name - The function name (case-insensitive)
71
70
  * @returns The function metadata, or undefined if not found
72
71
  */
@@ -76,56 +75,58 @@ class FunctionFactory {
76
75
 
77
76
  /**
78
77
  * Lists all registered functions with their metadata.
79
- *
78
+ *
80
79
  * @param options - Optional filter options
81
80
  * @returns Array of function metadata
82
81
  */
83
- public static listFunctions(options?: {
84
- category?: string;
82
+ public static listFunctions(options?: {
83
+ category?: string;
85
84
  asyncOnly?: boolean;
86
85
  syncOnly?: boolean;
87
86
  }): FunctionMetadata[] {
88
87
  const result: FunctionMetadata[] = [];
89
-
88
+
90
89
  for (const meta of getRegisteredFunctionMetadata()) {
91
90
  if (options?.category && meta.category !== options.category) continue;
92
- if (options?.asyncOnly && meta.category !== 'async') continue;
93
- if (options?.syncOnly && meta.category === 'async') continue;
91
+ if (options?.asyncOnly && meta.category !== "async") continue;
92
+ if (options?.syncOnly && meta.category === "async") continue;
94
93
  result.push(meta);
95
94
  }
96
-
95
+
97
96
  return result;
98
97
  }
99
98
 
100
99
  /**
101
100
  * Lists all registered function names.
102
- *
101
+ *
103
102
  * @returns Array of function names
104
103
  */
105
104
  public static listFunctionNames(): string[] {
106
- return getRegisteredFunctionMetadata().map(m => m.name);
105
+ return getRegisteredFunctionMetadata().map((m) => m.name);
107
106
  }
108
107
 
109
108
  /**
110
109
  * Gets all function metadata as a JSON-serializable object for LLM consumption.
111
- *
110
+ *
112
111
  * @returns Object with functions grouped by category
113
112
  */
114
113
  public static toJSON(): { functions: FunctionMetadata[]; categories: string[] } {
115
114
  const functions = FunctionFactory.listFunctions();
116
- const categories = [...new Set(functions.map(f => f.category).filter(Boolean))] as string[];
115
+ const categories = [
116
+ ...new Set(functions.map((f) => f.category).filter(Boolean)),
117
+ ] as string[];
117
118
  return { functions, categories };
118
119
  }
119
120
 
120
121
  /**
121
122
  * Creates a function instance by name.
122
- *
123
+ *
123
124
  * @param name - The function name (case-insensitive)
124
125
  * @returns A Function instance of the appropriate type
125
126
  */
126
127
  public static create(name: string): Function {
127
128
  const lowerName: string = name.toLowerCase();
128
-
129
+
129
130
  // Check decorator-registered functions (built-ins use @FunctionDef)
130
131
  const decoratorFactory = getRegisteredFunctionFactory(lowerName);
131
132
  if (decoratorFactory) {
@@ -138,15 +139,15 @@ class FunctionFactory {
138
139
  /**
139
140
  * Creates a predicate function instance by name.
140
141
  * Predicate functions are used in WHERE clauses with quantifiers (e.g., ANY, ALL).
141
- *
142
+ *
142
143
  * @param name - The function name (case-insensitive)
143
144
  * @returns A PredicateFunction instance of the appropriate type
144
145
  */
145
146
  public static createPredicate(name: string): PredicateFunction {
146
147
  const lowerName: string = name.toLowerCase();
147
-
148
+
148
149
  // Check decorator-registered predicate functions
149
- const decoratorFactory = getRegisteredFunctionFactory(lowerName, 'predicate');
150
+ const decoratorFactory = getRegisteredFunctionFactory(lowerName, "predicate");
150
151
  if (decoratorFactory) {
151
152
  return decoratorFactory();
152
153
  }
@@ -156,13 +157,12 @@ class FunctionFactory {
156
157
 
157
158
  public static createAsync(name: string): AsyncFunction {
158
159
  const lowerName: string = name.toLowerCase();
159
- const decoratorFactory = getRegisteredFunctionFactory(lowerName, 'async');
160
+ const decoratorFactory = getRegisteredFunctionFactory(lowerName, "async");
160
161
  if (decoratorFactory) {
161
162
  return decoratorFactory() as AsyncFunction;
162
163
  }
163
164
  throw new Error(`Unknown async function: ${name}`);
164
165
  }
165
-
166
166
  }
167
167
 
168
- export default FunctionFactory;
168
+ export default FunctionFactory;
@@ -50,7 +50,9 @@ class Call extends Projection {
50
50
  const record: Map<string, any> = new Map();
51
51
  if (typeof item == "object" && !Array.isArray(item)) {
52
52
  for (const [key, value] of Object.entries(item)) {
53
- record.set(key, value);
53
+ if (this._map.has(key) || !this.hasYield) {
54
+ record.set(key, value);
55
+ }
54
56
  }
55
57
  } else {
56
58
  record.set(DEFAULT_VARIABLE_NAME, item);
@@ -0,0 +1,39 @@
1
+ import Database from "../../graph/database";
2
+ import Node from "../../graph/node";
3
+ import ASTNode from "../ast_node";
4
+ import Operation from "./operation";
5
+
6
+ class CreateNode extends Operation {
7
+ private _node: Node | null = null;
8
+ private _statement: ASTNode | null = null;
9
+ constructor(node: Node, statement: ASTNode) {
10
+ super();
11
+ this._node = node;
12
+ this._statement = statement;
13
+ }
14
+ public get node(): Node | null {
15
+ return this._node;
16
+ }
17
+ public get statement(): ASTNode | null {
18
+ return this._statement;
19
+ }
20
+ public run(): Promise<void> {
21
+ return new Promise(async (resolve, reject) => {
22
+ try {
23
+ if (this._node === null) {
24
+ throw new Error("Node is null");
25
+ }
26
+ const db: Database = Database.getInstance();
27
+ db.addNode(this._node, this._statement!);
28
+ resolve();
29
+ } catch (error) {
30
+ reject(error);
31
+ }
32
+ });
33
+ }
34
+ public get results(): Record<string, any>[] {
35
+ return [];
36
+ }
37
+ }
38
+
39
+ export default CreateNode;
@@ -0,0 +1,38 @@
1
+ import Database from "../../graph/database";
2
+ import Relationship from "../../graph/relationship";
3
+ import ASTNode from "../ast_node";
4
+ import Operation from "./operation";
5
+
6
+ class CreateRelationship extends Operation {
7
+ private _relationship: Relationship | null = null;
8
+ private _statement: ASTNode | null = null;
9
+ constructor(relationship: Relationship, statement: ASTNode) {
10
+ super();
11
+ this._relationship = relationship;
12
+ this._statement = statement;
13
+ }
14
+ public get relationship(): Relationship | null {
15
+ return this._relationship;
16
+ }
17
+ public get statement(): ASTNode | null {
18
+ return this._statement;
19
+ }
20
+ public run(): Promise<void> {
21
+ return new Promise(async (resolve, reject) => {
22
+ try {
23
+ if (this._relationship === null) {
24
+ throw new Error("Relationship is null");
25
+ }
26
+ const db = Database.getInstance();
27
+ db.addRelationship(this._relationship, this._statement!);
28
+ resolve();
29
+ } catch (error) {
30
+ reject(error);
31
+ }
32
+ });
33
+ }
34
+ public get results(): Record<string, any>[] {
35
+ return [];
36
+ }
37
+ }
38
+ export default CreateRelationship;
@@ -0,0 +1,31 @@
1
+ import Pattern from "../../graph/pattern";
2
+ import Patterns from "../../graph/patterns";
3
+ import Operation from "./operation";
4
+
5
+ class Match extends Operation {
6
+ private _patterns: Patterns | null = null;
7
+
8
+ constructor(patterns: Pattern[] = []) {
9
+ super();
10
+ this._patterns = new Patterns(patterns);
11
+ }
12
+ public get patterns(): Pattern[] {
13
+ return this._patterns ? this._patterns.patterns : [];
14
+ }
15
+ /**
16
+ * Executes the match operation by chaining the patterns together.
17
+ * After each pattern match, it continues to the next operation in the chain.
18
+ * @return Promise<void>
19
+ */
20
+ public async run(): Promise<void> {
21
+ await this._patterns!.initialize();
22
+ this._patterns!.toDoNext = async () => {
23
+ // Continue to the next operation after all patterns are matched
24
+ await this.next?.run();
25
+ };
26
+ // Kick off the graph pattern traversal
27
+ await this._patterns!.traverse();
28
+ }
29
+ }
30
+
31
+ export default Match;