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
@@ -1,26 +1,24 @@
1
1
  /**
2
2
  * Table plugin - transforms tabular data into Adaptive Card format.
3
- *
3
+ *
4
4
  * Adaptive Cards are platform-agnostic UI snippets that can be rendered in
5
5
  * Microsoft Teams, Outlook, Windows, and other applications.
6
- *
6
+ *
7
7
  * Usage in FlowQuery:
8
8
  * // First collect data from an async provider, then pass to table:
9
- * LOAD JSON FROM mockUsers(5) AS u
10
- * WITH collect(u) AS users
11
- * LOAD JSON FROM table(users, 'Users') AS card
12
- * RETURN card
13
- *
9
+ * CALL mockUsers(5) YIELD id, name, email
10
+ * WITH collect({ id, name, email }) AS users
11
+ * CALL table(users, 'Users') YIELD type, body
12
+ *
14
13
  * Note: Async providers cannot be nested as function arguments.
15
14
  */
16
-
17
- import { FunctionDef, AsyncFunction } from 'flowquery/extensibility';
15
+ import { AsyncFunction, FunctionDef } from "flowquery/extensibility";
18
16
 
19
17
  /**
20
18
  * Interface for Adaptive Card structure
21
19
  */
22
20
  interface AdaptiveCard {
23
- type: 'AdaptiveCard';
21
+ type: "AdaptiveCard";
24
22
  $schema: string;
25
23
  version: string;
26
24
  body: AdaptiveCardElement[];
@@ -32,12 +30,12 @@ interface AdaptiveCardElement {
32
30
  }
33
31
 
34
32
  interface TableCell {
35
- type: 'TableCell';
33
+ type: "TableCell";
36
34
  items: AdaptiveCardElement[];
37
35
  }
38
36
 
39
37
  interface TableRow {
40
- type: 'TableRow';
38
+ type: "TableRow";
41
39
  cells: TableCell[];
42
40
  }
43
41
 
@@ -45,55 +43,56 @@ interface TableRow {
45
43
  * Table class - transforms tabular data into an Adaptive Card table format.
46
44
  */
47
45
  @FunctionDef({
48
- description: 'Transforms tabular data into an Adaptive Card JSON format with a table layout',
49
- category: 'async',
46
+ description: "Transforms tabular data into an Adaptive Card JSON format with a table layout",
47
+ category: "async",
50
48
  parameters: [
51
49
  {
52
- name: 'data',
53
- description: 'Array of objects or async generator to display as a table',
54
- type: 'array',
55
- required: true
50
+ name: "data",
51
+ description: "Array of objects or async generator to display as a table",
52
+ type: "array",
53
+ required: true,
56
54
  },
57
55
  {
58
- name: 'title',
59
- description: 'Optional title for the card',
60
- type: 'string',
56
+ name: "title",
57
+ description: "Optional title for the card",
58
+ type: "string",
61
59
  required: false,
62
- default: 'Data Table'
60
+ default: "Data Table",
63
61
  },
64
62
  {
65
- name: 'columns',
66
- description: 'Optional array of column names to include (defaults to all columns from first row)',
67
- type: 'array',
68
- required: false
63
+ name: "columns",
64
+ description:
65
+ "Optional array of column names to include (defaults to all columns from first row)",
66
+ type: "array",
67
+ required: false,
69
68
  },
70
69
  {
71
- name: 'maxRows',
72
- description: 'Maximum number of rows to display',
73
- type: 'number',
70
+ name: "maxRows",
71
+ description: "Maximum number of rows to display",
72
+ type: "number",
74
73
  required: false,
75
- default: 100
76
- }
74
+ default: 100,
75
+ },
77
76
  ],
78
77
  output: {
79
- description: 'Adaptive Card JSON object',
80
- type: 'object',
78
+ description: "Adaptive Card JSON object",
79
+ type: "object",
81
80
  properties: {
82
- type: { description: 'Always "AdaptiveCard"', type: 'string' },
83
- $schema: { description: 'Adaptive Card schema URL', type: 'string' },
84
- version: { description: 'Adaptive Card version', type: 'string' },
85
- body: { description: 'Card body elements including table', type: 'array' }
86
- }
81
+ type: { description: 'Always "AdaptiveCard"', type: "string" },
82
+ $schema: { description: "Adaptive Card schema URL", type: "string" },
83
+ version: { description: "Adaptive Card version", type: "string" },
84
+ body: { description: "Card body elements including table", type: "array" },
85
+ },
87
86
  },
88
87
  examples: [
89
- "LOAD JSON FROM mockUsers(5) AS u WITH collect(u) AS users LOAD JSON FROM table(users, 'User List') AS card RETURN card",
90
- "LOAD JSON FROM mockProducts(10) AS p WITH collect(p) AS products LOAD JSON FROM table(products, 'Products', ['name', 'price', 'category']) AS card RETURN card"
91
- ]
88
+ "CALL mockUsers(5) YIELD id, name, email WITH collect({ id, name, email }) AS users CALL table(users, 'User List') YIELD type, body",
89
+ "CALL mockProducts(10) YIELD name, price, category WITH collect({ name, price, category }) AS products CALL table(products, 'Products', ['name', 'price', 'category']) YIELD type, body",
90
+ ],
92
91
  })
93
92
  export class Table extends AsyncFunction {
94
93
  /**
95
94
  * Transforms data into an Adaptive Card with table layout.
96
- *
95
+ *
97
96
  * @param data - Array or async iterable of objects
98
97
  * @param title - Card title
99
98
  * @param columns - Optional column names to include
@@ -101,13 +100,13 @@ export class Table extends AsyncFunction {
101
100
  */
102
101
  async *generate(
103
102
  data: any[] | AsyncIterable<any>,
104
- title: string = 'Data Table',
103
+ title: string = "Data Table",
105
104
  columns?: string[],
106
105
  maxRows: number = 100
107
106
  ): AsyncGenerator<AdaptiveCard, void, unknown> {
108
107
  // Collect data from array or async iterable
109
108
  const rows: any[] = [];
110
-
109
+
111
110
  if (Symbol.asyncIterator in Object(data)) {
112
111
  for await (const item of data as AsyncIterable<any>) {
113
112
  rows.push(item);
@@ -137,71 +136,75 @@ export class Table extends AsyncFunction {
137
136
  */
138
137
  private createTableCard(title: string, columnNames: string[], rows: any[]): AdaptiveCard {
139
138
  const card: AdaptiveCard = {
140
- type: 'AdaptiveCard',
141
- $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
142
- version: '1.3',
143
- body: []
139
+ type: "AdaptiveCard",
140
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
141
+ version: "1.3",
142
+ body: [],
144
143
  };
145
144
 
146
145
  // Add title
147
146
  card.body.push({
148
- type: 'TextBlock',
147
+ type: "TextBlock",
149
148
  text: title,
150
- weight: 'Bolder',
151
- size: 'Large',
152
- wrap: true
149
+ weight: "Bolder",
150
+ size: "Large",
151
+ wrap: true,
153
152
  });
154
153
 
155
154
  // Add separator
156
155
  card.body.push({
157
- type: 'TextBlock',
158
- text: ' ',
159
- separator: true
156
+ type: "TextBlock",
157
+ text: " ",
158
+ separator: true,
160
159
  });
161
160
 
162
161
  // Create header row using ColumnSet
163
162
  const headerColumnSet: AdaptiveCardElement = {
164
- type: 'ColumnSet',
165
- columns: columnNames.map(col => ({
166
- type: 'Column',
167
- width: 'stretch',
168
- items: [{
169
- type: 'TextBlock',
170
- text: this.formatColumnName(col),
171
- weight: 'Bolder',
172
- wrap: true
173
- }]
163
+ type: "ColumnSet",
164
+ columns: columnNames.map((col) => ({
165
+ type: "Column",
166
+ width: "stretch",
167
+ items: [
168
+ {
169
+ type: "TextBlock",
170
+ text: this.formatColumnName(col),
171
+ weight: "Bolder",
172
+ wrap: true,
173
+ },
174
+ ],
174
175
  })),
175
- style: 'accent'
176
+ style: "accent",
176
177
  };
177
178
  card.body.push(headerColumnSet);
178
179
 
179
180
  // Add data rows using ColumnSets
180
181
  for (const row of rows) {
181
182
  const dataColumnSet: AdaptiveCardElement = {
182
- type: 'ColumnSet',
183
- columns: columnNames.map(col => ({
184
- type: 'Column',
185
- width: 'stretch',
186
- items: [{
187
- type: 'TextBlock',
188
- text: this.formatCellValue(row[col]),
189
- wrap: true
190
- }]
183
+ type: "ColumnSet",
184
+ columns: columnNames.map((col) => ({
185
+ type: "Column",
186
+ width: "stretch",
187
+ items: [
188
+ {
189
+ type: "TextBlock",
190
+ text: this.formatCellValue(row[col]),
191
+ wrap: true,
192
+ },
193
+ ],
191
194
  })),
192
- separator: true
195
+ separator: true,
193
196
  };
194
197
  card.body.push(dataColumnSet);
195
198
  }
196
199
 
197
200
  // Add row count footer
198
201
  card.body.push({
199
- type: 'TextBlock',
200
- text: `Showing ${rows.length} row${rows.length !== 1 ? 's' : ''}`,
201
- size: 'Small',
202
+ type: "TextBlock",
203
+ text: `Showing ${rows.length} row${rows.length !== 1 ? "s" : ""}`,
204
+ size: "Small",
202
205
  isSubtle: true,
203
- horizontalAlignment: 'Right',
204
- separator: true
206
+ horizontalAlignment: "Right",
207
+ separator: true,
205
208
  });
206
209
 
207
210
  return card;
@@ -212,24 +215,24 @@ export class Table extends AsyncFunction {
212
215
  */
213
216
  private createEmptyCard(title: string): AdaptiveCard {
214
217
  return {
215
- type: 'AdaptiveCard',
216
- $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
217
- version: '1.3',
218
+ type: "AdaptiveCard",
219
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
220
+ version: "1.3",
218
221
  body: [
219
222
  {
220
- type: 'TextBlock',
223
+ type: "TextBlock",
221
224
  text: title,
222
- weight: 'Bolder',
223
- size: 'Large',
224
- wrap: true
225
+ weight: "Bolder",
226
+ size: "Large",
227
+ wrap: true,
225
228
  },
226
229
  {
227
- type: 'TextBlock',
228
- text: 'No data available',
230
+ type: "TextBlock",
231
+ text: "No data available",
229
232
  isSubtle: true,
230
- wrap: true
231
- }
232
- ]
233
+ wrap: true,
234
+ },
235
+ ],
233
236
  };
234
237
  }
235
238
 
@@ -238,9 +241,9 @@ export class Table extends AsyncFunction {
238
241
  */
239
242
  private formatColumnName(name: string): string {
240
243
  return name
241
- .replace(/([A-Z])/g, ' $1') // camelCase
242
- .replace(/_/g, ' ') // snake_case
243
- .replace(/^\w/, c => c.toUpperCase())
244
+ .replace(/([A-Z])/g, " $1") // camelCase
245
+ .replace(/_/g, " ") // snake_case
246
+ .replace(/^\w/, (c) => c.toUpperCase())
244
247
  .trim();
245
248
  }
246
249
 
@@ -249,19 +252,19 @@ export class Table extends AsyncFunction {
249
252
  */
250
253
  private formatCellValue(value: any): string {
251
254
  if (value === null || value === undefined) {
252
- return '-';
255
+ return "-";
253
256
  }
254
- if (typeof value === 'boolean') {
255
- return value ? '' : '';
257
+ if (typeof value === "boolean") {
258
+ return value ? "" : "";
256
259
  }
257
- if (typeof value === 'number') {
260
+ if (typeof value === "number") {
258
261
  // Format numbers nicely
259
262
  if (Number.isInteger(value)) {
260
263
  return value.toString();
261
264
  }
262
265
  return value.toFixed(2);
263
266
  }
264
- if (typeof value === 'object') {
267
+ if (typeof value === "object") {
265
268
  return JSON.stringify(value);
266
269
  }
267
270
  return String(value);
@@ -1,52 +1,60 @@
1
1
  /**
2
2
  * Example plugin: Fetch weather forecast for a location.
3
- *
3
+ *
4
4
  * Usage in FlowQuery:
5
- * LOAD JSON FROM weather('Oslo') AS forecast
6
- * RETURN forecast
5
+ * CALL weather('Oslo') YIELD date, location, temperature, humidity
7
6
  */
7
+ import { AsyncFunction, FunctionDef } from "flowquery/extensibility";
8
8
 
9
- import { FunctionDef, AsyncFunction } from 'flowquery/extensibility';
10
-
11
- const GEOCODING_API = 'https://geocoding-api.open-meteo.com/v1/search';
12
- const WEATHER_API = 'https://api.met.no/weatherapi/locationforecast/2.0/compact';
9
+ const GEOCODING_API = "https://geocoding-api.open-meteo.com/v1/search";
10
+ const WEATHER_API = "https://api.met.no/weatherapi/locationforecast/2.0/compact";
13
11
 
14
12
  /**
15
13
  * Weather class - fetches weather forecast for a given location.
16
14
  */
17
15
  @FunctionDef({
18
- description: 'Fetches weather forecast for a location using Open-Meteo geocoding and MET Norway weather API',
19
- category: 'async',
16
+ description:
17
+ "Fetches weather forecast for a location using Open-Meteo geocoding and MET Norway weather API",
18
+ category: "async",
20
19
  parameters: [
21
20
  {
22
- name: 'location',
21
+ name: "location",
23
22
  description: 'The name of the location to get weather for (e.g., "Oslo", "New York")',
24
- type: 'string',
25
- required: true
26
- }
23
+ type: "string",
24
+ required: true,
25
+ },
27
26
  ],
28
27
  output: {
29
- description: 'Weather forecast data point with location and weather parameters',
30
- type: 'object',
28
+ description: "Weather forecast data point with location and weather parameters",
29
+ type: "object",
31
30
  properties: {
32
- date: { description: 'ISO 8601 timestamp in UTC', type: 'string' },
33
- location: { description: 'Name of the location', type: 'string' },
34
- lat: { description: 'Latitude in decimal degrees', type: 'number' },
35
- lon: { description: 'Longitude in decimal degrees', type: 'number' },
36
- temperature: { description: 'Air temperature in celsius', type: 'number' },
37
- humidity: { description: 'Relative humidity in %', type: 'number' },
38
- pressure: { description: 'Air pressure at sea level in hPa', type: 'number' },
39
- cloud_cover: { description: 'Total cloud cover in %', type: 'number' },
40
- wind_speed: { description: 'Wind speed in m/s', type: 'number' },
41
- wind_direction: { description: 'Wind direction in degrees (0=N, 90=E, 180=S, 270=W)', type: 'number' },
42
- precipitation: { description: 'Expected precipitation in mm (next hour if available)', type: 'number' },
43
- symbol: { description: 'Weather symbol code (e.g., "partlycloudy_day", "rain")', type: 'string' }
44
- }
31
+ date: { description: "ISO 8601 timestamp in UTC", type: "string" },
32
+ location: { description: "Name of the location", type: "string" },
33
+ lat: { description: "Latitude in decimal degrees", type: "number" },
34
+ lon: { description: "Longitude in decimal degrees", type: "number" },
35
+ temperature: { description: "Air temperature in celsius", type: "number" },
36
+ humidity: { description: "Relative humidity in %", type: "number" },
37
+ pressure: { description: "Air pressure at sea level in hPa", type: "number" },
38
+ cloud_cover: { description: "Total cloud cover in %", type: "number" },
39
+ wind_speed: { description: "Wind speed in m/s", type: "number" },
40
+ wind_direction: {
41
+ description: "Wind direction in degrees (0=N, 90=E, 180=S, 270=W)",
42
+ type: "number",
43
+ },
44
+ precipitation: {
45
+ description: "Expected precipitation in mm (next hour if available)",
46
+ type: "number",
47
+ },
48
+ symbol: {
49
+ description: 'Weather symbol code (e.g., "partlycloudy_day", "rain")',
50
+ type: "string",
51
+ },
52
+ },
45
53
  },
46
54
  examples: [
47
- "LOAD JSON FROM weather('Oslo') AS forecast RETURN forecast",
48
- "LOAD JSON FROM weather('London') AS forecast RETURN forecast[0]"
49
- ]
55
+ "CALL weather('Oslo') YIELD date, location, temperature, humidity",
56
+ "CALL weather('London') YIELD date, location, temperature, wind_speed, precipitation",
57
+ ],
50
58
  })
51
59
  export class Weather extends AsyncFunction {
52
60
  private readonly geocodingApiUrl: string;
@@ -60,7 +68,7 @@ export class Weather extends AsyncFunction {
60
68
 
61
69
  /**
62
70
  * Fetches weather forecast for a given location.
63
- *
71
+ *
64
72
  * @param location - The name of the location to get weather for
65
73
  */
66
74
  async *generate(location: string): AsyncGenerator<any, void, unknown> {
@@ -87,8 +95,8 @@ export class Weather extends AsyncFunction {
87
95
  const weatherResponse = await fetch(weatherUrl, {
88
96
  headers: {
89
97
  // MET Norway API requires a User-Agent header
90
- 'User-Agent': 'FlowQuery-RAG/1.0'
91
- }
98
+ "User-Agent": "FlowQuery-RAG/1.0",
99
+ },
92
100
  });
93
101
 
94
102
  if (!weatherResponse.ok) {
@@ -117,8 +125,11 @@ export class Weather extends AsyncFunction {
117
125
  cloud_cover: instant.cloud_area_fraction,
118
126
  wind_speed: instant.wind_speed,
119
127
  wind_direction: instant.wind_from_direction,
120
- precipitation: next1h.details?.precipitation_amount ?? next6h.details?.precipitation_amount ?? null,
121
- symbol: next1h.summary?.symbol_code ?? next6h.summary?.symbol_code ?? null
128
+ precipitation:
129
+ next1h.details?.precipitation_amount ??
130
+ next6h.details?.precipitation_amount ??
131
+ null,
132
+ symbol: next1h.summary?.symbol_code ?? next6h.summary?.symbol_code ?? null,
122
133
  };
123
134
  }
124
135
  }