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.
- package/.github/workflows/python-publish.yml +97 -0
- package/dist/compute/runner.d.ts +3 -2
- package/dist/compute/runner.d.ts.map +1 -1
- package/dist/compute/runner.js +7 -7
- package/dist/compute/runner.js.map +1 -1
- package/dist/flowquery.min.js +1 -1
- package/dist/graph/data.d.ts +31 -0
- package/dist/graph/data.d.ts.map +1 -0
- package/dist/graph/data.js +110 -0
- package/dist/graph/data.js.map +1 -0
- package/dist/graph/database.d.ts +20 -0
- package/dist/graph/database.d.ts.map +1 -0
- package/dist/graph/database.js +77 -0
- package/dist/graph/database.js.map +1 -0
- package/dist/graph/hops.d.ts +11 -0
- package/dist/graph/hops.d.ts.map +1 -0
- package/dist/graph/hops.js +25 -0
- package/dist/graph/hops.js.map +1 -0
- package/dist/graph/node.d.ts +35 -0
- package/dist/graph/node.d.ts.map +1 -0
- package/dist/graph/node.js +113 -0
- package/dist/graph/node.js.map +1 -0
- package/dist/graph/node_data.d.ts +11 -0
- package/dist/graph/node_data.d.ts.map +1 -0
- package/dist/graph/node_data.js +20 -0
- package/dist/graph/node_data.js.map +1 -0
- package/dist/graph/node_reference.d.ts +10 -0
- package/dist/graph/node_reference.d.ts.map +1 -0
- package/dist/graph/node_reference.js +52 -0
- package/dist/graph/node_reference.js.map +1 -0
- package/dist/graph/pattern.d.ts +18 -0
- package/dist/graph/pattern.d.ts.map +1 -0
- package/dist/graph/pattern.js +114 -0
- package/dist/graph/pattern.js.map +1 -0
- package/dist/graph/pattern_expression.d.ts +14 -0
- package/dist/graph/pattern_expression.d.ts.map +1 -0
- package/dist/graph/pattern_expression.js +58 -0
- package/dist/graph/pattern_expression.js.map +1 -0
- package/dist/graph/patterns.d.ts +11 -0
- package/dist/graph/patterns.d.ts.map +1 -0
- package/dist/graph/patterns.js +49 -0
- package/dist/graph/patterns.js.map +1 -0
- package/dist/graph/physical_node.d.ts +10 -0
- package/dist/graph/physical_node.d.ts.map +1 -0
- package/dist/graph/physical_node.js +40 -0
- package/dist/graph/physical_node.js.map +1 -0
- package/dist/graph/physical_relationship.d.ts +10 -0
- package/dist/graph/physical_relationship.d.ts.map +1 -0
- package/dist/graph/physical_relationship.js +40 -0
- package/dist/graph/physical_relationship.js.map +1 -0
- package/dist/graph/relationship.d.ts +40 -0
- package/dist/graph/relationship.d.ts.map +1 -0
- package/dist/graph/relationship.js +124 -0
- package/dist/graph/relationship.js.map +1 -0
- package/dist/graph/relationship_data.d.ts +12 -0
- package/dist/graph/relationship_data.d.ts.map +1 -0
- package/dist/graph/relationship_data.js +40 -0
- package/dist/graph/relationship_data.js.map +1 -0
- package/dist/graph/relationship_match_collector.d.ts +19 -0
- package/dist/graph/relationship_match_collector.d.ts.map +1 -0
- package/dist/graph/relationship_match_collector.js +55 -0
- package/dist/graph/relationship_match_collector.js.map +1 -0
- package/dist/graph/relationship_reference.d.ts +8 -0
- package/dist/graph/relationship_reference.d.ts.map +1 -0
- package/dist/graph/relationship_reference.js +37 -0
- package/dist/graph/relationship_reference.js.map +1 -0
- package/dist/parsing/base_parser.d.ts +1 -0
- package/dist/parsing/base_parser.d.ts.map +1 -1
- package/dist/parsing/base_parser.js +4 -1
- package/dist/parsing/base_parser.js.map +1 -1
- package/dist/parsing/context.d.ts +2 -2
- package/dist/parsing/context.js +5 -5
- package/dist/parsing/expressions/boolean.d.ts +8 -0
- package/dist/parsing/expressions/boolean.d.ts.map +1 -0
- package/dist/parsing/expressions/boolean.js +26 -0
- package/dist/parsing/expressions/boolean.js.map +1 -0
- package/dist/parsing/expressions/expression.d.ts +4 -1
- package/dist/parsing/expressions/expression.d.ts.map +1 -1
- package/dist/parsing/expressions/expression.js +15 -8
- package/dist/parsing/expressions/expression.js.map +1 -1
- package/dist/parsing/expressions/expression_map.d.ts +1 -0
- package/dist/parsing/expressions/expression_map.d.ts.map +1 -1
- package/dist/parsing/expressions/expression_map.js +3 -0
- package/dist/parsing/expressions/expression_map.js.map +1 -1
- package/dist/parsing/expressions/operator.d.ts +1 -1
- package/dist/parsing/expressions/operator.d.ts.map +1 -1
- package/dist/parsing/expressions/operator.js.map +1 -1
- package/dist/parsing/functions/function_factory.d.ts +13 -13
- package/dist/parsing/functions/function_factory.d.ts.map +1 -1
- package/dist/parsing/functions/function_factory.js +20 -18
- package/dist/parsing/functions/function_factory.js.map +1 -1
- package/dist/parsing/operations/call.d.ts.map +1 -1
- package/dist/parsing/operations/call.js +3 -1
- package/dist/parsing/operations/call.js.map +1 -1
- package/dist/parsing/operations/create_node.d.ts +14 -0
- package/dist/parsing/operations/create_node.d.ts.map +1 -0
- package/dist/parsing/operations/create_node.js +51 -0
- package/dist/parsing/operations/create_node.js.map +1 -0
- package/dist/parsing/operations/create_relationship.d.ts +14 -0
- package/dist/parsing/operations/create_relationship.d.ts.map +1 -0
- package/dist/parsing/operations/create_relationship.js +51 -0
- package/dist/parsing/operations/create_relationship.js.map +1 -0
- package/dist/parsing/operations/match.d.ts +15 -0
- package/dist/parsing/operations/match.d.ts.map +1 -0
- package/dist/parsing/operations/match.js +45 -0
- package/dist/parsing/operations/match.js.map +1 -0
- package/dist/parsing/operations/operation.d.ts +1 -0
- package/dist/parsing/operations/operation.d.ts.map +1 -1
- package/dist/parsing/operations/operation.js +6 -0
- package/dist/parsing/operations/operation.js.map +1 -1
- package/dist/parsing/operations/return.d.ts +1 -0
- package/dist/parsing/operations/return.d.ts.map +1 -1
- package/dist/parsing/operations/return.js +7 -1
- package/dist/parsing/operations/return.js.map +1 -1
- package/dist/parsing/operations/where.d.ts +1 -1
- package/dist/parsing/operations/where.d.ts.map +1 -1
- package/dist/parsing/operations/where.js +4 -0
- package/dist/parsing/operations/where.js.map +1 -1
- package/dist/parsing/parser.d.ts +10 -0
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +344 -5
- package/dist/parsing/parser.js.map +1 -1
- package/dist/parsing/token_to_node.d.ts.map +1 -1
- package/dist/parsing/token_to_node.js +7 -0
- package/dist/parsing/token_to_node.js.map +1 -1
- package/dist/tokenization/keyword.d.ts +1 -0
- package/dist/tokenization/keyword.d.ts.map +1 -1
- package/dist/tokenization/keyword.js +1 -0
- package/dist/tokenization/keyword.js.map +1 -1
- package/dist/tokenization/token.d.ts +4 -0
- package/dist/tokenization/token.d.ts.map +1 -1
- package/dist/tokenization/token.js +14 -1
- package/dist/tokenization/token.js.map +1 -1
- package/dist/tokenization/token_type.d.ts +1 -0
- package/dist/tokenization/token_type.d.ts.map +1 -1
- package/dist/tokenization/token_type.js +1 -0
- package/dist/tokenization/token_type.js.map +1 -1
- package/dist/tokenization/tokenizer.d.ts +2 -1
- package/dist/tokenization/tokenizer.d.ts.map +1 -1
- package/dist/tokenization/tokenizer.js +25 -12
- package/dist/tokenization/tokenizer.js.map +1 -1
- package/docs/flowquery.min.js +1 -1
- package/flowquery-py/README.md +166 -0
- package/flowquery-py/pyproject.toml +75 -0
- package/flowquery-py/setup_env.ps1 +92 -0
- package/flowquery-py/setup_env.sh +87 -0
- package/flowquery-py/src/__init__.py +34 -0
- package/flowquery-py/src/__main__.py +10 -0
- package/flowquery-py/src/compute/__init__.py +5 -0
- package/flowquery-py/src/compute/runner.py +60 -0
- package/flowquery-py/src/extensibility.py +52 -0
- package/flowquery-py/src/graph/__init__.py +31 -0
- package/flowquery-py/src/graph/data.py +118 -0
- package/flowquery-py/src/graph/database.py +82 -0
- package/flowquery-py/src/graph/hops.py +43 -0
- package/flowquery-py/src/graph/node.py +112 -0
- package/flowquery-py/src/graph/node_data.py +26 -0
- package/flowquery-py/src/graph/node_reference.py +49 -0
- package/flowquery-py/src/graph/pattern.py +125 -0
- package/flowquery-py/src/graph/pattern_expression.py +62 -0
- package/flowquery-py/src/graph/patterns.py +42 -0
- package/flowquery-py/src/graph/physical_node.py +40 -0
- package/flowquery-py/src/graph/physical_relationship.py +36 -0
- package/flowquery-py/src/graph/relationship.py +135 -0
- package/flowquery-py/src/graph/relationship_data.py +33 -0
- package/flowquery-py/src/graph/relationship_match_collector.py +77 -0
- package/flowquery-py/src/graph/relationship_reference.py +21 -0
- package/flowquery-py/src/io/__init__.py +5 -0
- package/flowquery-py/src/io/command_line.py +67 -0
- package/flowquery-py/src/parsing/__init__.py +17 -0
- package/flowquery-py/src/parsing/alias.py +20 -0
- package/flowquery-py/src/parsing/alias_option.py +11 -0
- package/flowquery-py/src/parsing/ast_node.py +146 -0
- package/flowquery-py/src/parsing/base_parser.py +84 -0
- package/flowquery-py/src/parsing/components/__init__.py +19 -0
- package/flowquery-py/src/parsing/components/csv.py +8 -0
- package/flowquery-py/src/parsing/components/from_.py +10 -0
- package/flowquery-py/src/parsing/components/headers.py +12 -0
- package/flowquery-py/src/parsing/components/json.py +8 -0
- package/flowquery-py/src/parsing/components/null.py +10 -0
- package/flowquery-py/src/parsing/components/post.py +8 -0
- package/flowquery-py/src/parsing/components/text.py +8 -0
- package/flowquery-py/src/parsing/context.py +50 -0
- package/flowquery-py/src/parsing/data_structures/__init__.py +15 -0
- package/flowquery-py/src/parsing/data_structures/associative_array.py +41 -0
- package/flowquery-py/src/parsing/data_structures/json_array.py +30 -0
- package/flowquery-py/src/parsing/data_structures/key_value_pair.py +38 -0
- package/flowquery-py/src/parsing/data_structures/lookup.py +49 -0
- package/flowquery-py/src/parsing/data_structures/range_lookup.py +42 -0
- package/flowquery-py/src/parsing/expressions/__init__.py +57 -0
- package/flowquery-py/src/parsing/expressions/boolean.py +20 -0
- package/flowquery-py/src/parsing/expressions/expression.py +138 -0
- package/flowquery-py/src/parsing/expressions/expression_map.py +26 -0
- package/flowquery-py/src/parsing/expressions/f_string.py +27 -0
- package/flowquery-py/src/parsing/expressions/identifier.py +20 -0
- package/flowquery-py/src/parsing/expressions/number.py +32 -0
- package/flowquery-py/src/parsing/expressions/operator.py +169 -0
- package/flowquery-py/src/parsing/expressions/reference.py +47 -0
- package/flowquery-py/src/parsing/expressions/string.py +27 -0
- package/flowquery-py/src/parsing/functions/__init__.py +75 -0
- package/flowquery-py/src/parsing/functions/aggregate_function.py +60 -0
- package/flowquery-py/src/parsing/functions/async_function.py +62 -0
- package/flowquery-py/src/parsing/functions/avg.py +55 -0
- package/flowquery-py/src/parsing/functions/collect.py +75 -0
- package/flowquery-py/src/parsing/functions/function.py +68 -0
- package/flowquery-py/src/parsing/functions/function_factory.py +173 -0
- package/flowquery-py/src/parsing/functions/function_metadata.py +149 -0
- package/flowquery-py/src/parsing/functions/functions.py +59 -0
- package/flowquery-py/src/parsing/functions/join.py +47 -0
- package/flowquery-py/src/parsing/functions/keys.py +34 -0
- package/flowquery-py/src/parsing/functions/predicate_function.py +46 -0
- package/flowquery-py/src/parsing/functions/predicate_sum.py +47 -0
- package/flowquery-py/src/parsing/functions/rand.py +28 -0
- package/flowquery-py/src/parsing/functions/range_.py +34 -0
- package/flowquery-py/src/parsing/functions/reducer_element.py +15 -0
- package/flowquery-py/src/parsing/functions/replace.py +37 -0
- package/flowquery-py/src/parsing/functions/round_.py +32 -0
- package/flowquery-py/src/parsing/functions/size.py +32 -0
- package/flowquery-py/src/parsing/functions/split.py +47 -0
- package/flowquery-py/src/parsing/functions/stringify.py +47 -0
- package/flowquery-py/src/parsing/functions/sum.py +51 -0
- package/flowquery-py/src/parsing/functions/to_json.py +33 -0
- package/flowquery-py/src/parsing/functions/type_.py +47 -0
- package/flowquery-py/src/parsing/functions/value_holder.py +24 -0
- package/flowquery-py/src/parsing/logic/__init__.py +15 -0
- package/flowquery-py/src/parsing/logic/case.py +29 -0
- package/flowquery-py/src/parsing/logic/else_.py +12 -0
- package/flowquery-py/src/parsing/logic/end.py +8 -0
- package/flowquery-py/src/parsing/logic/then.py +12 -0
- package/flowquery-py/src/parsing/logic/when.py +10 -0
- package/flowquery-py/src/parsing/operations/__init__.py +35 -0
- package/flowquery-py/src/parsing/operations/aggregated_return.py +24 -0
- package/flowquery-py/src/parsing/operations/aggregated_with.py +22 -0
- package/flowquery-py/src/parsing/operations/call.py +74 -0
- package/flowquery-py/src/parsing/operations/create_node.py +34 -0
- package/flowquery-py/src/parsing/operations/create_relationship.py +34 -0
- package/flowquery-py/src/parsing/operations/group_by.py +130 -0
- package/flowquery-py/src/parsing/operations/limit.py +22 -0
- package/flowquery-py/src/parsing/operations/load.py +140 -0
- package/flowquery-py/src/parsing/operations/match.py +29 -0
- package/flowquery-py/src/parsing/operations/operation.py +69 -0
- package/flowquery-py/src/parsing/operations/projection.py +21 -0
- package/flowquery-py/src/parsing/operations/return_op.py +50 -0
- package/flowquery-py/src/parsing/operations/unwind.py +37 -0
- package/flowquery-py/src/parsing/operations/where.py +41 -0
- package/flowquery-py/src/parsing/operations/with_op.py +18 -0
- package/flowquery-py/src/parsing/parser.py +1011 -0
- package/flowquery-py/src/parsing/token_to_node.py +109 -0
- package/flowquery-py/src/tokenization/__init__.py +23 -0
- package/flowquery-py/src/tokenization/keyword.py +48 -0
- package/flowquery-py/src/tokenization/operator.py +29 -0
- package/flowquery-py/src/tokenization/string_walker.py +158 -0
- package/flowquery-py/src/tokenization/symbol.py +19 -0
- package/flowquery-py/src/tokenization/token.py +659 -0
- package/flowquery-py/src/tokenization/token_mapper.py +52 -0
- package/flowquery-py/src/tokenization/token_type.py +21 -0
- package/flowquery-py/src/tokenization/tokenizer.py +214 -0
- package/flowquery-py/src/tokenization/trie.py +124 -0
- package/flowquery-py/src/utils/__init__.py +6 -0
- package/flowquery-py/src/utils/object_utils.py +20 -0
- package/flowquery-py/src/utils/string_utils.py +113 -0
- package/flowquery-py/tests/__init__.py +1 -0
- package/flowquery-py/tests/compute/__init__.py +1 -0
- package/flowquery-py/tests/compute/test_runner.py +1335 -0
- package/flowquery-py/tests/graph/__init__.py +1 -0
- package/flowquery-py/tests/graph/test_create.py +56 -0
- package/flowquery-py/tests/graph/test_data.py +73 -0
- package/flowquery-py/tests/graph/test_match.py +40 -0
- package/flowquery-py/tests/parsing/__init__.py +1 -0
- package/flowquery-py/tests/parsing/test_context.py +34 -0
- package/flowquery-py/tests/parsing/test_expression.py +49 -0
- package/flowquery-py/tests/parsing/test_parser.py +674 -0
- package/flowquery-py/tests/test_extensibility.py +611 -0
- package/flowquery-py/tests/tokenization/__init__.py +1 -0
- package/flowquery-py/tests/tokenization/test_token_mapper.py +60 -0
- package/flowquery-py/tests/tokenization/test_tokenizer.py +164 -0
- package/flowquery-py/tests/tokenization/test_trie.py +30 -0
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
- package/misc/apps/RAG/package.json +1 -1
- package/misc/apps/RAG/src/components/AdaptiveCardRenderer.tsx +76 -8
- package/misc/apps/RAG/src/components/index.ts +19 -10
- package/misc/apps/RAG/src/plugins/loaders/CatFacts.ts +21 -26
- package/misc/apps/RAG/src/plugins/loaders/FetchJson.ts +24 -25
- package/misc/apps/RAG/src/plugins/loaders/Form.ts +163 -147
- package/misc/apps/RAG/src/plugins/loaders/Llm.ts +103 -90
- package/misc/apps/RAG/src/plugins/loaders/MockData.ts +80 -130
- package/misc/apps/RAG/src/plugins/loaders/Table.ts +104 -101
- package/misc/apps/RAG/src/plugins/loaders/Weather.ts +47 -36
- package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +89 -78
- package/package.json +1 -1
- package/src/compute/runner.ts +24 -19
- package/src/graph/data.ts +112 -0
- package/src/graph/database.ts +63 -0
- package/src/graph/hops.ts +22 -0
- package/src/graph/node.ts +99 -0
- package/src/graph/node_data.ts +18 -0
- package/src/graph/node_reference.ts +33 -0
- package/src/graph/pattern.ts +101 -0
- package/src/graph/pattern_expression.ts +37 -0
- package/src/graph/patterns.ts +36 -0
- package/src/graph/physical_node.ts +23 -0
- package/src/graph/physical_relationship.ts +23 -0
- package/src/graph/relationship.ts +116 -0
- package/src/graph/relationship_data.ts +27 -0
- package/src/graph/relationship_match_collector.ts +58 -0
- package/src/graph/relationship_reference.ts +24 -0
- package/src/parsing/base_parser.ts +20 -14
- package/src/parsing/context.ts +14 -14
- package/src/parsing/expressions/boolean.ts +21 -0
- package/src/parsing/expressions/expression.ts +34 -26
- package/src/parsing/expressions/expression_map.ts +3 -0
- package/src/parsing/expressions/operator.ts +19 -1
- package/src/parsing/functions/function_factory.ts +45 -45
- package/src/parsing/operations/call.ts +3 -1
- package/src/parsing/operations/create_node.ts +39 -0
- package/src/parsing/operations/create_relationship.ts +38 -0
- package/src/parsing/operations/match.ts +31 -0
- package/src/parsing/operations/operation.ts +3 -0
- package/src/parsing/operations/return.ts +11 -7
- package/src/parsing/operations/where.ts +10 -6
- package/src/parsing/parser.ts +346 -8
- package/src/parsing/token_to_node.ts +6 -0
- package/src/tokenization/keyword.ts +41 -40
- package/src/tokenization/token.ts +21 -1
- package/src/tokenization/token_type.ts +2 -1
- package/src/tokenization/tokenizer.ts +52 -31
- package/tests/compute/runner.test.ts +660 -6
- package/tests/extensibility.test.ts +97 -93
- package/tests/graph/create.test.ts +36 -0
- package/tests/graph/data.test.ts +58 -0
- package/tests/graph/match.test.ts +29 -0
- package/tests/parsing/parser.test.ts +276 -8
- package/tests/tokenization/tokenizer.test.ts +107 -17
|
@@ -235,10 +235,16 @@ export class AdaptiveCardRenderer extends React.Component<AdaptiveCardRendererPr
|
|
|
235
235
|
this.containerRef.current.innerHTML = '';
|
|
236
236
|
|
|
237
237
|
try {
|
|
238
|
+
// Normalize the card to standard Adaptive Card format
|
|
239
|
+
let cardPayload = normalizeAdaptiveCard(card);
|
|
240
|
+
|
|
241
|
+
if (!cardPayload) {
|
|
242
|
+
throw new Error('Invalid Adaptive Card format');
|
|
243
|
+
}
|
|
244
|
+
|
|
238
245
|
// Apply data binding if data is provided
|
|
239
|
-
let cardPayload = card;
|
|
240
246
|
if (data) {
|
|
241
|
-
const template = new ACData.Template(
|
|
247
|
+
const template = new ACData.Template(cardPayload);
|
|
242
248
|
cardPayload = template.expand({
|
|
243
249
|
$root: data
|
|
244
250
|
});
|
|
@@ -299,14 +305,76 @@ export class AdaptiveCardRenderer extends React.Component<AdaptiveCardRendererPr
|
|
|
299
305
|
}
|
|
300
306
|
|
|
301
307
|
/**
|
|
302
|
-
* Helper function to check if an object looks like an Adaptive Card
|
|
308
|
+
* Helper function to check if an object looks like an Adaptive Card.
|
|
309
|
+
* Supports both standard format (type: 'AdaptiveCard') and alternative format (cardType: 'AdaptiveCard').
|
|
303
310
|
*/
|
|
304
311
|
export function isAdaptiveCard(obj: unknown): obj is Record<string, unknown> {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
312
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const card = obj as Record<string, unknown>;
|
|
317
|
+
|
|
318
|
+
// Standard Adaptive Card format
|
|
319
|
+
if (card.type === 'AdaptiveCard') {
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Alternative format with cardType/cardBody
|
|
324
|
+
if (card.cardType === 'AdaptiveCard') {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Check if it's an array containing Adaptive Cards
|
|
329
|
+
if (Array.isArray(obj) && obj.length > 0) {
|
|
330
|
+
return obj.some(item => isAdaptiveCard(item));
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Normalizes a card payload to the standard Adaptive Card format.
|
|
338
|
+
* Handles:
|
|
339
|
+
* - Arrays of cards (returns the first card)
|
|
340
|
+
* - Alternative format with cardType/cardBody properties
|
|
341
|
+
* - Standard format (passed through unchanged)
|
|
342
|
+
*/
|
|
343
|
+
export function normalizeAdaptiveCard(obj: unknown): Record<string, unknown> | null {
|
|
344
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Handle arrays - extract the first valid card
|
|
349
|
+
if (Array.isArray(obj)) {
|
|
350
|
+
for (const item of obj) {
|
|
351
|
+
const normalized = normalizeAdaptiveCard(item);
|
|
352
|
+
if (normalized) {
|
|
353
|
+
return normalized;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const card = obj as Record<string, unknown>;
|
|
360
|
+
|
|
361
|
+
// Standard format - return as-is
|
|
362
|
+
if (card.type === 'AdaptiveCard') {
|
|
363
|
+
return card;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Alternative format - convert to standard format
|
|
367
|
+
if (card.cardType === 'AdaptiveCard') {
|
|
368
|
+
return {
|
|
369
|
+
type: 'AdaptiveCard',
|
|
370
|
+
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
|
|
371
|
+
version: (card.version as string) || '1.5',
|
|
372
|
+
body: card.cardBody || card.body || [],
|
|
373
|
+
actions: card.actions || []
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return null;
|
|
310
378
|
}
|
|
311
379
|
|
|
312
380
|
export default AdaptiveCardRenderer;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
// Chat components exports
|
|
2
|
-
export { ChatContainer } from
|
|
3
|
-
export { ChatMessage } from
|
|
4
|
-
export { ChatInput } from
|
|
5
|
-
export { ApiKeySettings } from
|
|
2
|
+
export { ChatContainer } from "./ChatContainer";
|
|
3
|
+
export { ChatMessage } from "./ChatMessage";
|
|
4
|
+
export { ChatInput } from "./ChatInput";
|
|
5
|
+
export { ApiKeySettings } from "./ApiKeySettings";
|
|
6
6
|
|
|
7
7
|
// FlowQuery Runner
|
|
8
|
-
export { FlowQueryRunner } from
|
|
8
|
+
export { FlowQueryRunner } from "./FlowQueryRunner";
|
|
9
9
|
|
|
10
10
|
// Adaptive Card Renderer
|
|
11
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
AdaptiveCardRenderer,
|
|
13
|
+
isAdaptiveCard,
|
|
14
|
+
normalizeAdaptiveCard,
|
|
15
|
+
} from "./AdaptiveCardRenderer";
|
|
12
16
|
|
|
13
17
|
// FlowQuery Agent
|
|
14
|
-
export { processQuery, processQueryStream } from
|
|
15
|
-
export type {
|
|
18
|
+
export { processQuery, processQueryStream } from "./FlowQueryAgent";
|
|
19
|
+
export type {
|
|
20
|
+
AgentStep,
|
|
21
|
+
AgentResult,
|
|
22
|
+
FlowQueryAgentOptions,
|
|
23
|
+
AgentStreamCallback,
|
|
24
|
+
} from "./FlowQueryAgent";
|
|
16
25
|
|
|
17
26
|
// Types
|
|
18
|
-
export type { Message } from
|
|
19
|
-
export type { AdaptiveCardRendererProps } from
|
|
27
|
+
export type { Message } from "./ChatMessage";
|
|
28
|
+
export type { AdaptiveCardRendererProps } from "./AdaptiveCardRenderer";
|
|
@@ -1,42 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Example plugin: Fetch random cat facts from the Cat Facts API.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Usage in FlowQuery:
|
|
5
|
-
*
|
|
6
|
-
* RETURN fact.text
|
|
5
|
+
* CALL catFacts(5) YIELD text, length
|
|
7
6
|
*/
|
|
7
|
+
import { AsyncFunction, FunctionDef } from "flowquery/extensibility";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const CAT_FACTS_API = 'https://catfact.ninja/facts';
|
|
9
|
+
const CAT_FACTS_API = "https://catfact.ninja/facts";
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* CatFacts class - fetches random cat facts from the Cat Facts API.
|
|
15
13
|
*/
|
|
16
14
|
@FunctionDef({
|
|
17
|
-
description:
|
|
18
|
-
category:
|
|
15
|
+
description: "Fetches random cat facts from the Cat Facts API (catfact.ninja)",
|
|
16
|
+
category: "async",
|
|
19
17
|
parameters: [
|
|
20
18
|
{
|
|
21
|
-
name:
|
|
22
|
-
description:
|
|
23
|
-
type:
|
|
19
|
+
name: "count",
|
|
20
|
+
description: "Number of cat facts to fetch",
|
|
21
|
+
type: "number",
|
|
24
22
|
required: false,
|
|
25
|
-
default: 1
|
|
26
|
-
}
|
|
23
|
+
default: 1,
|
|
24
|
+
},
|
|
27
25
|
],
|
|
28
26
|
output: {
|
|
29
|
-
description:
|
|
30
|
-
type:
|
|
27
|
+
description: "Cat fact object",
|
|
28
|
+
type: "object",
|
|
31
29
|
properties: {
|
|
32
|
-
text: { description:
|
|
33
|
-
length: { description:
|
|
34
|
-
}
|
|
30
|
+
text: { description: "The cat fact text", type: "string" },
|
|
31
|
+
length: { description: "Length of the fact text", type: "number" },
|
|
32
|
+
},
|
|
35
33
|
},
|
|
36
|
-
examples: [
|
|
37
|
-
"LOAD JSON FROM catFacts() AS fact RETURN fact.text",
|
|
38
|
-
"LOAD JSON FROM catFacts(5) AS fact RETURN fact.text, fact.length AS length"
|
|
39
|
-
]
|
|
34
|
+
examples: ["CALL catFacts() YIELD text", "CALL catFacts(5) YIELD text, length"],
|
|
40
35
|
})
|
|
41
36
|
export class CatFacts extends AsyncFunction {
|
|
42
37
|
private readonly apiUrl: string;
|
|
@@ -48,25 +43,25 @@ export class CatFacts extends AsyncFunction {
|
|
|
48
43
|
|
|
49
44
|
/**
|
|
50
45
|
* Fetches random cat facts from the Cat Facts API.
|
|
51
|
-
*
|
|
46
|
+
*
|
|
52
47
|
* @param count - Number of cat facts to fetch (default: 1)
|
|
53
48
|
*/
|
|
54
49
|
async *generate(count: number = 1): AsyncGenerator<any, void, unknown> {
|
|
55
50
|
const url = `${this.apiUrl}?limit=${count}`;
|
|
56
51
|
const response = await fetch(url);
|
|
57
|
-
|
|
52
|
+
|
|
58
53
|
if (!response.ok) {
|
|
59
54
|
throw new Error(`Failed to fetch cat facts: ${response.statusText}`);
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
const json = await response.json();
|
|
63
58
|
const data = json.data || [];
|
|
64
|
-
|
|
59
|
+
|
|
65
60
|
for (const item of data) {
|
|
66
61
|
// Map 'fact' to 'text' for backwards compatibility with existing queries
|
|
67
62
|
yield {
|
|
68
63
|
text: item.fact,
|
|
69
|
-
length: item.length
|
|
64
|
+
length: item.length,
|
|
70
65
|
};
|
|
71
66
|
}
|
|
72
67
|
}
|
|
@@ -1,58 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Example plugin: Fetch JSON data from a URL.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Usage in FlowQuery:
|
|
5
|
-
*
|
|
6
|
-
* RETURN item.name, item.value
|
|
5
|
+
* CALL fetchJson('https://api.example.com/data') YIELD name, value
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
import { FunctionDef, AsyncFunction } from 'flowquery/extensibility';
|
|
7
|
+
import { AsyncFunction, FunctionDef } from "flowquery/extensibility";
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* FetchJson class - fetches JSON data from a URL and yields items.
|
|
13
11
|
*/
|
|
14
12
|
@FunctionDef({
|
|
15
|
-
description:
|
|
16
|
-
|
|
13
|
+
description:
|
|
14
|
+
"Fetches JSON data from a URL. If the response is an array, yields each item individually.",
|
|
15
|
+
category: "async",
|
|
17
16
|
parameters: [
|
|
18
17
|
{
|
|
19
|
-
name:
|
|
20
|
-
description:
|
|
21
|
-
type:
|
|
22
|
-
required: true
|
|
18
|
+
name: "url",
|
|
19
|
+
description: "The URL to fetch JSON from",
|
|
20
|
+
type: "string",
|
|
21
|
+
required: true,
|
|
23
22
|
},
|
|
24
23
|
{
|
|
25
|
-
name:
|
|
26
|
-
description:
|
|
27
|
-
type:
|
|
28
|
-
required: false
|
|
29
|
-
}
|
|
24
|
+
name: "options",
|
|
25
|
+
description: "Optional fetch options (headers, method, etc.)",
|
|
26
|
+
type: "object",
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
30
29
|
],
|
|
31
30
|
output: {
|
|
32
|
-
description:
|
|
33
|
-
type:
|
|
31
|
+
description: "JSON data items",
|
|
32
|
+
type: "object",
|
|
34
33
|
},
|
|
35
34
|
examples: [
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
]
|
|
35
|
+
"CALL fetchJson('https://api.example.com/users') YIELD name",
|
|
36
|
+
"CALL fetchJson('https://api.example.com/data') YIELD name, active WHERE active = true",
|
|
37
|
+
],
|
|
39
38
|
})
|
|
40
39
|
export class FetchJson extends AsyncFunction {
|
|
41
40
|
/**
|
|
42
41
|
* Fetches JSON data from a URL and yields each item if array, or the object itself.
|
|
43
|
-
*
|
|
42
|
+
*
|
|
44
43
|
* @param url - The URL to fetch JSON from
|
|
45
44
|
* @param options - Optional fetch options
|
|
46
45
|
*/
|
|
47
46
|
async *generate(url: string, options?: RequestInit): AsyncGenerator<any, void, unknown> {
|
|
48
47
|
const response = await fetch(url, options);
|
|
49
|
-
|
|
48
|
+
|
|
50
49
|
if (!response.ok) {
|
|
51
50
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
const data = await response.json();
|
|
55
|
-
|
|
54
|
+
|
|
56
55
|
if (Array.isArray(data)) {
|
|
57
56
|
for (const item of data) {
|
|
58
57
|
yield item;
|
|
@@ -63,4 +62,4 @@ export class FetchJson extends AsyncFunction {
|
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
export default FetchJson;
|
|
65
|
+
export default FetchJson;
|