flowquery 1.0.46 → 1.0.47
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/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/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,68 +0,0 @@
|
|
|
1
|
-
import ASTNode from "../ast_node";
|
|
2
|
-
import Function from "./function";
|
|
3
|
-
import { FunctionDef } from "./function_metadata";
|
|
4
|
-
|
|
5
|
-
@FunctionDef({
|
|
6
|
-
description:
|
|
7
|
-
"Returns a substring of a string, starting at a 0-based index with an optional length",
|
|
8
|
-
category: "scalar",
|
|
9
|
-
parameters: [
|
|
10
|
-
{ name: "original", description: "The original string", type: "string" },
|
|
11
|
-
{ name: "start", description: "The 0-based start index", type: "integer" },
|
|
12
|
-
{
|
|
13
|
-
name: "length",
|
|
14
|
-
description: "The length of the substring (optional, defaults to remainder of string)",
|
|
15
|
-
type: "integer",
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
output: { description: "The substring", type: "string", example: "llo" },
|
|
19
|
-
examples: ["RETURN substring('hello', 1, 3)", "RETURN substring('hello', 2)"],
|
|
20
|
-
})
|
|
21
|
-
class Substring extends Function {
|
|
22
|
-
constructor() {
|
|
23
|
-
super("substring");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public set parameters(nodes: ASTNode[]) {
|
|
27
|
-
if (nodes.length < 2 || nodes.length > 3) {
|
|
28
|
-
throw new Error(
|
|
29
|
-
`Function substring expected 2 or 3 parameters, but got ${nodes.length}`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
this.children = nodes;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public value(): any {
|
|
36
|
-
const children = this.getChildren();
|
|
37
|
-
const original = children[0].value();
|
|
38
|
-
const start = children[1].value();
|
|
39
|
-
|
|
40
|
-
if (original === null || original === undefined) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
if (typeof original !== "string") {
|
|
44
|
-
throw new Error(
|
|
45
|
-
"Invalid argument for substring function: expected a string as the first argument"
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
if (typeof start !== "number" || !Number.isInteger(start)) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
"Invalid argument for substring function: expected an integer as the second argument"
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (children.length === 3) {
|
|
55
|
-
const length = children[2].value();
|
|
56
|
-
if (typeof length !== "number" || !Number.isInteger(length)) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
"Invalid argument for substring function: expected an integer as the third argument"
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return original.substring(start, start + length);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return original.substring(start);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default Substring;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import AggregateFunction from "./aggregate_function";
|
|
2
|
-
import ReducerElement from "./reducer_element";
|
|
3
|
-
import { FunctionDef } from "./function_metadata";
|
|
4
|
-
|
|
5
|
-
class SumReducerElement extends ReducerElement {
|
|
6
|
-
private _value: any = null;
|
|
7
|
-
public get value(): any {
|
|
8
|
-
return this._value;
|
|
9
|
-
}
|
|
10
|
-
public set value(value: any) {
|
|
11
|
-
if(this._value !== null) {
|
|
12
|
-
this._value += value;
|
|
13
|
-
} else {
|
|
14
|
-
this._value = value;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@FunctionDef({
|
|
20
|
-
description: "Calculates the sum of numeric values across grouped rows",
|
|
21
|
-
category: "aggregate",
|
|
22
|
-
parameters: [
|
|
23
|
-
{ name: "value", description: "Numeric value to sum", type: "number" }
|
|
24
|
-
],
|
|
25
|
-
output: { description: "Sum of all values", type: "number", example: 150 },
|
|
26
|
-
examples: ["WITH [1, 2, 3] AS nums UNWIND nums AS n RETURN sum(n)"]
|
|
27
|
-
})
|
|
28
|
-
class Sum extends AggregateFunction {
|
|
29
|
-
constructor() {
|
|
30
|
-
super("sum");
|
|
31
|
-
this._expectedParameterCount = 1;
|
|
32
|
-
}
|
|
33
|
-
public reduce(element: SumReducerElement): void {
|
|
34
|
-
element.value = this.firstChild().value();
|
|
35
|
-
}
|
|
36
|
-
public element(): SumReducerElement {
|
|
37
|
-
return new SumReducerElement();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default Sum;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Returns all elements of a list except the first",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [
|
|
8
|
-
{
|
|
9
|
-
name: "list",
|
|
10
|
-
description: "The list to get all but the first element from",
|
|
11
|
-
type: "array",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
output: {
|
|
15
|
-
description: "All elements except the first",
|
|
16
|
-
type: "array",
|
|
17
|
-
example: "[2, 3]",
|
|
18
|
-
},
|
|
19
|
-
examples: ["RETURN tail([1, 2, 3])", "WITH ['a', 'b', 'c'] AS items RETURN tail(items)"],
|
|
20
|
-
})
|
|
21
|
-
class Tail extends Function {
|
|
22
|
-
constructor() {
|
|
23
|
-
super("tail");
|
|
24
|
-
this._expectedParameterCount = 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public value(): any {
|
|
28
|
-
const val = this.getChildren()[0].value();
|
|
29
|
-
if (val === null || val === undefined) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
if (!Array.isArray(val)) {
|
|
33
|
-
throw new Error("tail() expects a list");
|
|
34
|
-
}
|
|
35
|
-
return val.slice(1);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default Tail;
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utility functions for temporal (date/time) operations.
|
|
3
|
-
*
|
|
4
|
-
* These helpers are used by the datetime, date, time, localdatetime,
|
|
5
|
-
* localtime, and timestamp functions.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Computes the ISO day of the week (1 = Monday, 7 = Sunday).
|
|
10
|
-
*/
|
|
11
|
-
function isoDayOfWeek(d: Date): number {
|
|
12
|
-
const jsDay = d.getDay(); // 0 = Sunday, 6 = Saturday
|
|
13
|
-
return jsDay === 0 ? 7 : jsDay;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Computes the day of the year (1-based).
|
|
18
|
-
*/
|
|
19
|
-
function dayOfYear(d: Date): number {
|
|
20
|
-
const start = new Date(d.getFullYear(), 0, 0);
|
|
21
|
-
const diff = d.getTime() - start.getTime();
|
|
22
|
-
const oneDay = 1000 * 60 * 60 * 24;
|
|
23
|
-
return Math.floor(diff / oneDay);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Computes the quarter (1-4) from a month (0-11).
|
|
28
|
-
*/
|
|
29
|
-
function quarter(month: number): number {
|
|
30
|
-
return Math.floor(month / 3) + 1;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Pads a number to a given width with leading zeros.
|
|
35
|
-
*/
|
|
36
|
-
function pad(n: number, width: number = 2): string {
|
|
37
|
-
return String(n).padStart(width, "0");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Formats a timezone offset in ±HH:MM format.
|
|
42
|
-
*/
|
|
43
|
-
function formatTimezoneOffset(d: Date): string {
|
|
44
|
-
const offset = -d.getTimezoneOffset();
|
|
45
|
-
if (offset === 0) return "Z";
|
|
46
|
-
const sign = offset > 0 ? "+" : "-";
|
|
47
|
-
const absOffset = Math.abs(offset);
|
|
48
|
-
const hours = Math.floor(absOffset / 60);
|
|
49
|
-
const minutes = absOffset % 60;
|
|
50
|
-
return `${sign}${pad(hours)}:${pad(minutes)}`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Parses a temporal argument (string or map) into a Date object.
|
|
55
|
-
*
|
|
56
|
-
* @param arg - The argument to parse (string or object with year/month/day/hour/minute/second/millisecond)
|
|
57
|
-
* @param fnName - The calling function name for error messages
|
|
58
|
-
* @returns A Date object
|
|
59
|
-
*/
|
|
60
|
-
export function parseTemporalArg(arg: any, fnName: string): Date {
|
|
61
|
-
if (typeof arg === "string") {
|
|
62
|
-
const d = new Date(arg);
|
|
63
|
-
if (isNaN(d.getTime())) {
|
|
64
|
-
throw new Error(`${fnName}(): Invalid temporal string: '${arg}'`);
|
|
65
|
-
}
|
|
66
|
-
return d;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (typeof arg === "number") {
|
|
70
|
-
// Treat as epoch milliseconds
|
|
71
|
-
return new Date(arg);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (typeof arg === "object" && arg !== null && !Array.isArray(arg)) {
|
|
75
|
-
// Map-style construction: {year, month, day, hour, minute, second, millisecond}
|
|
76
|
-
const year = arg.year ?? new Date().getFullYear();
|
|
77
|
-
const month = (arg.month ?? 1) - 1; // JS months are 0-based
|
|
78
|
-
const day = arg.day ?? 1;
|
|
79
|
-
const hour = arg.hour ?? 0;
|
|
80
|
-
const minute = arg.minute ?? 0;
|
|
81
|
-
const second = arg.second ?? 0;
|
|
82
|
-
const millisecond = arg.millisecond ?? 0;
|
|
83
|
-
return new Date(year, month, day, hour, minute, second, millisecond);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
throw new Error(
|
|
87
|
-
`${fnName}(): Expected a string, number (epoch millis), or map argument, got ${typeof arg}`
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Builds a datetime result object with full temporal properties.
|
|
93
|
-
*
|
|
94
|
-
* @param d - The Date object
|
|
95
|
-
* @param utc - If true, use UTC values; if false, use local values
|
|
96
|
-
* @returns An object with year, month, day, hour, minute, second, millisecond,
|
|
97
|
-
* epochMillis, epochSeconds, dayOfWeek, dayOfYear, quarter, formatted
|
|
98
|
-
*/
|
|
99
|
-
export function buildDatetimeObject(d: Date, utc: boolean): Record<string, any> {
|
|
100
|
-
const year = utc ? d.getUTCFullYear() : d.getFullYear();
|
|
101
|
-
const month = utc ? d.getUTCMonth() + 1 : d.getMonth() + 1;
|
|
102
|
-
const day = utc ? d.getUTCDate() : d.getDate();
|
|
103
|
-
const hour = utc ? d.getUTCHours() : d.getHours();
|
|
104
|
-
const minute = utc ? d.getUTCMinutes() : d.getMinutes();
|
|
105
|
-
const second = utc ? d.getUTCSeconds() : d.getSeconds();
|
|
106
|
-
const millisecond = utc ? d.getUTCMilliseconds() : d.getMilliseconds();
|
|
107
|
-
|
|
108
|
-
const datePart = new Date(year, month - 1, day);
|
|
109
|
-
|
|
110
|
-
const formatted = utc
|
|
111
|
-
? d.toISOString()
|
|
112
|
-
: `${year}-${pad(month)}-${pad(day)}T${pad(hour)}:${pad(minute)}:${pad(second)}.${pad(millisecond, 3)}`;
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
year,
|
|
116
|
-
month,
|
|
117
|
-
day,
|
|
118
|
-
hour,
|
|
119
|
-
minute,
|
|
120
|
-
second,
|
|
121
|
-
millisecond,
|
|
122
|
-
epochMillis: d.getTime(),
|
|
123
|
-
epochSeconds: Math.floor(d.getTime() / 1000),
|
|
124
|
-
dayOfWeek: isoDayOfWeek(datePart),
|
|
125
|
-
dayOfYear: dayOfYear(datePart),
|
|
126
|
-
quarter: quarter(month - 1),
|
|
127
|
-
formatted,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Builds a date result object (no time component).
|
|
133
|
-
*
|
|
134
|
-
* @param d - The Date object
|
|
135
|
-
* @returns An object with year, month, day, epochMillis, dayOfWeek, dayOfYear, quarter, formatted
|
|
136
|
-
*/
|
|
137
|
-
export function buildDateObject(d: Date): Record<string, any> {
|
|
138
|
-
const year = d.getFullYear();
|
|
139
|
-
const month = d.getMonth() + 1;
|
|
140
|
-
const day = d.getDate();
|
|
141
|
-
|
|
142
|
-
// Strip time component for epoch calculation
|
|
143
|
-
const dateOnly = new Date(year, month - 1, day);
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
year,
|
|
147
|
-
month,
|
|
148
|
-
day,
|
|
149
|
-
epochMillis: dateOnly.getTime(),
|
|
150
|
-
dayOfWeek: isoDayOfWeek(dateOnly),
|
|
151
|
-
dayOfYear: dayOfYear(dateOnly),
|
|
152
|
-
quarter: quarter(month - 1),
|
|
153
|
-
formatted: `${year}-${pad(month)}-${pad(day)}`,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Builds a time result object (no date component).
|
|
159
|
-
*
|
|
160
|
-
* @param d - The Date object
|
|
161
|
-
* @param utc - If true, use UTC values; if false, use local values
|
|
162
|
-
* @returns An object with hour, minute, second, millisecond, formatted
|
|
163
|
-
*/
|
|
164
|
-
export function buildTimeObject(d: Date, utc: boolean): Record<string, any> {
|
|
165
|
-
const hour = utc ? d.getUTCHours() : d.getHours();
|
|
166
|
-
const minute = utc ? d.getUTCMinutes() : d.getMinutes();
|
|
167
|
-
const second = utc ? d.getUTCSeconds() : d.getSeconds();
|
|
168
|
-
const millisecond = utc ? d.getUTCMilliseconds() : d.getMilliseconds();
|
|
169
|
-
|
|
170
|
-
const timePart = `${pad(hour)}:${pad(minute)}:${pad(second)}.${pad(millisecond, 3)}`;
|
|
171
|
-
const formatted = utc ? `${timePart}Z` : timePart;
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
hour,
|
|
175
|
-
minute,
|
|
176
|
-
second,
|
|
177
|
-
millisecond,
|
|
178
|
-
formatted,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
import { buildTimeObject, parseTemporalArg } from "./temporal_utils";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns a time value (with timezone offset awareness).
|
|
7
|
-
* When called with no arguments, returns the current UTC time.
|
|
8
|
-
* When called with a string argument, parses it as an ISO 8601 time.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```
|
|
12
|
-
* RETURN time() AS now
|
|
13
|
-
* RETURN time('12:30:00') AS t
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
@FunctionDef({
|
|
17
|
-
description:
|
|
18
|
-
"Returns a time value. With no arguments returns the current UTC time. " +
|
|
19
|
-
"Accepts an ISO 8601 time string or a map of components (hour, minute, second, millisecond).",
|
|
20
|
-
category: "scalar",
|
|
21
|
-
parameters: [
|
|
22
|
-
{
|
|
23
|
-
name: "input",
|
|
24
|
-
description: "Optional. An ISO 8601 time string (HH:MM:SS) or a map of components.",
|
|
25
|
-
type: "string",
|
|
26
|
-
required: false,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
output: {
|
|
30
|
-
description: "A time object with properties: hour, minute, second, millisecond, formatted",
|
|
31
|
-
type: "object",
|
|
32
|
-
},
|
|
33
|
-
examples: [
|
|
34
|
-
"RETURN time() AS now",
|
|
35
|
-
"RETURN time('12:30:00') AS t",
|
|
36
|
-
"WITH time() AS t RETURN t.hour, t.minute",
|
|
37
|
-
],
|
|
38
|
-
})
|
|
39
|
-
class Time extends Function {
|
|
40
|
-
constructor() {
|
|
41
|
-
super("time");
|
|
42
|
-
this._expectedParameterCount = null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public value(): any {
|
|
46
|
-
const children = this.getChildren();
|
|
47
|
-
if (children.length > 1) {
|
|
48
|
-
throw new Error("time() accepts at most one argument");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const d: Date =
|
|
52
|
-
children.length === 1 ? parseTemporalArg(children[0].value(), "time") : new Date();
|
|
53
|
-
|
|
54
|
-
return buildTimeObject(d, true);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default Time;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns the number of milliseconds since the Unix epoch (1970-01-01T00:00:00Z).
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```
|
|
9
|
-
* RETURN timestamp() AS ts
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
@FunctionDef({
|
|
13
|
-
description: "Returns the number of milliseconds since the Unix epoch (1970-01-01T00:00:00Z).",
|
|
14
|
-
category: "scalar",
|
|
15
|
-
parameters: [],
|
|
16
|
-
output: {
|
|
17
|
-
description: "Milliseconds since Unix epoch",
|
|
18
|
-
type: "number",
|
|
19
|
-
example: 1718450000000,
|
|
20
|
-
},
|
|
21
|
-
examples: [
|
|
22
|
-
"RETURN timestamp() AS ts",
|
|
23
|
-
"WITH timestamp() AS before, timestamp() AS after RETURN after - before",
|
|
24
|
-
],
|
|
25
|
-
})
|
|
26
|
-
class Timestamp extends Function {
|
|
27
|
-
constructor() {
|
|
28
|
-
super("timestamp");
|
|
29
|
-
this._expectedParameterCount = 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public value(): any {
|
|
33
|
-
return Date.now();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default Timestamp;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Converts a value to a floating point number",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [
|
|
8
|
-
{
|
|
9
|
-
name: "value",
|
|
10
|
-
description: "The value to convert to a float",
|
|
11
|
-
type: "any",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
output: {
|
|
15
|
-
description: "The floating point representation of the value",
|
|
16
|
-
type: "number",
|
|
17
|
-
example: "3.14",
|
|
18
|
-
},
|
|
19
|
-
examples: ['RETURN toFloat("3.14")', "RETURN toFloat(42)", "RETURN toFloat(true)"],
|
|
20
|
-
})
|
|
21
|
-
class ToFloat extends Function {
|
|
22
|
-
constructor() {
|
|
23
|
-
super("tofloat");
|
|
24
|
-
this._expectedParameterCount = 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public value(): any {
|
|
28
|
-
const val = this.getChildren()[0].value();
|
|
29
|
-
if (val === null || val === undefined) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
if (typeof val === "boolean") {
|
|
33
|
-
return val ? 1.0 : 0.0;
|
|
34
|
-
}
|
|
35
|
-
if (typeof val === "number") {
|
|
36
|
-
return val;
|
|
37
|
-
}
|
|
38
|
-
if (typeof val === "string") {
|
|
39
|
-
const trimmed = val.trim();
|
|
40
|
-
const parsed = Number(trimmed);
|
|
41
|
-
if (isNaN(parsed)) {
|
|
42
|
-
throw new Error(`Cannot convert string "${val}" to float`);
|
|
43
|
-
}
|
|
44
|
-
return parsed;
|
|
45
|
-
}
|
|
46
|
-
throw new Error("toFloat() expects a number, string, or boolean");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default ToFloat;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Converts a value to an integer",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [
|
|
8
|
-
{
|
|
9
|
-
name: "value",
|
|
10
|
-
description: "The value to convert to an integer",
|
|
11
|
-
type: "any",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
output: {
|
|
15
|
-
description: "The integer representation of the value",
|
|
16
|
-
type: "number",
|
|
17
|
-
example: "42",
|
|
18
|
-
},
|
|
19
|
-
examples: ['RETURN toInteger("42")', "RETURN toInteger(3.14)", "RETURN toInteger(true)"],
|
|
20
|
-
})
|
|
21
|
-
class ToInteger extends Function {
|
|
22
|
-
constructor() {
|
|
23
|
-
super("tointeger");
|
|
24
|
-
this._expectedParameterCount = 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public value(): any {
|
|
28
|
-
const val = this.getChildren()[0].value();
|
|
29
|
-
if (val === null || val === undefined) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
if (typeof val === "boolean") {
|
|
33
|
-
return val ? 1 : 0;
|
|
34
|
-
}
|
|
35
|
-
if (typeof val === "number") {
|
|
36
|
-
return Math.trunc(val);
|
|
37
|
-
}
|
|
38
|
-
if (typeof val === "string") {
|
|
39
|
-
const trimmed = val.trim();
|
|
40
|
-
const parsed = Number(trimmed);
|
|
41
|
-
if (isNaN(parsed)) {
|
|
42
|
-
throw new Error(`Cannot convert string "${val}" to integer`);
|
|
43
|
-
}
|
|
44
|
-
return Math.trunc(parsed);
|
|
45
|
-
}
|
|
46
|
-
throw new Error("toInteger() expects a number, string, or boolean");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default ToInteger;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Parses a JSON string into an object",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [{ name: "text", description: "JSON string to parse", type: "string" }],
|
|
8
|
-
output: { description: "Parsed object or array", type: "object", example: { a: 1 } },
|
|
9
|
-
examples: ["WITH '{\"a\": 1}' AS s RETURN tojson(s)"],
|
|
10
|
-
})
|
|
11
|
-
class ToJson extends Function {
|
|
12
|
-
constructor() {
|
|
13
|
-
super("tojson");
|
|
14
|
-
this._expectedParameterCount = 1;
|
|
15
|
-
}
|
|
16
|
-
public value(): any {
|
|
17
|
-
const str = this.getChildren()[0].value();
|
|
18
|
-
if (str === null || str === undefined) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
if (typeof str !== "string") {
|
|
22
|
-
throw new Error("Invalid arguments for tojson function");
|
|
23
|
-
}
|
|
24
|
-
return JSON.parse(str);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default ToJson;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Converts a string to lowercase",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [{ name: "text", description: "String to convert to lowercase", type: "string" }],
|
|
8
|
-
output: { description: "Lowercase string", type: "string", example: "hello world" },
|
|
9
|
-
examples: ["WITH 'Hello World' AS s RETURN toLower(s)", "WITH 'FOO' AS s RETURN toLower(s)"],
|
|
10
|
-
})
|
|
11
|
-
class ToLower extends Function {
|
|
12
|
-
constructor() {
|
|
13
|
-
super("tolower");
|
|
14
|
-
this._expectedParameterCount = 1;
|
|
15
|
-
}
|
|
16
|
-
public value(): any {
|
|
17
|
-
const val = this.getChildren()[0].value();
|
|
18
|
-
if (val === null || val === undefined) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
if (typeof val !== "string") {
|
|
22
|
-
throw new Error("Invalid argument for toLower function: expected a string");
|
|
23
|
-
}
|
|
24
|
-
return val.toLowerCase();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default ToLower;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Converts a value to its string representation",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [{ name: "value", description: "Value to convert to a string", type: "any" }],
|
|
8
|
-
output: { description: "String representation of the value", type: "string", example: "42" },
|
|
9
|
-
examples: [
|
|
10
|
-
"WITH 42 AS n RETURN toString(n)",
|
|
11
|
-
"WITH true AS b RETURN toString(b)",
|
|
12
|
-
"WITH [1, 2, 3] AS arr RETURN toString(arr)",
|
|
13
|
-
],
|
|
14
|
-
})
|
|
15
|
-
class ToString extends Function {
|
|
16
|
-
constructor() {
|
|
17
|
-
super("tostring");
|
|
18
|
-
this._expectedParameterCount = 1;
|
|
19
|
-
}
|
|
20
|
-
public value(): any {
|
|
21
|
-
const val = this.getChildren()[0].value();
|
|
22
|
-
if (val === null || val === undefined) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
if (typeof val === "object") {
|
|
26
|
-
return JSON.stringify(val);
|
|
27
|
-
}
|
|
28
|
-
return String(val);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default ToString;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Removes leading and trailing whitespace from a string",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [{ name: "text", description: "String to trim", type: "string" }],
|
|
8
|
-
output: { description: "Trimmed string", type: "string", example: "hello" },
|
|
9
|
-
examples: ["WITH ' hello ' AS s RETURN trim(s)", "WITH '\\tfoo\\n' AS s RETURN trim(s)"],
|
|
10
|
-
})
|
|
11
|
-
class Trim extends Function {
|
|
12
|
-
constructor() {
|
|
13
|
-
super("trim");
|
|
14
|
-
this._expectedParameterCount = 1;
|
|
15
|
-
}
|
|
16
|
-
public value(): any {
|
|
17
|
-
const val = this.getChildren()[0].value();
|
|
18
|
-
if (val === null || val === undefined) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
if (typeof val !== "string") {
|
|
22
|
-
throw new Error("Invalid argument for trim function: expected a string");
|
|
23
|
-
}
|
|
24
|
-
return val.trim();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default Trim;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import Function from "./function";
|
|
2
|
-
import { FunctionDef } from "./function_metadata";
|
|
3
|
-
|
|
4
|
-
@FunctionDef({
|
|
5
|
-
description: "Returns the type of a value as a string",
|
|
6
|
-
category: "scalar",
|
|
7
|
-
parameters: [
|
|
8
|
-
{ name: "value", description: "Value to check the type of", type: "any" }
|
|
9
|
-
],
|
|
10
|
-
output: { description: "Type of the input value", type: "string", example: "string" },
|
|
11
|
-
examples: [
|
|
12
|
-
"WITH 'hello' AS val RETURN type(val)",
|
|
13
|
-
"WITH 42 AS val RETURN type(val)",
|
|
14
|
-
"WITH [1, 2, 3] AS val RETURN type(val)"
|
|
15
|
-
]
|
|
16
|
-
})
|
|
17
|
-
class Type extends Function {
|
|
18
|
-
constructor() {
|
|
19
|
-
super("type");
|
|
20
|
-
this._expectedParameterCount = 1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public value(): any {
|
|
24
|
-
const val = this.getChildren()[0].value();
|
|
25
|
-
|
|
26
|
-
if (val === null) {
|
|
27
|
-
return "null";
|
|
28
|
-
}
|
|
29
|
-
if (val === undefined) {
|
|
30
|
-
return "undefined";
|
|
31
|
-
}
|
|
32
|
-
if (Array.isArray(val)) {
|
|
33
|
-
return "array";
|
|
34
|
-
}
|
|
35
|
-
return typeof val;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default Type;
|