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,40 +0,0 @@
|
|
|
1
|
-
import ASTNode from "../ast_node";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a numeric literal in the AST.
|
|
5
|
-
*
|
|
6
|
-
* Parses string representations of numbers into integer or float values.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const num = new Number("42");
|
|
11
|
-
* console.log(num.value()); // 42
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
class Number extends ASTNode {
|
|
15
|
-
private _value: number;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new Number node by parsing the string value.
|
|
19
|
-
*
|
|
20
|
-
* @param value - The string representation of the number
|
|
21
|
-
*/
|
|
22
|
-
constructor(value: string) {
|
|
23
|
-
super();
|
|
24
|
-
if(value.indexOf('.') !== -1) {
|
|
25
|
-
this._value = parseFloat(value);
|
|
26
|
-
} else {
|
|
27
|
-
this._value = parseInt(value);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public value(): number {
|
|
32
|
-
return this._value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
protected toString(): string {
|
|
36
|
-
return `${this.constructor.name} (${this._value})`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default Number;
|
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import ASTNode from "../ast_node";
|
|
2
|
-
|
|
3
|
-
function deepEquals(a: any, b: any): boolean {
|
|
4
|
-
if (a === b) return true;
|
|
5
|
-
if (a === null || b === null || a === undefined || b === undefined) return false;
|
|
6
|
-
if (typeof a !== typeof b) return false;
|
|
7
|
-
if (typeof a !== "object") return false;
|
|
8
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
9
|
-
if (Array.isArray(a)) {
|
|
10
|
-
if (a.length !== b.length) return false;
|
|
11
|
-
for (let i = 0; i < a.length; i++) {
|
|
12
|
-
if (!deepEquals(a[i], b[i])) return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
const keysA = Object.keys(a);
|
|
17
|
-
const keysB = Object.keys(b);
|
|
18
|
-
if (keysA.length !== keysB.length) return false;
|
|
19
|
-
for (const key of keysA) {
|
|
20
|
-
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
21
|
-
if (!deepEquals(a[key], b[key])) return false;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
abstract class Operator extends ASTNode {
|
|
27
|
-
private _precedence: number = 0;
|
|
28
|
-
private _leftAssociative: boolean = true;
|
|
29
|
-
|
|
30
|
-
constructor(precedence: number, leftAssociative: boolean) {
|
|
31
|
-
super();
|
|
32
|
-
this._precedence = precedence;
|
|
33
|
-
this._leftAssociative = leftAssociative;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public isOperator(): boolean {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public get precedence(): number {
|
|
41
|
-
return this._precedence;
|
|
42
|
-
}
|
|
43
|
-
public get leftAssociative(): boolean {
|
|
44
|
-
return this._leftAssociative;
|
|
45
|
-
}
|
|
46
|
-
public abstract value(): any;
|
|
47
|
-
public get lhs(): ASTNode {
|
|
48
|
-
return this.getChildren()[0];
|
|
49
|
-
}
|
|
50
|
-
public get rhs(): ASTNode {
|
|
51
|
-
return this.getChildren()[1];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class Add extends Operator {
|
|
56
|
-
constructor() {
|
|
57
|
-
super(1, true);
|
|
58
|
-
}
|
|
59
|
-
public value(): any {
|
|
60
|
-
const l = this.lhs.value();
|
|
61
|
-
const r = this.rhs.value();
|
|
62
|
-
if (Array.isArray(l) && Array.isArray(r)) {
|
|
63
|
-
return [...l, ...r];
|
|
64
|
-
}
|
|
65
|
-
return l + r;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
class Subtract extends Operator {
|
|
70
|
-
constructor() {
|
|
71
|
-
super(1, true);
|
|
72
|
-
}
|
|
73
|
-
public value(): number {
|
|
74
|
-
return this.lhs.value() - this.rhs.value();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
class Multiply extends Operator {
|
|
79
|
-
constructor() {
|
|
80
|
-
super(2, true);
|
|
81
|
-
}
|
|
82
|
-
public value(): number {
|
|
83
|
-
return this.lhs.value() * this.rhs.value();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
class Divide extends Operator {
|
|
88
|
-
constructor() {
|
|
89
|
-
super(2, true);
|
|
90
|
-
}
|
|
91
|
-
public value(): number {
|
|
92
|
-
return this.lhs.value() / this.rhs.value();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
class Modulo extends Operator {
|
|
97
|
-
constructor() {
|
|
98
|
-
super(2, true);
|
|
99
|
-
}
|
|
100
|
-
public value(): number {
|
|
101
|
-
return this.lhs.value() % this.rhs.value();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
class Power extends Operator {
|
|
106
|
-
constructor() {
|
|
107
|
-
super(3, false);
|
|
108
|
-
}
|
|
109
|
-
public value(): number {
|
|
110
|
-
return Math.pow(this.lhs.value(), this.rhs.value());
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
class Equals extends Operator {
|
|
115
|
-
constructor() {
|
|
116
|
-
super(0, true);
|
|
117
|
-
}
|
|
118
|
-
public value(): number {
|
|
119
|
-
return deepEquals(this.lhs.value(), this.rhs.value()) ? 1 : 0;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
class NotEquals extends Operator {
|
|
124
|
-
constructor() {
|
|
125
|
-
super(0, true);
|
|
126
|
-
}
|
|
127
|
-
public value(): number {
|
|
128
|
-
return !deepEquals(this.lhs.value(), this.rhs.value()) ? 1 : 0;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
class GreaterThan extends Operator {
|
|
133
|
-
constructor() {
|
|
134
|
-
super(0, true);
|
|
135
|
-
}
|
|
136
|
-
public value(): number {
|
|
137
|
-
return this.lhs.value() > this.rhs.value() ? 1 : 0;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
class LessThan extends Operator {
|
|
142
|
-
constructor() {
|
|
143
|
-
super(0, true);
|
|
144
|
-
}
|
|
145
|
-
public value(): number {
|
|
146
|
-
return this.lhs.value() < this.rhs.value() ? 1 : 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
class GreaterThanOrEqual extends Operator {
|
|
151
|
-
constructor() {
|
|
152
|
-
super(0, true);
|
|
153
|
-
}
|
|
154
|
-
public value(): number {
|
|
155
|
-
return this.lhs.value() >= this.rhs.value() ? 1 : 0;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class LessThanOrEqual extends Operator {
|
|
160
|
-
constructor() {
|
|
161
|
-
super(0, true);
|
|
162
|
-
}
|
|
163
|
-
public value(): number {
|
|
164
|
-
return this.lhs.value() <= this.rhs.value() ? 1 : 0;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
class And extends Operator {
|
|
169
|
-
constructor() {
|
|
170
|
-
super(-1, true);
|
|
171
|
-
}
|
|
172
|
-
public value(): number {
|
|
173
|
-
return this.lhs.value() && this.rhs.value() ? 1 : 0;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
class Or extends Operator {
|
|
178
|
-
constructor() {
|
|
179
|
-
super(-1, true);
|
|
180
|
-
}
|
|
181
|
-
public value(): number {
|
|
182
|
-
return this.lhs.value() || this.rhs.value() ? 1 : 0;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
class Not extends Operator {
|
|
187
|
-
constructor() {
|
|
188
|
-
super(0, true);
|
|
189
|
-
}
|
|
190
|
-
public isOperator(): boolean {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
public value(): number {
|
|
194
|
-
return !this.lhs.value() ? 1 : 0;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
class Is extends Operator {
|
|
199
|
-
constructor() {
|
|
200
|
-
super(0, true);
|
|
201
|
-
}
|
|
202
|
-
public value(): number {
|
|
203
|
-
return this.lhs.value() == this.rhs.value() ? 1 : 0;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
class IsNot extends Operator {
|
|
208
|
-
constructor() {
|
|
209
|
-
super(0, true);
|
|
210
|
-
}
|
|
211
|
-
public value(): number {
|
|
212
|
-
return this.lhs.value() != this.rhs.value() ? 1 : 0;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
class In extends Operator {
|
|
217
|
-
constructor() {
|
|
218
|
-
super(0, true);
|
|
219
|
-
}
|
|
220
|
-
public value(): number {
|
|
221
|
-
const list = this.rhs.value();
|
|
222
|
-
if (!Array.isArray(list)) {
|
|
223
|
-
throw new Error("Right operand of IN must be a list");
|
|
224
|
-
}
|
|
225
|
-
return list.includes(this.lhs.value()) ? 1 : 0;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
class NotIn extends Operator {
|
|
230
|
-
constructor() {
|
|
231
|
-
super(0, true);
|
|
232
|
-
}
|
|
233
|
-
public value(): number {
|
|
234
|
-
const list = this.rhs.value();
|
|
235
|
-
if (!Array.isArray(list)) {
|
|
236
|
-
throw new Error("Right operand of NOT IN must be a list");
|
|
237
|
-
}
|
|
238
|
-
return list.includes(this.lhs.value()) ? 0 : 1;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
class Contains extends Operator {
|
|
243
|
-
constructor() {
|
|
244
|
-
super(0, true);
|
|
245
|
-
}
|
|
246
|
-
public value(): number {
|
|
247
|
-
const str = this.lhs.value();
|
|
248
|
-
const search = this.rhs.value();
|
|
249
|
-
if (typeof str !== "string" || typeof search !== "string") {
|
|
250
|
-
throw new Error("CONTAINS requires string operands");
|
|
251
|
-
}
|
|
252
|
-
return str.includes(search) ? 1 : 0;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
class NotContains extends Operator {
|
|
257
|
-
constructor() {
|
|
258
|
-
super(0, true);
|
|
259
|
-
}
|
|
260
|
-
public value(): number {
|
|
261
|
-
const str = this.lhs.value();
|
|
262
|
-
const search = this.rhs.value();
|
|
263
|
-
if (typeof str !== "string" || typeof search !== "string") {
|
|
264
|
-
throw new Error("NOT CONTAINS requires string operands");
|
|
265
|
-
}
|
|
266
|
-
return str.includes(search) ? 0 : 1;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
class StartsWith extends Operator {
|
|
271
|
-
constructor() {
|
|
272
|
-
super(0, true);
|
|
273
|
-
}
|
|
274
|
-
public value(): number {
|
|
275
|
-
const str = this.lhs.value();
|
|
276
|
-
const search = this.rhs.value();
|
|
277
|
-
if (typeof str !== "string" || typeof search !== "string") {
|
|
278
|
-
throw new Error("STARTS WITH requires string operands");
|
|
279
|
-
}
|
|
280
|
-
return str.startsWith(search) ? 1 : 0;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
class NotStartsWith extends Operator {
|
|
285
|
-
constructor() {
|
|
286
|
-
super(0, true);
|
|
287
|
-
}
|
|
288
|
-
public value(): number {
|
|
289
|
-
const str = this.lhs.value();
|
|
290
|
-
const search = this.rhs.value();
|
|
291
|
-
if (typeof str !== "string" || typeof search !== "string") {
|
|
292
|
-
throw new Error("NOT STARTS WITH requires string operands");
|
|
293
|
-
}
|
|
294
|
-
return str.startsWith(search) ? 0 : 1;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
class EndsWith extends Operator {
|
|
299
|
-
constructor() {
|
|
300
|
-
super(0, true);
|
|
301
|
-
}
|
|
302
|
-
public value(): number {
|
|
303
|
-
const str = this.lhs.value();
|
|
304
|
-
const search = this.rhs.value();
|
|
305
|
-
if (typeof str !== "string" || typeof search !== "string") {
|
|
306
|
-
throw new Error("ENDS WITH requires string operands");
|
|
307
|
-
}
|
|
308
|
-
return str.endsWith(search) ? 1 : 0;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
class NotEndsWith extends Operator {
|
|
313
|
-
constructor() {
|
|
314
|
-
super(0, true);
|
|
315
|
-
}
|
|
316
|
-
public value(): number {
|
|
317
|
-
const str = this.lhs.value();
|
|
318
|
-
const search = this.rhs.value();
|
|
319
|
-
if (typeof str !== "string" || typeof search !== "string") {
|
|
320
|
-
throw new Error("NOT ENDS WITH requires string operands");
|
|
321
|
-
}
|
|
322
|
-
return str.endsWith(search) ? 0 : 1;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export {
|
|
327
|
-
deepEquals,
|
|
328
|
-
Operator,
|
|
329
|
-
Add,
|
|
330
|
-
Subtract,
|
|
331
|
-
Multiply,
|
|
332
|
-
Divide,
|
|
333
|
-
Modulo,
|
|
334
|
-
Power,
|
|
335
|
-
Equals,
|
|
336
|
-
NotEquals,
|
|
337
|
-
GreaterThan,
|
|
338
|
-
LessThan,
|
|
339
|
-
GreaterThanOrEqual,
|
|
340
|
-
LessThanOrEqual,
|
|
341
|
-
And,
|
|
342
|
-
Or,
|
|
343
|
-
Not,
|
|
344
|
-
Is,
|
|
345
|
-
IsNot,
|
|
346
|
-
In,
|
|
347
|
-
NotIn,
|
|
348
|
-
Contains,
|
|
349
|
-
NotContains,
|
|
350
|
-
StartsWith,
|
|
351
|
-
NotStartsWith,
|
|
352
|
-
EndsWith,
|
|
353
|
-
NotEndsWith,
|
|
354
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import ASTNode from "../ast_node";
|
|
2
|
-
import Identifier from "./identifier";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Represents a reference to a previously defined variable or expression.
|
|
6
|
-
*
|
|
7
|
-
* References point to values defined earlier in the query (e.g., in WITH or LOAD statements).
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const ref = new Reference("myVar", previousNode);
|
|
12
|
-
* console.log(ref.value()); // Gets value from referred node
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
class Reference extends Identifier {
|
|
16
|
-
private _referred: ASTNode | undefined = undefined;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new Reference to a variable.
|
|
20
|
-
*
|
|
21
|
-
* @param value - The identifier name
|
|
22
|
-
* @param referred - The node this reference points to (optional)
|
|
23
|
-
*/
|
|
24
|
-
constructor(value: string, referred: ASTNode | undefined = undefined) {
|
|
25
|
-
super(value);
|
|
26
|
-
this._referred = referred;
|
|
27
|
-
}
|
|
28
|
-
public get referred(): ASTNode | undefined {
|
|
29
|
-
return this._referred;
|
|
30
|
-
}
|
|
31
|
-
public set referred(node: ASTNode) {
|
|
32
|
-
this._referred = node;
|
|
33
|
-
}
|
|
34
|
-
public toString(): string {
|
|
35
|
-
return `Reference (${this._value})`;
|
|
36
|
-
}
|
|
37
|
-
public value(): any {
|
|
38
|
-
return this._referred?.value();
|
|
39
|
-
}
|
|
40
|
-
public get identifier(): string {
|
|
41
|
-
return this._value;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default Reference;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import ASTNode from "../ast_node";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a string literal in the AST.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* const str = new String("hello");
|
|
9
|
-
* console.log(str.value()); // "hello"
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
class String extends ASTNode {
|
|
13
|
-
protected _value: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new String node with the given value.
|
|
17
|
-
*
|
|
18
|
-
* @param value - The string value
|
|
19
|
-
*/
|
|
20
|
-
constructor(value: string) {
|
|
21
|
-
super();
|
|
22
|
-
this._value = value;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public value(): string {
|
|
26
|
-
return this._value;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public toString(): string {
|
|
30
|
-
return `String (${this._value})`;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default String;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import ReducerElement from "./reducer_element";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Base class for aggregate functions that reduce multiple values to a single value.
|
|
6
|
-
*
|
|
7
|
-
* Aggregate functions like SUM, AVG, and COLLECT process multiple input values
|
|
8
|
-
* and produce a single output. They cannot be nested within other aggregate functions.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const sumFunc = new Sum();
|
|
13
|
-
* // Used in: RETURN SUM(values)
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
class AggregateFunction extends Function {
|
|
17
|
-
private _overridden: any | null = null;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new AggregateFunction with the given name.
|
|
21
|
-
*
|
|
22
|
-
* @param name - The function name
|
|
23
|
-
*/
|
|
24
|
-
constructor(name?: string) {
|
|
25
|
-
super(name);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Processes a value during the aggregation phase.
|
|
30
|
-
*
|
|
31
|
-
* @param value - The element to aggregate
|
|
32
|
-
* @throws {Error} If not implemented by subclass
|
|
33
|
-
*/
|
|
34
|
-
public reduce(value: ReducerElement): void {
|
|
35
|
-
throw new Error("Method not implemented.");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Creates a reducer element for this aggregate function.
|
|
40
|
-
*
|
|
41
|
-
* @returns A ReducerElement instance
|
|
42
|
-
* @throws {Error} If not implemented by subclass
|
|
43
|
-
*/
|
|
44
|
-
public element(): ReducerElement {
|
|
45
|
-
throw new Error("Method not implemented.");
|
|
46
|
-
}
|
|
47
|
-
public get overridden(): any | null {
|
|
48
|
-
return this._overridden;
|
|
49
|
-
}
|
|
50
|
-
public set overridden(value: any | null) {
|
|
51
|
-
this._overridden = value;
|
|
52
|
-
}
|
|
53
|
-
public value(): any {
|
|
54
|
-
return this._overridden;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default AggregateFunction;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import ASTNode from "../ast_node";
|
|
2
|
-
import Function from "./function";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Represents an async data provider function call for use in LOAD operations.
|
|
6
|
-
*
|
|
7
|
-
* This class holds the function name and arguments, and provides async iteration
|
|
8
|
-
* over the results from a registered async data provider.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // Used in: LOAD JSON FROM myDataSource('arg1', 'arg2') AS data
|
|
13
|
-
* const asyncFunc = new AsyncFunction("myDataSource");
|
|
14
|
-
* asyncFunc.parameters = [arg1Node, arg2Node];
|
|
15
|
-
* for await (const item of asyncFunc.execute()) {
|
|
16
|
-
* console.log(item);
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
class AsyncFunction extends Function {
|
|
21
|
-
/**
|
|
22
|
-
* Sets the function parameters.
|
|
23
|
-
*
|
|
24
|
-
* @param nodes - Array of AST nodes representing the function arguments
|
|
25
|
-
*/
|
|
26
|
-
public set parameters(nodes: ASTNode[]) {
|
|
27
|
-
this.children = nodes;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Evaluates all parameters and returns their values.
|
|
32
|
-
* Used by the framework to pass arguments to generate().
|
|
33
|
-
*
|
|
34
|
-
* @returns Array of parameter values
|
|
35
|
-
*/
|
|
36
|
-
public getArguments(): any[] {
|
|
37
|
-
return this.children.map(child => child.value());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Generates the async data provider function results.
|
|
42
|
-
*
|
|
43
|
-
* Subclasses override this method with their own typed parameters.
|
|
44
|
-
* The framework automatically evaluates the AST children and spreads
|
|
45
|
-
* them as arguments when calling this method.
|
|
46
|
-
*
|
|
47
|
-
* @param args - Arguments passed from the query (e.g., myFunc(arg1, arg2))
|
|
48
|
-
* @yields Data items from the async provider
|
|
49
|
-
* @throws {Error} If the function is not registered as an async provider
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* // Subclass with typed parameters:
|
|
54
|
-
* async *generate(count: number = 1, filter?: string): AsyncGenerator<any> {
|
|
55
|
-
* // Implementation
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
public async *generate(...args: any[]): AsyncGenerator<any, void, unknown> {
|
|
60
|
-
throw new Error("Not implemented: generate method must be overridden in subclasses.");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default AsyncFunction;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import AggregateFunction from "./aggregate_function";
|
|
2
|
-
import ASTNode from "../ast_node";
|
|
3
|
-
import ReducerElement from "./reducer_element";
|
|
4
|
-
import { FunctionDef } from "./function_metadata";
|
|
5
|
-
|
|
6
|
-
class AvgReducerElement extends ReducerElement {
|
|
7
|
-
private _count: number = 0;
|
|
8
|
-
private _sum: number | null = null;
|
|
9
|
-
public get value(): number | null {
|
|
10
|
-
if(this._sum === null) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
return this._sum / this._count;
|
|
14
|
-
}
|
|
15
|
-
public set value(value: number) {
|
|
16
|
-
this._count += 1;
|
|
17
|
-
if(this._sum !== null) {
|
|
18
|
-
this._sum += value;
|
|
19
|
-
} else {
|
|
20
|
-
this._sum = value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@FunctionDef({
|
|
26
|
-
description: "Calculates the average of numeric values across grouped rows",
|
|
27
|
-
category: "aggregate",
|
|
28
|
-
parameters: [
|
|
29
|
-
{ name: "value", description: "Numeric value to average", type: "number" }
|
|
30
|
-
],
|
|
31
|
-
output: { description: "Average of all values", type: "number", example: 50 },
|
|
32
|
-
examples: ["WITH [10, 20, 30] AS nums UNWIND nums AS n RETURN avg(n)"]
|
|
33
|
-
})
|
|
34
|
-
class Avg extends AggregateFunction {
|
|
35
|
-
constructor() {
|
|
36
|
-
super("avg");
|
|
37
|
-
this._expectedParameterCount = 1;
|
|
38
|
-
}
|
|
39
|
-
public reduce(element: AvgReducerElement): void {
|
|
40
|
-
element.value = this.firstChild().value();
|
|
41
|
-
}
|
|
42
|
-
public element(): AvgReducerElement {
|
|
43
|
-
return new AvgReducerElement();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default Avg;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns the first non-null value from a list of expressions.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```
|
|
9
|
-
* RETURN coalesce(null, null, 'hello', 'world') // returns 'hello'
|
|
10
|
-
* MATCH (n) RETURN coalesce(n.nickname, n.name) AS displayName
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
@FunctionDef({
|
|
14
|
-
description: "Returns the first non-null value from a list of expressions",
|
|
15
|
-
category: "scalar",
|
|
16
|
-
parameters: [
|
|
17
|
-
{ name: "expressions", description: "Two or more expressions to evaluate", type: "any" },
|
|
18
|
-
],
|
|
19
|
-
output: {
|
|
20
|
-
description: "The first non-null value, or null if all values are null",
|
|
21
|
-
type: "any",
|
|
22
|
-
},
|
|
23
|
-
examples: [
|
|
24
|
-
"RETURN coalesce(null, 'hello', 'world')",
|
|
25
|
-
"MATCH (n) RETURN coalesce(n.nickname, n.name) AS displayName",
|
|
26
|
-
],
|
|
27
|
-
})
|
|
28
|
-
class Coalesce extends Function {
|
|
29
|
-
constructor() {
|
|
30
|
-
super("coalesce");
|
|
31
|
-
this._expectedParameterCount = null; // variable number of parameters
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public value(): any {
|
|
35
|
-
const children = this.getChildren();
|
|
36
|
-
if (children.length === 0) {
|
|
37
|
-
throw new Error("coalesce() requires at least one argument");
|
|
38
|
-
}
|
|
39
|
-
for (const child of children) {
|
|
40
|
-
const val = child.value();
|
|
41
|
-
if (val !== null && val !== undefined) {
|
|
42
|
-
return val;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default Coalesce;
|