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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Form plugin - transforms configuration into Adaptive Card form 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
|
* This plugin creates customizable forms with various input types including:
|
|
8
8
|
* - Text inputs (single and multi-line)
|
|
9
9
|
* - Number inputs
|
|
@@ -11,24 +11,22 @@
|
|
|
11
11
|
* - Dropdown/choice sets
|
|
12
12
|
* - Toggle switches
|
|
13
13
|
* - Choice sets (radio buttons, checkboxes)
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* Usage in FlowQuery:
|
|
16
16
|
* // Create a simple contact form:
|
|
17
|
-
*
|
|
17
|
+
* CALL form('Contact Us', [
|
|
18
18
|
* { id: 'name', type: 'text', label: 'Your Name', required: true },
|
|
19
19
|
* { id: 'email', type: 'text', label: 'Email', placeholder: 'you@example.com' },
|
|
20
20
|
* { id: 'message', type: 'textarea', label: 'Message' }
|
|
21
|
-
* ])
|
|
22
|
-
* RETURN form
|
|
21
|
+
* ]) YIELD type, body, actions
|
|
23
22
|
*/
|
|
24
|
-
|
|
25
|
-
import { FunctionDef, AsyncFunction } from 'flowquery/extensibility';
|
|
23
|
+
import { AsyncFunction, FunctionDef } from "flowquery/extensibility";
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
* Interface for Adaptive Card structure
|
|
29
27
|
*/
|
|
30
28
|
interface AdaptiveCard {
|
|
31
|
-
type:
|
|
29
|
+
type: "AdaptiveCard";
|
|
32
30
|
$schema: string;
|
|
33
31
|
version: string;
|
|
34
32
|
body: AdaptiveCardElement[];
|
|
@@ -53,7 +51,17 @@ interface FormFieldConfig {
|
|
|
53
51
|
/** Unique identifier for the field */
|
|
54
52
|
id: string;
|
|
55
53
|
/** Input type: text, textarea, number, date, time, datetime, toggle, dropdown, radio, checkbox */
|
|
56
|
-
type:
|
|
54
|
+
type:
|
|
55
|
+
| "text"
|
|
56
|
+
| "textarea"
|
|
57
|
+
| "number"
|
|
58
|
+
| "date"
|
|
59
|
+
| "time"
|
|
60
|
+
| "datetime"
|
|
61
|
+
| "toggle"
|
|
62
|
+
| "dropdown"
|
|
63
|
+
| "radio"
|
|
64
|
+
| "checkbox";
|
|
57
65
|
/** Display label for the field */
|
|
58
66
|
label: string;
|
|
59
67
|
/** Placeholder text for input fields */
|
|
@@ -79,9 +87,9 @@ interface FormFieldConfig {
|
|
|
79
87
|
/** Separator before this field */
|
|
80
88
|
separator?: boolean;
|
|
81
89
|
/** Field width: auto, stretch, or weighted value */
|
|
82
|
-
width?:
|
|
90
|
+
width?: "auto" | "stretch" | number;
|
|
83
91
|
/** Custom style for the label */
|
|
84
|
-
labelStyle?:
|
|
92
|
+
labelStyle?: "default" | "heading";
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
/**
|
|
@@ -95,22 +103,22 @@ interface FormConfig {
|
|
|
95
103
|
/** Submit button configuration */
|
|
96
104
|
submitButton?: {
|
|
97
105
|
title?: string;
|
|
98
|
-
style?:
|
|
106
|
+
style?: "default" | "positive" | "destructive";
|
|
99
107
|
/** Action URL for form submission */
|
|
100
108
|
url?: string;
|
|
101
109
|
/** Action type: submit, openUrl, or custom */
|
|
102
|
-
actionType?:
|
|
110
|
+
actionType?: "submit" | "openUrl" | "showCard";
|
|
103
111
|
};
|
|
104
112
|
/** Additional action buttons */
|
|
105
113
|
additionalActions?: Array<{
|
|
106
114
|
title: string;
|
|
107
|
-
type:
|
|
115
|
+
type: "submit" | "openUrl" | "showCard";
|
|
108
116
|
url?: string;
|
|
109
|
-
style?:
|
|
117
|
+
style?: "default" | "positive" | "destructive";
|
|
110
118
|
data?: any;
|
|
111
119
|
}>;
|
|
112
120
|
/** Card background style */
|
|
113
|
-
style?:
|
|
121
|
+
style?: "default" | "emphasis" | "good" | "attention" | "warning" | "accent";
|
|
114
122
|
/** Whether to show a reset/clear button */
|
|
115
123
|
showResetButton?: boolean;
|
|
116
124
|
/** Card schema version */
|
|
@@ -121,48 +129,48 @@ interface FormConfig {
|
|
|
121
129
|
* Form class - creates customizable Adaptive Card forms.
|
|
122
130
|
*/
|
|
123
131
|
@FunctionDef({
|
|
124
|
-
description:
|
|
125
|
-
category:
|
|
132
|
+
description: "Creates a customizable Adaptive Card form with various input types",
|
|
133
|
+
category: "async",
|
|
126
134
|
parameters: [
|
|
127
135
|
{
|
|
128
|
-
name:
|
|
129
|
-
description:
|
|
130
|
-
type:
|
|
131
|
-
required: true
|
|
136
|
+
name: "title",
|
|
137
|
+
description: "Form title displayed at the top",
|
|
138
|
+
type: "string",
|
|
139
|
+
required: true,
|
|
132
140
|
},
|
|
133
141
|
{
|
|
134
|
-
name:
|
|
135
|
-
description:
|
|
136
|
-
type:
|
|
137
|
-
required: true
|
|
142
|
+
name: "fields",
|
|
143
|
+
description: "Array of field configurations defining the form inputs",
|
|
144
|
+
type: "array",
|
|
145
|
+
required: true,
|
|
138
146
|
},
|
|
139
147
|
{
|
|
140
|
-
name:
|
|
141
|
-
description:
|
|
142
|
-
type:
|
|
143
|
-
required: false
|
|
144
|
-
}
|
|
148
|
+
name: "config",
|
|
149
|
+
description: "Optional form configuration (submit button, additional actions, styling)",
|
|
150
|
+
type: "object",
|
|
151
|
+
required: false,
|
|
152
|
+
},
|
|
145
153
|
],
|
|
146
154
|
output: {
|
|
147
|
-
description:
|
|
148
|
-
type:
|
|
155
|
+
description: "Adaptive Card JSON object with form elements",
|
|
156
|
+
type: "object",
|
|
149
157
|
properties: {
|
|
150
|
-
type: { description: 'Always "AdaptiveCard"', type:
|
|
151
|
-
$schema: { description:
|
|
152
|
-
version: { description:
|
|
153
|
-
body: { description:
|
|
154
|
-
actions: { description:
|
|
155
|
-
}
|
|
158
|
+
type: { description: 'Always "AdaptiveCard"', type: "string" },
|
|
159
|
+
$schema: { description: "Adaptive Card schema URL", type: "string" },
|
|
160
|
+
version: { description: "Adaptive Card version", type: "string" },
|
|
161
|
+
body: { description: "Card body elements including form inputs", type: "array" },
|
|
162
|
+
actions: { description: "Card actions (submit, cancel, etc.)", type: "array" },
|
|
163
|
+
},
|
|
156
164
|
},
|
|
157
165
|
examples: [
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
]
|
|
166
|
+
"CALL form('Contact Form', [{ id: 'name', type: 'text', label: 'Name', required: true }, { id: 'email', type: 'text', label: 'Email' }]) YIELD type, body, actions",
|
|
167
|
+
"CALL form('Survey', [{ id: 'rating', type: 'dropdown', label: 'Rating', choices: ['1', '2', '3', '4', '5'] }, { id: 'subscribe', type: 'toggle', label: 'Subscribe', toggleTitle: 'Yes, send me updates' }], { submitButton: { title: 'Submit Survey', style: 'positive' } }) YIELD type, body, actions",
|
|
168
|
+
],
|
|
161
169
|
})
|
|
162
170
|
export class Form extends AsyncFunction {
|
|
163
171
|
/**
|
|
164
172
|
* Creates an Adaptive Card form with the specified fields and configuration.
|
|
165
|
-
*
|
|
173
|
+
*
|
|
166
174
|
* @param title - Form title
|
|
167
175
|
* @param fields - Array of field configurations
|
|
168
176
|
* @param config - Optional form configuration
|
|
@@ -185,46 +193,46 @@ export class Form extends AsyncFunction {
|
|
|
185
193
|
config: FormConfig
|
|
186
194
|
): AdaptiveCard {
|
|
187
195
|
const card: AdaptiveCard = {
|
|
188
|
-
type:
|
|
189
|
-
$schema:
|
|
190
|
-
version: config.version ||
|
|
196
|
+
type: "AdaptiveCard",
|
|
197
|
+
$schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
198
|
+
version: config.version || "1.5",
|
|
191
199
|
body: [],
|
|
192
|
-
actions: []
|
|
200
|
+
actions: [],
|
|
193
201
|
};
|
|
194
202
|
|
|
195
203
|
// Add container with optional background style
|
|
196
204
|
const container: AdaptiveCardElement = {
|
|
197
|
-
type:
|
|
198
|
-
style: config.style ||
|
|
199
|
-
items: []
|
|
205
|
+
type: "Container",
|
|
206
|
+
style: config.style || "default",
|
|
207
|
+
items: [],
|
|
200
208
|
};
|
|
201
209
|
|
|
202
210
|
// Add title
|
|
203
211
|
container.items.push({
|
|
204
|
-
type:
|
|
212
|
+
type: "TextBlock",
|
|
205
213
|
text: title,
|
|
206
|
-
weight:
|
|
207
|
-
size:
|
|
208
|
-
wrap: true
|
|
214
|
+
weight: "Bolder",
|
|
215
|
+
size: "Large",
|
|
216
|
+
wrap: true,
|
|
209
217
|
});
|
|
210
218
|
|
|
211
219
|
// Add description if provided
|
|
212
220
|
if (config.description) {
|
|
213
221
|
container.items.push({
|
|
214
|
-
type:
|
|
222
|
+
type: "TextBlock",
|
|
215
223
|
text: config.description,
|
|
216
224
|
isSubtle: true,
|
|
217
225
|
wrap: true,
|
|
218
|
-
spacing:
|
|
226
|
+
spacing: "Small",
|
|
219
227
|
});
|
|
220
228
|
}
|
|
221
229
|
|
|
222
230
|
// Add separator after header
|
|
223
231
|
container.items.push({
|
|
224
|
-
type:
|
|
225
|
-
text:
|
|
232
|
+
type: "TextBlock",
|
|
233
|
+
text: " ",
|
|
226
234
|
separator: true,
|
|
227
|
-
spacing:
|
|
235
|
+
spacing: "Medium",
|
|
228
236
|
});
|
|
229
237
|
|
|
230
238
|
// Add form fields
|
|
@@ -250,12 +258,12 @@ export class Form extends AsyncFunction {
|
|
|
250
258
|
// Add label
|
|
251
259
|
const labelText = field.required ? `${field.label} *` : field.label;
|
|
252
260
|
elements.push({
|
|
253
|
-
type:
|
|
261
|
+
type: "TextBlock",
|
|
254
262
|
text: labelText,
|
|
255
|
-
weight: field.labelStyle ===
|
|
263
|
+
weight: field.labelStyle === "heading" ? "Bolder" : "Default",
|
|
256
264
|
wrap: true,
|
|
257
265
|
separator: field.separator || false,
|
|
258
|
-
spacing: field.separator ?
|
|
266
|
+
spacing: field.separator ? "Large" : "Default",
|
|
259
267
|
});
|
|
260
268
|
|
|
261
269
|
// Add input based on type
|
|
@@ -270,36 +278,36 @@ export class Form extends AsyncFunction {
|
|
|
270
278
|
*/
|
|
271
279
|
private createInputElement(field: FormFieldConfig): AdaptiveCardElement {
|
|
272
280
|
switch (field.type) {
|
|
273
|
-
case
|
|
281
|
+
case "text":
|
|
274
282
|
return this.createTextInput(field, false);
|
|
275
|
-
|
|
276
|
-
case
|
|
283
|
+
|
|
284
|
+
case "textarea":
|
|
277
285
|
return this.createTextInput(field, true);
|
|
278
|
-
|
|
279
|
-
case
|
|
286
|
+
|
|
287
|
+
case "number":
|
|
280
288
|
return this.createNumberInput(field);
|
|
281
|
-
|
|
282
|
-
case
|
|
289
|
+
|
|
290
|
+
case "date":
|
|
283
291
|
return this.createDateInput(field);
|
|
284
|
-
|
|
285
|
-
case
|
|
292
|
+
|
|
293
|
+
case "time":
|
|
286
294
|
return this.createTimeInput(field);
|
|
287
|
-
|
|
288
|
-
case
|
|
295
|
+
|
|
296
|
+
case "datetime":
|
|
289
297
|
return this.createDateTimeInputs(field);
|
|
290
|
-
|
|
291
|
-
case
|
|
298
|
+
|
|
299
|
+
case "toggle":
|
|
292
300
|
return this.createToggleInput(field);
|
|
293
|
-
|
|
294
|
-
case
|
|
295
|
-
return this.createChoiceSet(field,
|
|
296
|
-
|
|
297
|
-
case
|
|
298
|
-
return this.createChoiceSet(field,
|
|
299
|
-
|
|
300
|
-
case
|
|
301
|
-
return this.createChoiceSet(field,
|
|
302
|
-
|
|
301
|
+
|
|
302
|
+
case "dropdown":
|
|
303
|
+
return this.createChoiceSet(field, "compact");
|
|
304
|
+
|
|
305
|
+
case "radio":
|
|
306
|
+
return this.createChoiceSet(field, "expanded");
|
|
307
|
+
|
|
308
|
+
case "checkbox":
|
|
309
|
+
return this.createChoiceSet(field, "expanded", true);
|
|
310
|
+
|
|
303
311
|
default:
|
|
304
312
|
return this.createTextInput(field, false);
|
|
305
313
|
}
|
|
@@ -310,11 +318,11 @@ export class Form extends AsyncFunction {
|
|
|
310
318
|
*/
|
|
311
319
|
private createTextInput(field: FormFieldConfig, isMultiLine: boolean): AdaptiveCardElement {
|
|
312
320
|
const input: AdaptiveCardElement = {
|
|
313
|
-
type:
|
|
321
|
+
type: "Input.Text",
|
|
314
322
|
id: field.id,
|
|
315
|
-
placeholder: field.placeholder ||
|
|
323
|
+
placeholder: field.placeholder || "",
|
|
316
324
|
isMultiline: isMultiLine,
|
|
317
|
-
isRequired: field.required || false
|
|
325
|
+
isRequired: field.required || false,
|
|
318
326
|
};
|
|
319
327
|
|
|
320
328
|
if (field.defaultValue !== undefined) {
|
|
@@ -330,7 +338,7 @@ export class Form extends AsyncFunction {
|
|
|
330
338
|
}
|
|
331
339
|
|
|
332
340
|
if (isMultiLine) {
|
|
333
|
-
input.style =
|
|
341
|
+
input.style = "text";
|
|
334
342
|
}
|
|
335
343
|
|
|
336
344
|
return input;
|
|
@@ -341,10 +349,10 @@ export class Form extends AsyncFunction {
|
|
|
341
349
|
*/
|
|
342
350
|
private createNumberInput(field: FormFieldConfig): AdaptiveCardElement {
|
|
343
351
|
const input: AdaptiveCardElement = {
|
|
344
|
-
type:
|
|
352
|
+
type: "Input.Number",
|
|
345
353
|
id: field.id,
|
|
346
|
-
placeholder: field.placeholder ||
|
|
347
|
-
isRequired: field.required || false
|
|
354
|
+
placeholder: field.placeholder || "",
|
|
355
|
+
isRequired: field.required || false,
|
|
348
356
|
};
|
|
349
357
|
|
|
350
358
|
if (field.defaultValue !== undefined) {
|
|
@@ -371,9 +379,9 @@ export class Form extends AsyncFunction {
|
|
|
371
379
|
*/
|
|
372
380
|
private createDateInput(field: FormFieldConfig): AdaptiveCardElement {
|
|
373
381
|
const input: AdaptiveCardElement = {
|
|
374
|
-
type:
|
|
382
|
+
type: "Input.Date",
|
|
375
383
|
id: field.id,
|
|
376
|
-
isRequired: field.required || false
|
|
384
|
+
isRequired: field.required || false,
|
|
377
385
|
};
|
|
378
386
|
|
|
379
387
|
if (field.defaultValue !== undefined) {
|
|
@@ -392,9 +400,9 @@ export class Form extends AsyncFunction {
|
|
|
392
400
|
*/
|
|
393
401
|
private createTimeInput(field: FormFieldConfig): AdaptiveCardElement {
|
|
394
402
|
const input: AdaptiveCardElement = {
|
|
395
|
-
type:
|
|
403
|
+
type: "Input.Time",
|
|
396
404
|
id: field.id,
|
|
397
|
-
isRequired: field.required || false
|
|
405
|
+
isRequired: field.required || false,
|
|
398
406
|
};
|
|
399
407
|
|
|
400
408
|
if (field.defaultValue !== undefined) {
|
|
@@ -412,33 +420,39 @@ export class Form extends AsyncFunction {
|
|
|
412
420
|
* Creates date and time inputs in a column set for datetime fields.
|
|
413
421
|
*/
|
|
414
422
|
private createDateTimeInputs(field: FormFieldConfig): AdaptiveCardElement {
|
|
415
|
-
const dateValue = field.defaultValue ? String(field.defaultValue).split(
|
|
416
|
-
const timeValue = field.defaultValue
|
|
423
|
+
const dateValue = field.defaultValue ? String(field.defaultValue).split("T")[0] : undefined;
|
|
424
|
+
const timeValue = field.defaultValue
|
|
425
|
+
? String(field.defaultValue).split("T")[1]?.substring(0, 5)
|
|
426
|
+
: undefined;
|
|
417
427
|
|
|
418
428
|
return {
|
|
419
|
-
type:
|
|
429
|
+
type: "ColumnSet",
|
|
420
430
|
columns: [
|
|
421
431
|
{
|
|
422
|
-
type:
|
|
423
|
-
width:
|
|
424
|
-
items: [
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
432
|
+
type: "Column",
|
|
433
|
+
width: "stretch",
|
|
434
|
+
items: [
|
|
435
|
+
{
|
|
436
|
+
type: "Input.Date",
|
|
437
|
+
id: `${field.id}_date`,
|
|
438
|
+
isRequired: field.required || false,
|
|
439
|
+
value: dateValue,
|
|
440
|
+
},
|
|
441
|
+
],
|
|
430
442
|
},
|
|
431
443
|
{
|
|
432
|
-
type:
|
|
433
|
-
width:
|
|
434
|
-
items: [
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
444
|
+
type: "Column",
|
|
445
|
+
width: "stretch",
|
|
446
|
+
items: [
|
|
447
|
+
{
|
|
448
|
+
type: "Input.Time",
|
|
449
|
+
id: `${field.id}_time`,
|
|
450
|
+
isRequired: field.required || false,
|
|
451
|
+
value: timeValue,
|
|
452
|
+
},
|
|
453
|
+
],
|
|
454
|
+
},
|
|
455
|
+
],
|
|
442
456
|
};
|
|
443
457
|
}
|
|
444
458
|
|
|
@@ -447,16 +461,16 @@ export class Form extends AsyncFunction {
|
|
|
447
461
|
*/
|
|
448
462
|
private createToggleInput(field: FormFieldConfig): AdaptiveCardElement {
|
|
449
463
|
const input: AdaptiveCardElement = {
|
|
450
|
-
type:
|
|
464
|
+
type: "Input.Toggle",
|
|
451
465
|
id: field.id,
|
|
452
466
|
title: field.toggleTitle || field.label,
|
|
453
|
-
valueOn:
|
|
454
|
-
valueOff:
|
|
455
|
-
isRequired: field.required || false
|
|
467
|
+
valueOn: "true",
|
|
468
|
+
valueOff: "false",
|
|
469
|
+
isRequired: field.required || false,
|
|
456
470
|
};
|
|
457
471
|
|
|
458
472
|
if (field.defaultValue !== undefined) {
|
|
459
|
-
input.value = field.defaultValue ?
|
|
473
|
+
input.value = field.defaultValue ? "true" : "false";
|
|
460
474
|
}
|
|
461
475
|
|
|
462
476
|
return input;
|
|
@@ -467,25 +481,25 @@ export class Form extends AsyncFunction {
|
|
|
467
481
|
*/
|
|
468
482
|
private createChoiceSet(
|
|
469
483
|
field: FormFieldConfig,
|
|
470
|
-
style:
|
|
484
|
+
style: "compact" | "expanded",
|
|
471
485
|
isMultiSelect: boolean = false
|
|
472
486
|
): AdaptiveCardElement {
|
|
473
487
|
const choices = this.normalizeChoices(field.choices || []);
|
|
474
488
|
|
|
475
489
|
const input: AdaptiveCardElement = {
|
|
476
|
-
type:
|
|
490
|
+
type: "Input.ChoiceSet",
|
|
477
491
|
id: field.id,
|
|
478
492
|
style: style,
|
|
479
493
|
isMultiSelect: isMultiSelect,
|
|
480
494
|
isRequired: field.required || false,
|
|
481
|
-
choices: choices
|
|
495
|
+
choices: choices,
|
|
482
496
|
};
|
|
483
497
|
|
|
484
498
|
if (field.defaultValue !== undefined) {
|
|
485
499
|
input.value = String(field.defaultValue);
|
|
486
500
|
}
|
|
487
501
|
|
|
488
|
-
if (field.placeholder && style ===
|
|
502
|
+
if (field.placeholder && style === "compact") {
|
|
489
503
|
input.placeholder = field.placeholder;
|
|
490
504
|
}
|
|
491
505
|
|
|
@@ -495,9 +509,11 @@ export class Form extends AsyncFunction {
|
|
|
495
509
|
/**
|
|
496
510
|
* Normalizes choices to the expected format.
|
|
497
511
|
*/
|
|
498
|
-
private normalizeChoices(
|
|
499
|
-
|
|
500
|
-
|
|
512
|
+
private normalizeChoices(
|
|
513
|
+
choices: Array<{ title: string; value: string }> | string[]
|
|
514
|
+
): Array<{ title: string; value: string }> {
|
|
515
|
+
return choices.map((choice) => {
|
|
516
|
+
if (typeof choice === "string") {
|
|
501
517
|
return { title: choice, value: choice };
|
|
502
518
|
}
|
|
503
519
|
return choice;
|
|
@@ -513,12 +529,12 @@ export class Form extends AsyncFunction {
|
|
|
513
529
|
// Add submit button
|
|
514
530
|
const submitConfig = config.submitButton || {};
|
|
515
531
|
const submitAction: AdaptiveCardAction = {
|
|
516
|
-
type: this.getActionType(submitConfig.actionType ||
|
|
517
|
-
title: submitConfig.title ||
|
|
518
|
-
style: submitConfig.style ||
|
|
532
|
+
type: this.getActionType(submitConfig.actionType || "submit"),
|
|
533
|
+
title: submitConfig.title || "Submit",
|
|
534
|
+
style: submitConfig.style || "positive",
|
|
519
535
|
};
|
|
520
536
|
|
|
521
|
-
if (submitConfig.actionType ===
|
|
537
|
+
if (submitConfig.actionType === "openUrl" && submitConfig.url) {
|
|
522
538
|
submitAction.url = submitConfig.url;
|
|
523
539
|
}
|
|
524
540
|
|
|
@@ -527,10 +543,10 @@ export class Form extends AsyncFunction {
|
|
|
527
543
|
// Add reset button if requested
|
|
528
544
|
if (config.showResetButton) {
|
|
529
545
|
actions.push({
|
|
530
|
-
type:
|
|
531
|
-
title:
|
|
532
|
-
style:
|
|
533
|
-
data: { action:
|
|
546
|
+
type: "Action.Submit",
|
|
547
|
+
title: "Reset",
|
|
548
|
+
style: "default",
|
|
549
|
+
data: { action: "reset" },
|
|
534
550
|
});
|
|
535
551
|
}
|
|
536
552
|
|
|
@@ -540,10 +556,10 @@ export class Form extends AsyncFunction {
|
|
|
540
556
|
const action: AdaptiveCardAction = {
|
|
541
557
|
type: this.getActionType(actionConfig.type),
|
|
542
558
|
title: actionConfig.title,
|
|
543
|
-
style: actionConfig.style ||
|
|
559
|
+
style: actionConfig.style || "default",
|
|
544
560
|
};
|
|
545
561
|
|
|
546
|
-
if (actionConfig.type ===
|
|
562
|
+
if (actionConfig.type === "openUrl" && actionConfig.url) {
|
|
547
563
|
action.url = actionConfig.url;
|
|
548
564
|
}
|
|
549
565
|
|
|
@@ -563,14 +579,14 @@ export class Form extends AsyncFunction {
|
|
|
563
579
|
*/
|
|
564
580
|
private getActionType(type: string): string {
|
|
565
581
|
switch (type) {
|
|
566
|
-
case
|
|
567
|
-
return
|
|
568
|
-
case
|
|
569
|
-
return
|
|
570
|
-
case
|
|
571
|
-
return
|
|
582
|
+
case "submit":
|
|
583
|
+
return "Action.Submit";
|
|
584
|
+
case "openUrl":
|
|
585
|
+
return "Action.OpenUrl";
|
|
586
|
+
case "showCard":
|
|
587
|
+
return "Action.ShowCard";
|
|
572
588
|
default:
|
|
573
|
-
return
|
|
589
|
+
return "Action.Submit";
|
|
574
590
|
}
|
|
575
591
|
}
|
|
576
592
|
}
|