flowquery 1.0.46 → 1.0.48
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/dist/flowquery.min.js +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/parsing/data_structures/list_comprehension.d.ts +56 -0
- package/dist/parsing/data_structures/list_comprehension.d.ts.map +1 -0
- package/dist/parsing/data_structures/list_comprehension.js +102 -0
- package/dist/parsing/data_structures/list_comprehension.js.map +1 -0
- package/dist/parsing/parser.d.ts +18 -0
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +92 -0
- package/dist/parsing/parser.js.map +1 -1
- package/package.json +4 -1
- package/.editorconfig +0 -21
- package/.gitattributes +0 -3
- package/.github/workflows/npm-publish.yml +0 -32
- package/.github/workflows/python-publish.yml +0 -143
- package/.github/workflows/release.yml +0 -107
- package/.husky/pre-commit +0 -28
- package/.prettierrc +0 -22
- package/CODE_OF_CONDUCT.md +0 -10
- package/FlowQueryLogoIcon.png +0 -0
- package/SECURITY.md +0 -14
- package/SUPPORT.md +0 -13
- package/docs/flowquery.min.js +0 -1
- package/docs/index.html +0 -105
- package/flowquery-py/CONTRIBUTING.md +0 -127
- package/flowquery-py/README.md +0 -67
- package/flowquery-py/misc/data/test.json +0 -10
- package/flowquery-py/misc/data/users.json +0 -242
- package/flowquery-py/notebooks/TestFlowQuery.ipynb +0 -440
- package/flowquery-py/pyproject.toml +0 -121
- package/flowquery-py/setup_env.ps1 +0 -92
- package/flowquery-py/setup_env.sh +0 -87
- package/flowquery-py/src/__init__.py +0 -38
- package/flowquery-py/src/__main__.py +0 -10
- package/flowquery-py/src/compute/__init__.py +0 -6
- package/flowquery-py/src/compute/flowquery.py +0 -68
- package/flowquery-py/src/compute/runner.py +0 -64
- package/flowquery-py/src/extensibility.py +0 -52
- package/flowquery-py/src/graph/__init__.py +0 -31
- package/flowquery-py/src/graph/data.py +0 -136
- package/flowquery-py/src/graph/database.py +0 -141
- package/flowquery-py/src/graph/hops.py +0 -43
- package/flowquery-py/src/graph/node.py +0 -143
- package/flowquery-py/src/graph/node_data.py +0 -26
- package/flowquery-py/src/graph/node_reference.py +0 -50
- package/flowquery-py/src/graph/pattern.py +0 -115
- package/flowquery-py/src/graph/pattern_expression.py +0 -67
- package/flowquery-py/src/graph/patterns.py +0 -42
- package/flowquery-py/src/graph/physical_node.py +0 -41
- package/flowquery-py/src/graph/physical_relationship.py +0 -36
- package/flowquery-py/src/graph/relationship.py +0 -193
- package/flowquery-py/src/graph/relationship_data.py +0 -36
- package/flowquery-py/src/graph/relationship_match_collector.py +0 -85
- package/flowquery-py/src/graph/relationship_reference.py +0 -21
- package/flowquery-py/src/io/__init__.py +0 -5
- package/flowquery-py/src/io/command_line.py +0 -108
- package/flowquery-py/src/parsing/__init__.py +0 -17
- package/flowquery-py/src/parsing/alias.py +0 -20
- package/flowquery-py/src/parsing/alias_option.py +0 -11
- package/flowquery-py/src/parsing/ast_node.py +0 -147
- package/flowquery-py/src/parsing/base_parser.py +0 -84
- package/flowquery-py/src/parsing/components/__init__.py +0 -19
- package/flowquery-py/src/parsing/components/csv.py +0 -8
- package/flowquery-py/src/parsing/components/from_.py +0 -12
- package/flowquery-py/src/parsing/components/headers.py +0 -12
- package/flowquery-py/src/parsing/components/json.py +0 -8
- package/flowquery-py/src/parsing/components/null.py +0 -10
- package/flowquery-py/src/parsing/components/post.py +0 -8
- package/flowquery-py/src/parsing/components/text.py +0 -8
- package/flowquery-py/src/parsing/context.py +0 -50
- package/flowquery-py/src/parsing/data_structures/__init__.py +0 -15
- package/flowquery-py/src/parsing/data_structures/associative_array.py +0 -41
- package/flowquery-py/src/parsing/data_structures/json_array.py +0 -30
- package/flowquery-py/src/parsing/data_structures/key_value_pair.py +0 -38
- package/flowquery-py/src/parsing/data_structures/lookup.py +0 -51
- package/flowquery-py/src/parsing/data_structures/range_lookup.py +0 -42
- package/flowquery-py/src/parsing/expressions/__init__.py +0 -61
- package/flowquery-py/src/parsing/expressions/boolean.py +0 -20
- package/flowquery-py/src/parsing/expressions/expression.py +0 -141
- package/flowquery-py/src/parsing/expressions/expression_map.py +0 -26
- package/flowquery-py/src/parsing/expressions/f_string.py +0 -27
- package/flowquery-py/src/parsing/expressions/identifier.py +0 -21
- package/flowquery-py/src/parsing/expressions/number.py +0 -32
- package/flowquery-py/src/parsing/expressions/operator.py +0 -271
- package/flowquery-py/src/parsing/expressions/reference.py +0 -47
- package/flowquery-py/src/parsing/expressions/string.py +0 -27
- package/flowquery-py/src/parsing/functions/__init__.py +0 -127
- package/flowquery-py/src/parsing/functions/aggregate_function.py +0 -60
- package/flowquery-py/src/parsing/functions/async_function.py +0 -65
- package/flowquery-py/src/parsing/functions/avg.py +0 -55
- package/flowquery-py/src/parsing/functions/coalesce.py +0 -43
- package/flowquery-py/src/parsing/functions/collect.py +0 -75
- package/flowquery-py/src/parsing/functions/count.py +0 -79
- package/flowquery-py/src/parsing/functions/date_.py +0 -61
- package/flowquery-py/src/parsing/functions/datetime_.py +0 -62
- package/flowquery-py/src/parsing/functions/duration.py +0 -159
- package/flowquery-py/src/parsing/functions/element_id.py +0 -50
- package/flowquery-py/src/parsing/functions/function.py +0 -68
- package/flowquery-py/src/parsing/functions/function_factory.py +0 -170
- package/flowquery-py/src/parsing/functions/function_metadata.py +0 -148
- package/flowquery-py/src/parsing/functions/functions.py +0 -67
- package/flowquery-py/src/parsing/functions/head.py +0 -39
- package/flowquery-py/src/parsing/functions/id_.py +0 -49
- package/flowquery-py/src/parsing/functions/join.py +0 -49
- package/flowquery-py/src/parsing/functions/keys.py +0 -34
- package/flowquery-py/src/parsing/functions/last.py +0 -39
- package/flowquery-py/src/parsing/functions/localdatetime.py +0 -60
- package/flowquery-py/src/parsing/functions/localtime.py +0 -57
- package/flowquery-py/src/parsing/functions/max_.py +0 -49
- package/flowquery-py/src/parsing/functions/min_.py +0 -49
- package/flowquery-py/src/parsing/functions/nodes.py +0 -48
- package/flowquery-py/src/parsing/functions/predicate_function.py +0 -47
- package/flowquery-py/src/parsing/functions/predicate_sum.py +0 -49
- package/flowquery-py/src/parsing/functions/properties.py +0 -50
- package/flowquery-py/src/parsing/functions/rand.py +0 -28
- package/flowquery-py/src/parsing/functions/range_.py +0 -41
- package/flowquery-py/src/parsing/functions/reducer_element.py +0 -15
- package/flowquery-py/src/parsing/functions/relationships.py +0 -46
- package/flowquery-py/src/parsing/functions/replace.py +0 -39
- package/flowquery-py/src/parsing/functions/round_.py +0 -34
- package/flowquery-py/src/parsing/functions/schema.py +0 -40
- package/flowquery-py/src/parsing/functions/size.py +0 -34
- package/flowquery-py/src/parsing/functions/split.py +0 -54
- package/flowquery-py/src/parsing/functions/string_distance.py +0 -92
- package/flowquery-py/src/parsing/functions/stringify.py +0 -49
- package/flowquery-py/src/parsing/functions/substring.py +0 -76
- package/flowquery-py/src/parsing/functions/sum.py +0 -51
- package/flowquery-py/src/parsing/functions/tail.py +0 -37
- package/flowquery-py/src/parsing/functions/temporal_utils.py +0 -186
- package/flowquery-py/src/parsing/functions/time_.py +0 -57
- package/flowquery-py/src/parsing/functions/timestamp.py +0 -37
- package/flowquery-py/src/parsing/functions/to_float.py +0 -46
- package/flowquery-py/src/parsing/functions/to_integer.py +0 -46
- package/flowquery-py/src/parsing/functions/to_json.py +0 -35
- package/flowquery-py/src/parsing/functions/to_lower.py +0 -37
- package/flowquery-py/src/parsing/functions/to_string.py +0 -41
- package/flowquery-py/src/parsing/functions/trim.py +0 -37
- package/flowquery-py/src/parsing/functions/type_.py +0 -47
- package/flowquery-py/src/parsing/functions/value_holder.py +0 -24
- package/flowquery-py/src/parsing/logic/__init__.py +0 -15
- package/flowquery-py/src/parsing/logic/case.py +0 -28
- package/flowquery-py/src/parsing/logic/else_.py +0 -12
- package/flowquery-py/src/parsing/logic/end.py +0 -8
- package/flowquery-py/src/parsing/logic/then.py +0 -12
- package/flowquery-py/src/parsing/logic/when.py +0 -12
- package/flowquery-py/src/parsing/operations/__init__.py +0 -46
- package/flowquery-py/src/parsing/operations/aggregated_return.py +0 -25
- package/flowquery-py/src/parsing/operations/aggregated_with.py +0 -22
- package/flowquery-py/src/parsing/operations/call.py +0 -73
- package/flowquery-py/src/parsing/operations/create_node.py +0 -35
- package/flowquery-py/src/parsing/operations/create_relationship.py +0 -35
- package/flowquery-py/src/parsing/operations/delete_node.py +0 -29
- package/flowquery-py/src/parsing/operations/delete_relationship.py +0 -29
- package/flowquery-py/src/parsing/operations/group_by.py +0 -148
- package/flowquery-py/src/parsing/operations/limit.py +0 -33
- package/flowquery-py/src/parsing/operations/load.py +0 -148
- package/flowquery-py/src/parsing/operations/match.py +0 -52
- package/flowquery-py/src/parsing/operations/operation.py +0 -69
- package/flowquery-py/src/parsing/operations/order_by.py +0 -114
- package/flowquery-py/src/parsing/operations/projection.py +0 -21
- package/flowquery-py/src/parsing/operations/return_op.py +0 -88
- package/flowquery-py/src/parsing/operations/union.py +0 -115
- package/flowquery-py/src/parsing/operations/union_all.py +0 -17
- package/flowquery-py/src/parsing/operations/unwind.py +0 -42
- package/flowquery-py/src/parsing/operations/where.py +0 -43
- package/flowquery-py/src/parsing/operations/with_op.py +0 -18
- package/flowquery-py/src/parsing/parser.py +0 -1384
- package/flowquery-py/src/parsing/parser_state.py +0 -26
- package/flowquery-py/src/parsing/token_to_node.py +0 -109
- package/flowquery-py/src/tokenization/__init__.py +0 -23
- package/flowquery-py/src/tokenization/keyword.py +0 -54
- package/flowquery-py/src/tokenization/operator.py +0 -29
- package/flowquery-py/src/tokenization/string_walker.py +0 -158
- package/flowquery-py/src/tokenization/symbol.py +0 -19
- package/flowquery-py/src/tokenization/token.py +0 -693
- package/flowquery-py/src/tokenization/token_mapper.py +0 -53
- package/flowquery-py/src/tokenization/token_type.py +0 -21
- package/flowquery-py/src/tokenization/tokenizer.py +0 -214
- package/flowquery-py/src/tokenization/trie.py +0 -125
- package/flowquery-py/src/utils/__init__.py +0 -6
- package/flowquery-py/src/utils/object_utils.py +0 -20
- package/flowquery-py/src/utils/string_utils.py +0 -113
- package/flowquery-py/tests/__init__.py +0 -1
- package/flowquery-py/tests/compute/__init__.py +0 -1
- package/flowquery-py/tests/compute/test_runner.py +0 -4902
- package/flowquery-py/tests/graph/__init__.py +0 -1
- package/flowquery-py/tests/graph/test_create.py +0 -56
- package/flowquery-py/tests/graph/test_data.py +0 -73
- package/flowquery-py/tests/graph/test_match.py +0 -40
- package/flowquery-py/tests/parsing/__init__.py +0 -1
- package/flowquery-py/tests/parsing/test_context.py +0 -34
- package/flowquery-py/tests/parsing/test_expression.py +0 -248
- package/flowquery-py/tests/parsing/test_parser.py +0 -1237
- package/flowquery-py/tests/test_extensibility.py +0 -611
- package/flowquery-py/tests/tokenization/__init__.py +0 -1
- package/flowquery-py/tests/tokenization/test_token_mapper.py +0 -60
- package/flowquery-py/tests/tokenization/test_tokenizer.py +0 -198
- package/flowquery-py/tests/tokenization/test_trie.py +0 -30
- package/flowquery-vscode/.vscode-test.mjs +0 -5
- package/flowquery-vscode/.vscodeignore +0 -13
- package/flowquery-vscode/LICENSE +0 -21
- package/flowquery-vscode/README.md +0 -11
- package/flowquery-vscode/demo/FlowQueryVSCodeDemo.gif +0 -0
- package/flowquery-vscode/eslint.config.mjs +0 -25
- package/flowquery-vscode/extension.js +0 -508
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +0 -1
- package/flowquery-vscode/flowquery-worker.js +0 -66
- package/flowquery-vscode/images/FlowQueryLogoIcon.png +0 -0
- package/flowquery-vscode/jsconfig.json +0 -13
- package/flowquery-vscode/libs/page.css +0 -53
- package/flowquery-vscode/libs/table.css +0 -13
- package/flowquery-vscode/libs/tabs.css +0 -66
- package/flowquery-vscode/package-lock.json +0 -2917
- package/flowquery-vscode/package.json +0 -51
- package/flowquery-vscode/test/extension.test.js +0 -196
- package/flowquery-vscode/test/worker.test.js +0 -25
- package/flowquery-vscode/vsc-extension-quickstart.md +0 -42
- package/jest.config.js +0 -14
- package/misc/apps/RAG/README.md +0 -29
- package/misc/apps/RAG/data/chats.json +0 -302
- package/misc/apps/RAG/data/emails.json +0 -182
- package/misc/apps/RAG/data/events.json +0 -226
- package/misc/apps/RAG/data/files.json +0 -172
- package/misc/apps/RAG/data/users.json +0 -158
- package/misc/apps/RAG/jest.config.js +0 -21
- package/misc/apps/RAG/package.json +0 -48
- package/misc/apps/RAG/public/index.html +0 -18
- package/misc/apps/RAG/src/App.css +0 -42
- package/misc/apps/RAG/src/App.tsx +0 -50
- package/misc/apps/RAG/src/components/AdaptiveCardRenderer.css +0 -172
- package/misc/apps/RAG/src/components/AdaptiveCardRenderer.tsx +0 -380
- package/misc/apps/RAG/src/components/ApiKeySettings.tsx +0 -245
- package/misc/apps/RAG/src/components/ChatContainer.css +0 -67
- package/misc/apps/RAG/src/components/ChatContainer.tsx +0 -242
- package/misc/apps/RAG/src/components/ChatInput.css +0 -23
- package/misc/apps/RAG/src/components/ChatInput.tsx +0 -76
- package/misc/apps/RAG/src/components/ChatMessage.css +0 -160
- package/misc/apps/RAG/src/components/ChatMessage.tsx +0 -286
- package/misc/apps/RAG/src/components/FlowQueryAgent.ts +0 -708
- package/misc/apps/RAG/src/components/FlowQueryRunner.css +0 -113
- package/misc/apps/RAG/src/components/FlowQueryRunner.tsx +0 -371
- package/misc/apps/RAG/src/components/index.ts +0 -28
- package/misc/apps/RAG/src/graph/index.ts +0 -19
- package/misc/apps/RAG/src/graph/initializeGraph.ts +0 -254
- package/misc/apps/RAG/src/index.tsx +0 -29
- package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +0 -327
- package/misc/apps/RAG/src/prompts/index.ts +0 -10
- package/misc/apps/RAG/src/tests/graph.test.ts +0 -35
- package/misc/apps/RAG/src/utils/FlowQueryExecutor.ts +0 -130
- package/misc/apps/RAG/src/utils/FlowQueryExtractor.ts +0 -208
- package/misc/apps/RAG/src/utils/Llm.ts +0 -248
- package/misc/apps/RAG/src/utils/index.ts +0 -12
- package/misc/apps/RAG/tsconfig.json +0 -22
- package/misc/apps/RAG/webpack.config.js +0 -43
- package/misc/apps/README.md +0 -1
- package/misc/queries/analyze_catfacts.cql +0 -75
- package/misc/queries/azure_openai_completions.cql +0 -13
- package/misc/queries/azure_openai_models.cql +0 -9
- package/misc/queries/mock_pipeline.cql +0 -84
- package/misc/queries/openai_completions.cql +0 -15
- package/misc/queries/openai_models.cql +0 -13
- package/misc/queries/test.cql +0 -6
- package/misc/queries/tool_inference.cql +0 -24
- package/misc/queries/wisdom.cql +0 -6
- package/misc/queries/wisdom_letter_histogram.cql +0 -8
- package/src/compute/flowquery.ts +0 -46
- package/src/compute/runner.ts +0 -66
- package/src/extensibility.ts +0 -45
- package/src/graph/data.ts +0 -130
- package/src/graph/database.ts +0 -143
- package/src/graph/hops.ts +0 -22
- package/src/graph/node.ts +0 -122
- package/src/graph/node_data.ts +0 -18
- package/src/graph/node_reference.ts +0 -38
- package/src/graph/pattern.ts +0 -110
- package/src/graph/pattern_expression.ts +0 -48
- package/src/graph/patterns.ts +0 -36
- package/src/graph/physical_node.ts +0 -23
- package/src/graph/physical_relationship.ts +0 -23
- package/src/graph/relationship.ts +0 -167
- package/src/graph/relationship_data.ts +0 -31
- package/src/graph/relationship_match_collector.ts +0 -64
- package/src/graph/relationship_reference.ts +0 -25
- package/src/index.browser.ts +0 -46
- package/src/index.node.ts +0 -55
- package/src/index.ts +0 -12
- package/src/io/command_line.ts +0 -74
- package/src/parsing/alias.ts +0 -23
- package/src/parsing/alias_option.ts +0 -5
- package/src/parsing/ast_node.ts +0 -153
- package/src/parsing/base_parser.ts +0 -98
- package/src/parsing/components/csv.ts +0 -9
- package/src/parsing/components/from.ts +0 -12
- package/src/parsing/components/headers.ts +0 -12
- package/src/parsing/components/json.ts +0 -9
- package/src/parsing/components/null.ts +0 -9
- package/src/parsing/components/post.ts +0 -9
- package/src/parsing/components/text.ts +0 -9
- package/src/parsing/context.ts +0 -54
- package/src/parsing/data_structures/associative_array.ts +0 -43
- package/src/parsing/data_structures/json_array.ts +0 -31
- package/src/parsing/data_structures/key_value_pair.ts +0 -37
- package/src/parsing/data_structures/lookup.ts +0 -44
- package/src/parsing/data_structures/range_lookup.ts +0 -36
- package/src/parsing/expressions/boolean.ts +0 -21
- package/src/parsing/expressions/expression.ts +0 -150
- package/src/parsing/expressions/expression_map.ts +0 -22
- package/src/parsing/expressions/f_string.ts +0 -26
- package/src/parsing/expressions/identifier.ts +0 -22
- package/src/parsing/expressions/number.ts +0 -40
- package/src/parsing/expressions/operator.ts +0 -354
- package/src/parsing/expressions/reference.ts +0 -45
- package/src/parsing/expressions/string.ts +0 -34
- package/src/parsing/functions/aggregate_function.ts +0 -58
- package/src/parsing/functions/async_function.ts +0 -64
- package/src/parsing/functions/avg.ts +0 -47
- package/src/parsing/functions/coalesce.ts +0 -49
- package/src/parsing/functions/collect.ts +0 -54
- package/src/parsing/functions/count.ts +0 -54
- package/src/parsing/functions/date.ts +0 -63
- package/src/parsing/functions/datetime.ts +0 -63
- package/src/parsing/functions/duration.ts +0 -143
- package/src/parsing/functions/element_id.ts +0 -51
- package/src/parsing/functions/function.ts +0 -60
- package/src/parsing/functions/function_factory.ts +0 -195
- package/src/parsing/functions/function_metadata.ts +0 -217
- package/src/parsing/functions/functions.ts +0 -70
- package/src/parsing/functions/head.ts +0 -42
- package/src/parsing/functions/id.ts +0 -51
- package/src/parsing/functions/join.ts +0 -40
- package/src/parsing/functions/keys.ts +0 -29
- package/src/parsing/functions/last.ts +0 -42
- package/src/parsing/functions/localdatetime.ts +0 -63
- package/src/parsing/functions/localtime.ts +0 -58
- package/src/parsing/functions/max.ts +0 -37
- package/src/parsing/functions/min.ts +0 -37
- package/src/parsing/functions/nodes.ts +0 -54
- package/src/parsing/functions/predicate_function.ts +0 -48
- package/src/parsing/functions/predicate_sum.ts +0 -47
- package/src/parsing/functions/properties.ts +0 -56
- package/src/parsing/functions/rand.ts +0 -21
- package/src/parsing/functions/range.ts +0 -37
- package/src/parsing/functions/reducer_element.ts +0 -10
- package/src/parsing/functions/relationships.ts +0 -52
- package/src/parsing/functions/replace.ts +0 -38
- package/src/parsing/functions/round.ts +0 -28
- package/src/parsing/functions/schema.ts +0 -39
- package/src/parsing/functions/size.ts +0 -28
- package/src/parsing/functions/split.ts +0 -45
- package/src/parsing/functions/string_distance.ts +0 -83
- package/src/parsing/functions/stringify.ts +0 -37
- package/src/parsing/functions/substring.ts +0 -68
- package/src/parsing/functions/sum.ts +0 -41
- package/src/parsing/functions/tail.ts +0 -39
- package/src/parsing/functions/temporal_utils.ts +0 -180
- package/src/parsing/functions/time.ts +0 -58
- package/src/parsing/functions/timestamp.ts +0 -37
- package/src/parsing/functions/to_float.ts +0 -50
- package/src/parsing/functions/to_integer.ts +0 -50
- package/src/parsing/functions/to_json.ts +0 -28
- package/src/parsing/functions/to_lower.ts +0 -28
- package/src/parsing/functions/to_string.ts +0 -32
- package/src/parsing/functions/trim.ts +0 -28
- package/src/parsing/functions/type.ts +0 -39
- package/src/parsing/functions/value_holder.ts +0 -13
- package/src/parsing/logic/case.ts +0 -26
- package/src/parsing/logic/else.ts +0 -12
- package/src/parsing/logic/end.ts +0 -9
- package/src/parsing/logic/then.ts +0 -12
- package/src/parsing/logic/when.ts +0 -12
- package/src/parsing/operations/aggregated_return.ts +0 -22
- package/src/parsing/operations/aggregated_with.ts +0 -18
- package/src/parsing/operations/call.ts +0 -69
- package/src/parsing/operations/create_node.ts +0 -39
- package/src/parsing/operations/create_relationship.ts +0 -38
- package/src/parsing/operations/delete_node.ts +0 -33
- package/src/parsing/operations/delete_relationship.ts +0 -32
- package/src/parsing/operations/group_by.ts +0 -137
- package/src/parsing/operations/limit.ts +0 -31
- package/src/parsing/operations/load.ts +0 -146
- package/src/parsing/operations/match.ts +0 -54
- package/src/parsing/operations/operation.ts +0 -69
- package/src/parsing/operations/order_by.ts +0 -126
- package/src/parsing/operations/projection.ts +0 -18
- package/src/parsing/operations/return.ts +0 -76
- package/src/parsing/operations/union.ts +0 -114
- package/src/parsing/operations/union_all.ts +0 -16
- package/src/parsing/operations/unwind.ts +0 -36
- package/src/parsing/operations/where.ts +0 -42
- package/src/parsing/operations/with.ts +0 -20
- package/src/parsing/parser.ts +0 -1641
- package/src/parsing/parser_state.ts +0 -25
- package/src/parsing/token_to_node.ts +0 -114
- package/src/tokenization/keyword.ts +0 -50
- package/src/tokenization/operator.ts +0 -25
- package/src/tokenization/string_walker.ts +0 -197
- package/src/tokenization/symbol.ts +0 -15
- package/src/tokenization/token.ts +0 -764
- package/src/tokenization/token_mapper.ts +0 -53
- package/src/tokenization/token_type.ts +0 -16
- package/src/tokenization/tokenizer.ts +0 -250
- package/src/tokenization/trie.ts +0 -117
- package/src/utils/object_utils.ts +0 -17
- package/src/utils/string_utils.ts +0 -114
- package/tests/compute/runner.test.ts +0 -4559
- package/tests/extensibility.test.ts +0 -643
- package/tests/graph/create.test.ts +0 -36
- package/tests/graph/data.test.ts +0 -58
- package/tests/graph/match.test.ts +0 -29
- package/tests/parsing/context.test.ts +0 -27
- package/tests/parsing/expression.test.ts +0 -303
- package/tests/parsing/parser.test.ts +0 -1327
- package/tests/tokenization/token_mapper.test.ts +0 -47
- package/tests/tokenization/tokenizer.test.ts +0 -191
- package/tests/tokenization/trie.test.ts +0 -20
- package/tsconfig.json +0 -19
- package/typedoc.json +0 -16
- package/vscode-settings.json.recommended +0 -16
- package/webpack.config.js +0 -26
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import AggregateFunction from "./aggregate_function";
|
|
2
|
-
import ReducerElement from "./reducer_element";
|
|
3
|
-
import { FunctionDef } from "./function_metadata";
|
|
4
|
-
|
|
5
|
-
class CollectReducerElement extends ReducerElement {
|
|
6
|
-
private _value: any[] = [];
|
|
7
|
-
public get value(): any {
|
|
8
|
-
return this._value;
|
|
9
|
-
}
|
|
10
|
-
public set value(value: any) {
|
|
11
|
-
this._value.push(value);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class DistinctCollectReducerElement extends ReducerElement {
|
|
16
|
-
private _value: Map<any, any> = new Map();
|
|
17
|
-
public get value(): any {
|
|
18
|
-
return Array.from(this._value.values());
|
|
19
|
-
}
|
|
20
|
-
public set value(value: any) {
|
|
21
|
-
const key: string = JSON.stringify(value);
|
|
22
|
-
if (!this._value.has(key)) {
|
|
23
|
-
this._value.set(key, value);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@FunctionDef({
|
|
29
|
-
description: "Collects values into an array across grouped rows",
|
|
30
|
-
category: "aggregate",
|
|
31
|
-
parameters: [
|
|
32
|
-
{ name: "value", description: "Value to collect", type: "any" }
|
|
33
|
-
],
|
|
34
|
-
output: { description: "Array of collected values", type: "array", example: [1, 2, 3] },
|
|
35
|
-
examples: ["WITH [1, 2, 3] AS nums UNWIND nums AS n RETURN collect(n)"]
|
|
36
|
-
})
|
|
37
|
-
class Collect extends AggregateFunction {
|
|
38
|
-
private _distinct: boolean = false;
|
|
39
|
-
constructor() {
|
|
40
|
-
super("collect");
|
|
41
|
-
this._expectedParameterCount = 1;
|
|
42
|
-
}
|
|
43
|
-
public reduce(element: CollectReducerElement): void {
|
|
44
|
-
element.value = this.firstChild().value();
|
|
45
|
-
}
|
|
46
|
-
public element(): CollectReducerElement | DistinctCollectReducerElement {
|
|
47
|
-
return this._distinct ? new DistinctCollectReducerElement() : new CollectReducerElement();
|
|
48
|
-
}
|
|
49
|
-
public set distinct(distinct: boolean) {
|
|
50
|
-
this._distinct = distinct;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default Collect;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import AggregateFunction from "./aggregate_function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
import ReducerElement from "./reducer_element";
|
|
4
|
-
|
|
5
|
-
class CountReducerElement extends ReducerElement {
|
|
6
|
-
private _value: number = 0;
|
|
7
|
-
public get value(): any {
|
|
8
|
-
return this._value;
|
|
9
|
-
}
|
|
10
|
-
public set value(value: any) {
|
|
11
|
-
this._value += 1;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class DistinctCountReducerElement extends ReducerElement {
|
|
16
|
-
private _seen: Set<string> = new Set();
|
|
17
|
-
public get value(): any {
|
|
18
|
-
return this._seen.size;
|
|
19
|
-
}
|
|
20
|
-
public set value(value: any) {
|
|
21
|
-
const key: string = JSON.stringify(value);
|
|
22
|
-
this._seen.add(key);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@FunctionDef({
|
|
27
|
-
description: "Counts the number of values across grouped rows",
|
|
28
|
-
category: "aggregate",
|
|
29
|
-
parameters: [{ name: "value", description: "Value to count", type: "any" }],
|
|
30
|
-
output: { description: "Number of values", type: "number", example: 3 },
|
|
31
|
-
examples: [
|
|
32
|
-
"WITH [1, 2, 3] AS nums UNWIND nums AS n RETURN count(n)",
|
|
33
|
-
"WITH [1, 2, 2, 3] AS nums UNWIND nums AS n RETURN count(distinct n)",
|
|
34
|
-
],
|
|
35
|
-
})
|
|
36
|
-
class Count extends AggregateFunction {
|
|
37
|
-
private _distinct: boolean = false;
|
|
38
|
-
constructor() {
|
|
39
|
-
super("count");
|
|
40
|
-
this._expectedParameterCount = 1;
|
|
41
|
-
this._supports_distinct = true;
|
|
42
|
-
}
|
|
43
|
-
public reduce(element: CountReducerElement | DistinctCountReducerElement): void {
|
|
44
|
-
element.value = this.firstChild().value();
|
|
45
|
-
}
|
|
46
|
-
public element(): CountReducerElement | DistinctCountReducerElement {
|
|
47
|
-
return this._distinct ? new DistinctCountReducerElement() : new CountReducerElement();
|
|
48
|
-
}
|
|
49
|
-
public set distinct(distinct: boolean) {
|
|
50
|
-
this._distinct = distinct;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default Count;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
import { buildDateObject, parseTemporalArg } from "./temporal_utils";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns a date value (no time component).
|
|
7
|
-
* When called with no arguments, returns the current date.
|
|
8
|
-
* When called with a string argument, parses it as an ISO 8601 date.
|
|
9
|
-
* When called with a map argument, constructs a date from components.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* RETURN date() AS today
|
|
14
|
-
* RETURN date('2025-06-15') AS d
|
|
15
|
-
* RETURN date({year: 2025, month: 6, day: 15}) AS d
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
@FunctionDef({
|
|
19
|
-
description:
|
|
20
|
-
"Returns a date value. With no arguments returns the current date. " +
|
|
21
|
-
"Accepts an ISO 8601 date string or a map of components (year, month, day).",
|
|
22
|
-
category: "scalar",
|
|
23
|
-
parameters: [
|
|
24
|
-
{
|
|
25
|
-
name: "input",
|
|
26
|
-
description: "Optional. An ISO 8601 date string (YYYY-MM-DD) or a map of components.",
|
|
27
|
-
type: "string",
|
|
28
|
-
required: false,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
output: {
|
|
32
|
-
description:
|
|
33
|
-
"A date object with properties: year, month, day, " +
|
|
34
|
-
"epochMillis, dayOfWeek, dayOfYear, quarter, formatted",
|
|
35
|
-
type: "object",
|
|
36
|
-
},
|
|
37
|
-
examples: [
|
|
38
|
-
"RETURN date() AS today",
|
|
39
|
-
"RETURN date('2025-06-15') AS d",
|
|
40
|
-
"RETURN date({year: 2025, month: 6, day: 15}) AS d",
|
|
41
|
-
"WITH date() AS d RETURN d.year, d.month, d.dayOfWeek",
|
|
42
|
-
],
|
|
43
|
-
})
|
|
44
|
-
class DateFunction extends Function {
|
|
45
|
-
constructor() {
|
|
46
|
-
super("date");
|
|
47
|
-
this._expectedParameterCount = null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public value(): any {
|
|
51
|
-
const children = this.getChildren();
|
|
52
|
-
if (children.length > 1) {
|
|
53
|
-
throw new Error("date() accepts at most one argument");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const d: Date =
|
|
57
|
-
children.length === 1 ? parseTemporalArg(children[0].value(), "date") : new Date();
|
|
58
|
-
|
|
59
|
-
return buildDateObject(d);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default DateFunction;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
import { buildDatetimeObject, parseTemporalArg } from "./temporal_utils";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns a datetime value (date + time + timezone offset).
|
|
7
|
-
* When called with no arguments, returns the current UTC datetime.
|
|
8
|
-
* When called with a string argument, parses it as an ISO 8601 datetime.
|
|
9
|
-
* When called with a map argument, constructs a datetime from components.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* RETURN datetime() AS now
|
|
14
|
-
* RETURN datetime('2025-06-15T12:30:00Z') AS dt
|
|
15
|
-
* RETURN datetime({year: 2025, month: 6, day: 15}) AS dt
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
@FunctionDef({
|
|
19
|
-
description:
|
|
20
|
-
"Returns a datetime value. With no arguments returns the current UTC datetime. " +
|
|
21
|
-
"Accepts an ISO 8601 string or a map of components (year, month, day, hour, minute, second, millisecond).",
|
|
22
|
-
category: "scalar",
|
|
23
|
-
parameters: [
|
|
24
|
-
{
|
|
25
|
-
name: "input",
|
|
26
|
-
description: "Optional. An ISO 8601 datetime string or a map of components.",
|
|
27
|
-
type: "string",
|
|
28
|
-
required: false,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
output: {
|
|
32
|
-
description:
|
|
33
|
-
"A datetime object with properties: year, month, day, hour, minute, second, millisecond, " +
|
|
34
|
-
"epochMillis, epochSeconds, dayOfWeek, dayOfYear, quarter, formatted",
|
|
35
|
-
type: "object",
|
|
36
|
-
},
|
|
37
|
-
examples: [
|
|
38
|
-
"RETURN datetime() AS now",
|
|
39
|
-
"RETURN datetime('2025-06-15T12:30:00Z') AS dt",
|
|
40
|
-
"RETURN datetime({year: 2025, month: 6, day: 15, hour: 12}) AS dt",
|
|
41
|
-
"WITH datetime() AS dt RETURN dt.year, dt.month, dt.day",
|
|
42
|
-
],
|
|
43
|
-
})
|
|
44
|
-
class Datetime extends Function {
|
|
45
|
-
constructor() {
|
|
46
|
-
super("datetime");
|
|
47
|
-
this._expectedParameterCount = null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public value(): any {
|
|
51
|
-
const children = this.getChildren();
|
|
52
|
-
if (children.length > 1) {
|
|
53
|
-
throw new Error("datetime() accepts at most one argument");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const d: Date =
|
|
57
|
-
children.length === 1 ? parseTemporalArg(children[0].value(), "datetime") : new Date();
|
|
58
|
-
|
|
59
|
-
return buildDatetimeObject(d, true);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default Datetime;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Regex for ISO 8601 duration strings: P[nY][nM][nW][nD][T[nH][nM][nS]]
|
|
6
|
-
*/
|
|
7
|
-
const ISO_DURATION_REGEX =
|
|
8
|
-
/^P(?:(\d+(?:\.\d+)?)Y)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;
|
|
9
|
-
|
|
10
|
-
function parseDurationString(s: string): Record<string, number> {
|
|
11
|
-
const match = s.match(ISO_DURATION_REGEX);
|
|
12
|
-
if (!match) {
|
|
13
|
-
throw new Error(`duration(): Invalid ISO 8601 duration string: '${s}'`);
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
years: match[1] ? parseFloat(match[1]) : 0,
|
|
17
|
-
months: match[2] ? parseFloat(match[2]) : 0,
|
|
18
|
-
weeks: match[3] ? parseFloat(match[3]) : 0,
|
|
19
|
-
days: match[4] ? parseFloat(match[4]) : 0,
|
|
20
|
-
hours: match[5] ? parseFloat(match[5]) : 0,
|
|
21
|
-
minutes: match[6] ? parseFloat(match[6]) : 0,
|
|
22
|
-
seconds: match[7] ? parseFloat(match[7]) : 0,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function buildDurationObject(components: Record<string, number>): Record<string, any> {
|
|
27
|
-
const years = components.years || 0;
|
|
28
|
-
const months = components.months || 0;
|
|
29
|
-
const weeks = components.weeks || 0;
|
|
30
|
-
const days = components.days || 0;
|
|
31
|
-
const hours = components.hours || 0;
|
|
32
|
-
const minutes = components.minutes || 0;
|
|
33
|
-
const seconds = Math.floor(components.seconds || 0);
|
|
34
|
-
const fractionalSeconds = (components.seconds || 0) - seconds;
|
|
35
|
-
|
|
36
|
-
const milliseconds = components.milliseconds
|
|
37
|
-
? Math.floor(components.milliseconds)
|
|
38
|
-
: Math.round(fractionalSeconds * 1000);
|
|
39
|
-
|
|
40
|
-
const nanoseconds = components.nanoseconds
|
|
41
|
-
? Math.floor(components.nanoseconds)
|
|
42
|
-
: Math.round(fractionalSeconds * 1_000_000_000) % 1_000_000;
|
|
43
|
-
|
|
44
|
-
// Total days including weeks
|
|
45
|
-
const totalDays = days + weeks * 7;
|
|
46
|
-
|
|
47
|
-
// Total seconds for the time portion
|
|
48
|
-
const totalSeconds = hours * 3600 + minutes * 60 + seconds;
|
|
49
|
-
|
|
50
|
-
// Approximate total in various units (months approximated at 30 days)
|
|
51
|
-
const totalMonths = years * 12 + months;
|
|
52
|
-
|
|
53
|
-
// Build ISO 8601 formatted string
|
|
54
|
-
let formatted = "P";
|
|
55
|
-
if (years) formatted += `${years}Y`;
|
|
56
|
-
if (months) formatted += `${months}M`;
|
|
57
|
-
if (weeks) formatted += `${weeks}W`;
|
|
58
|
-
if (totalDays - weeks * 7) formatted += `${totalDays - weeks * 7}D`;
|
|
59
|
-
const hasTime = hours || minutes || seconds || milliseconds;
|
|
60
|
-
if (hasTime) {
|
|
61
|
-
formatted += "T";
|
|
62
|
-
if (hours) formatted += `${hours}H`;
|
|
63
|
-
if (minutes) formatted += `${minutes}M`;
|
|
64
|
-
if (seconds || milliseconds) {
|
|
65
|
-
if (milliseconds) {
|
|
66
|
-
formatted += `${seconds}.${String(milliseconds).padStart(3, "0")}S`;
|
|
67
|
-
} else {
|
|
68
|
-
formatted += `${seconds}S`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (formatted === "P") formatted = "PT0S";
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
years,
|
|
76
|
-
months,
|
|
77
|
-
weeks,
|
|
78
|
-
days: totalDays,
|
|
79
|
-
hours,
|
|
80
|
-
minutes,
|
|
81
|
-
seconds,
|
|
82
|
-
milliseconds,
|
|
83
|
-
nanoseconds,
|
|
84
|
-
totalMonths,
|
|
85
|
-
totalDays,
|
|
86
|
-
totalSeconds,
|
|
87
|
-
formatted,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@FunctionDef({
|
|
92
|
-
description:
|
|
93
|
-
"Creates a duration value representing a span of time. " +
|
|
94
|
-
"Accepts an ISO 8601 duration string (e.g., 'P1Y2M3DT4H5M6S') or a map of components " +
|
|
95
|
-
"(years, months, weeks, days, hours, minutes, seconds, milliseconds, nanoseconds).",
|
|
96
|
-
category: "scalar",
|
|
97
|
-
parameters: [
|
|
98
|
-
{
|
|
99
|
-
name: "input",
|
|
100
|
-
description:
|
|
101
|
-
"An ISO 8601 duration string or a map of components (years, months, weeks, days, hours, minutes, seconds, milliseconds, nanoseconds)",
|
|
102
|
-
type: "any",
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
output: {
|
|
106
|
-
description:
|
|
107
|
-
"A duration object with properties: years, months, weeks, days, hours, minutes, seconds, " +
|
|
108
|
-
"milliseconds, nanoseconds, totalMonths, totalDays, totalSeconds, formatted",
|
|
109
|
-
type: "object",
|
|
110
|
-
},
|
|
111
|
-
examples: [
|
|
112
|
-
"RETURN duration('P1Y2M3D') AS d",
|
|
113
|
-
"RETURN duration('PT2H30M') AS d",
|
|
114
|
-
"RETURN duration({days: 14, hours: 16}) AS d",
|
|
115
|
-
"RETURN duration({months: 5, days: 1, hours: 12}) AS d",
|
|
116
|
-
],
|
|
117
|
-
})
|
|
118
|
-
class Duration extends Function {
|
|
119
|
-
constructor() {
|
|
120
|
-
super("duration");
|
|
121
|
-
this._expectedParameterCount = 1;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public value(): any {
|
|
125
|
-
const arg = this.getChildren()[0].value();
|
|
126
|
-
if (arg === null || arg === undefined) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (typeof arg === "string") {
|
|
131
|
-
const components = parseDurationString(arg);
|
|
132
|
-
return buildDurationObject(components);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (typeof arg === "object" && !Array.isArray(arg)) {
|
|
136
|
-
return buildDurationObject(arg);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
throw new Error("duration() expects a string or map argument");
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export default Duration;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description:
|
|
6
|
-
"Returns the element id of a node or relationship as a string. For nodes, returns the string representation of the id property. For relationships, returns the type.",
|
|
7
|
-
category: "scalar",
|
|
8
|
-
parameters: [
|
|
9
|
-
{
|
|
10
|
-
name: "entity",
|
|
11
|
-
description: "A node or relationship to get the element id from",
|
|
12
|
-
type: "object",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
output: {
|
|
16
|
-
description: "The element id of the entity as a string",
|
|
17
|
-
type: "string",
|
|
18
|
-
example: '"1"',
|
|
19
|
-
},
|
|
20
|
-
examples: ["MATCH (n:Person) RETURN elementId(n)", "MATCH (a)-[r]->(b) RETURN elementId(r)"],
|
|
21
|
-
})
|
|
22
|
-
class ElementId extends Function {
|
|
23
|
-
constructor() {
|
|
24
|
-
super("elementid");
|
|
25
|
-
this._expectedParameterCount = 1;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public value(): any {
|
|
29
|
-
const obj = this.getChildren()[0].value();
|
|
30
|
-
if (obj === null || obj === undefined) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
if (typeof obj !== "object" || Array.isArray(obj)) {
|
|
34
|
-
throw new Error("elementId() expects a node or relationship");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// If it's a RelationshipMatchRecord (has type, startNode, endNode, properties)
|
|
38
|
-
if ("type" in obj && "startNode" in obj && "endNode" in obj && "properties" in obj) {
|
|
39
|
-
return String(obj.type);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// If it's a node record (has id field)
|
|
43
|
-
if ("id" in obj) {
|
|
44
|
-
return String(obj.id);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
throw new Error("elementId() expects a node or relationship");
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default ElementId;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import ASTNode from "../ast_node";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Base class for all functions in FlowQuery.
|
|
5
|
-
*
|
|
6
|
-
* Functions can have parameters and may support the DISTINCT modifier.
|
|
7
|
-
* Subclasses implement specific function logic.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const func = FunctionFactory.create("sum");
|
|
12
|
-
* func.parameters = [expression1, expression2];
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
class Function extends ASTNode {
|
|
16
|
-
protected _name: string;
|
|
17
|
-
protected _expectedParameterCount: number | null = null;
|
|
18
|
-
protected _supports_distinct: boolean = false;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new Function with the given name.
|
|
22
|
-
*
|
|
23
|
-
* @param name - The function name
|
|
24
|
-
*/
|
|
25
|
-
constructor(name?: string) {
|
|
26
|
-
super();
|
|
27
|
-
this._name = name || this.constructor.name;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Sets the function parameters.
|
|
32
|
-
*
|
|
33
|
-
* @param nodes - Array of AST nodes representing the function arguments
|
|
34
|
-
* @throws {Error} If the number of parameters doesn't match expected count
|
|
35
|
-
*/
|
|
36
|
-
public set parameters(nodes: ASTNode[]) {
|
|
37
|
-
if (this._expectedParameterCount !== null && this._expectedParameterCount !== nodes.length) {
|
|
38
|
-
throw new Error(`Function ${this._name} expected ${this._expectedParameterCount} parameters, but got ${nodes.length}`);
|
|
39
|
-
}
|
|
40
|
-
this.children = nodes;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public get name(): string {
|
|
44
|
-
return this._name;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public toString(): string {
|
|
48
|
-
return `Function (${this._name})`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public set distinct(distinct: boolean) {
|
|
52
|
-
if (this._supports_distinct) {
|
|
53
|
-
this._supports_distinct = distinct;
|
|
54
|
-
} else {
|
|
55
|
-
throw new Error(`Function ${this._name} does not support distinct`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default Function;
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import AsyncFunction from "./async_function";
|
|
2
|
-
import "./avg";
|
|
3
|
-
import "./coalesce";
|
|
4
|
-
import "./collect";
|
|
5
|
-
import "./count";
|
|
6
|
-
import "./date";
|
|
7
|
-
import "./datetime";
|
|
8
|
-
import "./duration";
|
|
9
|
-
import "./element_id";
|
|
10
|
-
import Function from "./function";
|
|
11
|
-
import {
|
|
12
|
-
AsyncDataProvider,
|
|
13
|
-
FunctionMetadata,
|
|
14
|
-
getFunctionMetadata,
|
|
15
|
-
getRegisteredFunctionFactory,
|
|
16
|
-
getRegisteredFunctionMetadata,
|
|
17
|
-
} from "./function_metadata";
|
|
18
|
-
import "./functions";
|
|
19
|
-
import "./head";
|
|
20
|
-
import "./id";
|
|
21
|
-
import "./join";
|
|
22
|
-
import "./keys";
|
|
23
|
-
import "./last";
|
|
24
|
-
import "./localdatetime";
|
|
25
|
-
import "./localtime";
|
|
26
|
-
import "./max";
|
|
27
|
-
import "./min";
|
|
28
|
-
import "./nodes";
|
|
29
|
-
import PredicateFunction from "./predicate_function";
|
|
30
|
-
import "./predicate_sum";
|
|
31
|
-
import "./properties";
|
|
32
|
-
import "./rand";
|
|
33
|
-
import "./range";
|
|
34
|
-
import "./relationships";
|
|
35
|
-
import "./replace";
|
|
36
|
-
import "./round";
|
|
37
|
-
import "./schema";
|
|
38
|
-
import "./size";
|
|
39
|
-
import "./split";
|
|
40
|
-
import "./string_distance";
|
|
41
|
-
import "./stringify";
|
|
42
|
-
import "./substring";
|
|
43
|
-
// Import built-in functions to ensure their @FunctionDef decorators run
|
|
44
|
-
import "./sum";
|
|
45
|
-
import "./tail";
|
|
46
|
-
import "./time";
|
|
47
|
-
import "./timestamp";
|
|
48
|
-
import "./to_float";
|
|
49
|
-
import "./to_integer";
|
|
50
|
-
import "./to_json";
|
|
51
|
-
import "./to_lower";
|
|
52
|
-
import "./to_string";
|
|
53
|
-
import "./trim";
|
|
54
|
-
import "./type";
|
|
55
|
-
|
|
56
|
-
// Re-export AsyncDataProvider for backwards compatibility
|
|
57
|
-
export { AsyncDataProvider };
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Factory for creating function instances by name.
|
|
61
|
-
*
|
|
62
|
-
* All functions are registered via the @FunctionDef decorator.
|
|
63
|
-
* Maps function names (case-insensitive) to their corresponding implementation classes.
|
|
64
|
-
* Supports built-in functions like sum, avg, collect, range, split, join, etc.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const sumFunc = FunctionFactory.create("sum");
|
|
69
|
-
* const avgFunc = FunctionFactory.create("AVG");
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
class FunctionFactory {
|
|
73
|
-
/**
|
|
74
|
-
* Gets an async data provider by name.
|
|
75
|
-
*
|
|
76
|
-
* @param name - The function name (case-insensitive)
|
|
77
|
-
* @returns The async data provider, or undefined if not found
|
|
78
|
-
*/
|
|
79
|
-
public static getAsyncProvider(name: string): AsyncDataProvider | undefined {
|
|
80
|
-
return getRegisteredFunctionFactory(name.toLowerCase());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Checks if a function name is registered as an async data provider.
|
|
85
|
-
*
|
|
86
|
-
* @param name - The function name (case-insensitive)
|
|
87
|
-
* @returns True if the function is an async data provider
|
|
88
|
-
*/
|
|
89
|
-
public static isAsyncProvider(name: string): boolean {
|
|
90
|
-
return getRegisteredFunctionFactory(name.toLowerCase(), "async") !== undefined;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Gets metadata for a specific function.
|
|
95
|
-
*
|
|
96
|
-
* @param name - The function name (case-insensitive)
|
|
97
|
-
* @returns The function metadata, or undefined if not found
|
|
98
|
-
*/
|
|
99
|
-
public static getMetadata(name: string): FunctionMetadata | undefined {
|
|
100
|
-
return getFunctionMetadata(name.toLowerCase());
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Lists all registered functions with their metadata.
|
|
105
|
-
*
|
|
106
|
-
* @param options - Optional filter options
|
|
107
|
-
* @returns Array of function metadata
|
|
108
|
-
*/
|
|
109
|
-
public static listFunctions(options?: {
|
|
110
|
-
category?: string;
|
|
111
|
-
asyncOnly?: boolean;
|
|
112
|
-
syncOnly?: boolean;
|
|
113
|
-
}): FunctionMetadata[] {
|
|
114
|
-
const result: FunctionMetadata[] = [];
|
|
115
|
-
|
|
116
|
-
for (const meta of getRegisteredFunctionMetadata()) {
|
|
117
|
-
if (options?.category && meta.category !== options.category) continue;
|
|
118
|
-
if (options?.asyncOnly && meta.category !== "async") continue;
|
|
119
|
-
if (options?.syncOnly && meta.category === "async") continue;
|
|
120
|
-
result.push(meta);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Lists all registered function names.
|
|
128
|
-
*
|
|
129
|
-
* @returns Array of function names
|
|
130
|
-
*/
|
|
131
|
-
public static listFunctionNames(): string[] {
|
|
132
|
-
return getRegisteredFunctionMetadata().map((m) => m.name);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Gets all function metadata as a JSON-serializable object for LLM consumption.
|
|
137
|
-
*
|
|
138
|
-
* @returns Object with functions grouped by category
|
|
139
|
-
*/
|
|
140
|
-
public static toJSON(): { functions: FunctionMetadata[]; categories: string[] } {
|
|
141
|
-
const functions = FunctionFactory.listFunctions();
|
|
142
|
-
const categories = [
|
|
143
|
-
...new Set(functions.map((f) => f.category).filter(Boolean)),
|
|
144
|
-
] as string[];
|
|
145
|
-
return { functions, categories };
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Creates a function instance by name.
|
|
150
|
-
*
|
|
151
|
-
* @param name - The function name (case-insensitive)
|
|
152
|
-
* @returns A Function instance of the appropriate type
|
|
153
|
-
*/
|
|
154
|
-
public static create(name: string): Function {
|
|
155
|
-
const lowerName: string = name.toLowerCase();
|
|
156
|
-
|
|
157
|
-
// Check decorator-registered functions (built-ins use @FunctionDef)
|
|
158
|
-
const decoratorFactory = getRegisteredFunctionFactory(lowerName);
|
|
159
|
-
if (decoratorFactory) {
|
|
160
|
-
return decoratorFactory();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
throw new Error(`Unknown function: ${name}`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Creates a predicate function instance by name.
|
|
168
|
-
* Predicate functions are used in WHERE clauses with quantifiers (e.g., ANY, ALL).
|
|
169
|
-
*
|
|
170
|
-
* @param name - The function name (case-insensitive)
|
|
171
|
-
* @returns A PredicateFunction instance of the appropriate type
|
|
172
|
-
*/
|
|
173
|
-
public static createPredicate(name: string): PredicateFunction {
|
|
174
|
-
const lowerName: string = name.toLowerCase();
|
|
175
|
-
|
|
176
|
-
// Check decorator-registered predicate functions
|
|
177
|
-
const decoratorFactory = getRegisteredFunctionFactory(lowerName, "predicate");
|
|
178
|
-
if (decoratorFactory) {
|
|
179
|
-
return decoratorFactory();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
throw new Error(`Unknown predicate function: ${name}`);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
public static createAsync(name: string): AsyncFunction {
|
|
186
|
-
const lowerName: string = name.toLowerCase();
|
|
187
|
-
const decoratorFactory = getRegisteredFunctionFactory(lowerName, "async");
|
|
188
|
-
if (decoratorFactory) {
|
|
189
|
-
return decoratorFactory() as AsyncFunction;
|
|
190
|
-
}
|
|
191
|
-
throw new Error(`Unknown async function: ${name}`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export default FunctionFactory;
|