flowquery 1.0.0

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.
Files changed (128) hide show
  1. package/.github/workflows/npm-publish.yml +30 -0
  2. package/.github/workflows/release.yml +84 -0
  3. package/CODE_OF_CONDUCT.md +10 -0
  4. package/FlowQueryLogoIcon.png +0 -0
  5. package/LICENSE +21 -0
  6. package/README.md +113 -0
  7. package/SECURITY.md +14 -0
  8. package/SUPPORT.md +13 -0
  9. package/docs/flowquery.min.js +1 -0
  10. package/docs/index.html +105 -0
  11. package/flowquery-vscode/.vscode-test.mjs +5 -0
  12. package/flowquery-vscode/.vscodeignore +13 -0
  13. package/flowquery-vscode/LICENSE +21 -0
  14. package/flowquery-vscode/README.md +11 -0
  15. package/flowquery-vscode/demo/FlowQueryVSCodeDemo.gif +0 -0
  16. package/flowquery-vscode/eslint.config.mjs +25 -0
  17. package/flowquery-vscode/extension.js +508 -0
  18. package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -0
  19. package/flowquery-vscode/flowquery-worker.js +66 -0
  20. package/flowquery-vscode/images/FlowQueryLogoIcon.png +0 -0
  21. package/flowquery-vscode/jsconfig.json +13 -0
  22. package/flowquery-vscode/libs/page.css +53 -0
  23. package/flowquery-vscode/libs/table.css +13 -0
  24. package/flowquery-vscode/libs/tabs.css +66 -0
  25. package/flowquery-vscode/package-lock.json +2917 -0
  26. package/flowquery-vscode/package.json +51 -0
  27. package/flowquery-vscode/test/extension.test.js +196 -0
  28. package/flowquery-vscode/test/worker.test.js +25 -0
  29. package/flowquery-vscode/vsc-extension-quickstart.md +42 -0
  30. package/jest.config.js +11 -0
  31. package/package.json +28 -0
  32. package/queries/analyze_catfacts.cql +75 -0
  33. package/queries/azure_openai_completions.cql +13 -0
  34. package/queries/azure_openai_models.cql +9 -0
  35. package/queries/mock_pipeline.cql +84 -0
  36. package/queries/openai_completions.cql +15 -0
  37. package/queries/openai_models.cql +13 -0
  38. package/queries/test.cql +6 -0
  39. package/queries/tool_inference.cql +24 -0
  40. package/queries/wisdom.cql +6 -0
  41. package/queries/wisdom_letter_histogram.cql +8 -0
  42. package/src/compute/runner.ts +65 -0
  43. package/src/index.browser.ts +11 -0
  44. package/src/index.ts +12 -0
  45. package/src/io/command_line.ts +74 -0
  46. package/src/parsing/alias.ts +23 -0
  47. package/src/parsing/alias_option.ts +5 -0
  48. package/src/parsing/ast_node.ts +153 -0
  49. package/src/parsing/base_parser.ts +92 -0
  50. package/src/parsing/components/csv.ts +9 -0
  51. package/src/parsing/components/from.ts +12 -0
  52. package/src/parsing/components/headers.ts +12 -0
  53. package/src/parsing/components/json.ts +9 -0
  54. package/src/parsing/components/null.ts +9 -0
  55. package/src/parsing/components/post.ts +9 -0
  56. package/src/parsing/components/text.ts +9 -0
  57. package/src/parsing/context.ts +48 -0
  58. package/src/parsing/data_structures/associative_array.ts +43 -0
  59. package/src/parsing/data_structures/json_array.ts +31 -0
  60. package/src/parsing/data_structures/key_value_pair.ts +37 -0
  61. package/src/parsing/data_structures/lookup.ts +40 -0
  62. package/src/parsing/data_structures/range_lookup.ts +36 -0
  63. package/src/parsing/expressions/expression.ts +142 -0
  64. package/src/parsing/expressions/f_string.ts +26 -0
  65. package/src/parsing/expressions/identifier.ts +22 -0
  66. package/src/parsing/expressions/number.ts +40 -0
  67. package/src/parsing/expressions/operator.ts +179 -0
  68. package/src/parsing/expressions/reference.ts +42 -0
  69. package/src/parsing/expressions/string.ts +34 -0
  70. package/src/parsing/functions/aggregate_function.ts +58 -0
  71. package/src/parsing/functions/avg.ts +37 -0
  72. package/src/parsing/functions/collect.ts +44 -0
  73. package/src/parsing/functions/function.ts +60 -0
  74. package/src/parsing/functions/function_factory.ts +66 -0
  75. package/src/parsing/functions/join.ts +26 -0
  76. package/src/parsing/functions/predicate_function.ts +44 -0
  77. package/src/parsing/functions/predicate_function_factory.ts +15 -0
  78. package/src/parsing/functions/predicate_sum.ts +29 -0
  79. package/src/parsing/functions/rand.ts +13 -0
  80. package/src/parsing/functions/range.ts +18 -0
  81. package/src/parsing/functions/reducer_element.ts +10 -0
  82. package/src/parsing/functions/replace.ts +19 -0
  83. package/src/parsing/functions/round.ts +17 -0
  84. package/src/parsing/functions/size.ts +17 -0
  85. package/src/parsing/functions/split.ts +26 -0
  86. package/src/parsing/functions/stringify.ts +26 -0
  87. package/src/parsing/functions/sum.ts +31 -0
  88. package/src/parsing/functions/to_json.ts +17 -0
  89. package/src/parsing/functions/value_holder.ts +13 -0
  90. package/src/parsing/logic/case.ts +26 -0
  91. package/src/parsing/logic/else.ts +12 -0
  92. package/src/parsing/logic/end.ts +9 -0
  93. package/src/parsing/logic/then.ts +12 -0
  94. package/src/parsing/logic/when.ts +12 -0
  95. package/src/parsing/operations/aggregated_return.ts +18 -0
  96. package/src/parsing/operations/aggregated_with.ts +18 -0
  97. package/src/parsing/operations/group_by.ts +124 -0
  98. package/src/parsing/operations/limit.ts +22 -0
  99. package/src/parsing/operations/load.ts +92 -0
  100. package/src/parsing/operations/operation.ts +65 -0
  101. package/src/parsing/operations/projection.ts +18 -0
  102. package/src/parsing/operations/return.ts +43 -0
  103. package/src/parsing/operations/unwind.ts +32 -0
  104. package/src/parsing/operations/where.ts +38 -0
  105. package/src/parsing/operations/with.ts +20 -0
  106. package/src/parsing/parser.ts +762 -0
  107. package/src/parsing/token_to_node.ts +91 -0
  108. package/src/tokenization/keyword.ts +43 -0
  109. package/src/tokenization/operator.ts +25 -0
  110. package/src/tokenization/string_walker.ts +194 -0
  111. package/src/tokenization/symbol.ts +15 -0
  112. package/src/tokenization/token.ts +633 -0
  113. package/src/tokenization/token_mapper.ts +53 -0
  114. package/src/tokenization/token_type.ts +15 -0
  115. package/src/tokenization/tokenizer.ts +229 -0
  116. package/src/tokenization/trie.ts +117 -0
  117. package/src/utils/object_utils.ts +17 -0
  118. package/src/utils/string_utils.ts +114 -0
  119. package/tests/compute/runner.test.ts +498 -0
  120. package/tests/parsing/context.test.ts +27 -0
  121. package/tests/parsing/expression.test.ts +40 -0
  122. package/tests/parsing/parser.test.ts +434 -0
  123. package/tests/tokenization/token_mapper.test.ts +47 -0
  124. package/tests/tokenization/tokenizer.test.ts +67 -0
  125. package/tests/tokenization/trie.test.ts +20 -0
  126. package/tsconfig.json +15 -0
  127. package/typedoc.json +16 -0
  128. package/webpack.config.js +26 -0
@@ -0,0 +1,30 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+
13
+ - uses: actions/setup-node@v4
14
+ with:
15
+ node-version: '20'
16
+ registry-url: 'https://registry.npmjs.org'
17
+
18
+ - name: Install dependencies
19
+ run: npm ci
20
+
21
+ - name: Run tests
22
+ run: npm test
23
+
24
+ - name: Build
25
+ run: npm run build
26
+
27
+ - name: Publish to npm
28
+ run: npm publish
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,84 @@
1
+ name: Build and Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - 'src/**'
9
+
10
+ permissions:
11
+ contents: write
12
+
13
+ jobs:
14
+ build-and-release:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0
22
+
23
+ - name: Setup Node.js
24
+ uses: actions/setup-node@v4
25
+ with:
26
+ node-version: '20'
27
+ cache: 'npm'
28
+
29
+ - name: Install dependencies
30
+ run: npm ci
31
+
32
+ - name: Run tests
33
+ run: npm test
34
+
35
+ - name: Build project
36
+ run: npm run build
37
+
38
+ - name: Verify build artifacts
39
+ run: |
40
+ echo "Checking build artifacts..."
41
+ ls -la dist/flowquery.min.js || echo "dist/flowquery.min.js not found"
42
+
43
+ - name: Copy to VS Code extension
44
+ run: |
45
+ echo "Copying flowquery.min.js to VS Code extension..."
46
+ mkdir -p flowquery-vscode/flowQueryEngine
47
+ cp dist/flowquery.min.js flowquery-vscode/flowQueryEngine/
48
+ ls -la flowquery-vscode/flowQueryEngine/
49
+
50
+ - name: Install VS Code extension dependencies
51
+ working-directory: ./flowquery-vscode
52
+ run: |
53
+ npm install @vscode/vsce
54
+
55
+ - name: Package VS Code extension
56
+ working-directory: ./flowquery-vscode
57
+ run: |
58
+ npx @vscode/vsce package
59
+ ls -la *.vsix
60
+
61
+ - name: Generate version tag
62
+ id: version
63
+ run: |
64
+ VERSION=$(node -p "require('./package.json').version")
65
+ TIMESTAMP=$(date +%Y%m%d-%H%M%S)
66
+ TAG="v${VERSION}-${TIMESTAMP}"
67
+ echo "tag=${TAG}" >> $GITHUB_OUTPUT
68
+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
69
+
70
+ - name: Create GitHub Release
71
+ uses: softprops/action-gh-release@v1
72
+ with:
73
+ token: ${{ secrets.PAT_TOKEN }}
74
+ tag_name: ${{ steps.version.outputs.tag }}
75
+ name: Release ${{ steps.version.outputs.tag }}
76
+ body: |
77
+ Automated release from main branch
78
+ Version: ${{ steps.version.outputs.version }}
79
+ Commit: ${{ github.sha }}
80
+ files: |
81
+ dist/flowquery.min.js
82
+ flowquery-vscode/*.vsix
83
+ draft: false
84
+ prerelease: false
@@ -0,0 +1,10 @@
1
+ # Microsoft Open Source Code of Conduct
2
+
3
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4
+
5
+ Resources:
6
+
7
+ - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8
+ - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9
+ - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10
+ - Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
Binary file
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ ![FlowQuery](./FlowQueryLogoIcon.png)
2
+
3
+ A declarative query language for data processing pipelines.
4
+
5
+ FlowQuery is a declarative query language for defining and executing data processing pipelines involving (but not limited to) API calls over http. The language is very well suited for prototyping of for example LLM chain-of-thought pipelines involving fetching grounding data from APIs, and processing that grounding data in multiple successive LLM calls where the next call builds on previous results. FlowQuery is based on many of the core language constructs in the OpenCypher query language except (currently) concepts related to graphs. Additionally, FlowQuery implements its own language constructs, such as Python-style f-strings, and special predicate functions operating over lists. FlowQuery is not limited to its current capabilities and may evolve beyond this in the future to include language constructs such as variables and/or other language concepts from OpenCypher.
6
+
7
+ The main motivation of FlowQuery is rapid prototyping of fixed step data processing pipelines involving LLMs (for example chain-of-thought) and as such drastically shorten the work needed to create such data processing pipelines. A core business outcome of this is faster product value experimentation loops, which leads to shorter time-to-market for product ideas involving LLMs.
8
+
9
+ FlowQuery is written in TypeScript (https://www.typescriptlang.org/) and built/compiled runs both in browser or in Node as a self-contained one-file Javascript library.
10
+
11
+ - Test live at <a href="https://microsoft.github.io/FlowQuery/" target="_blank">https://microsoft.github.io/FlowQuery/</a>.
12
+ - Try as a VSCode plugin from https://marketplace.visualstudio.com/items?itemName=FlowQuery.flowquery-vscode.
13
+
14
+ ## Howto
15
+ - Dev: ```npm start```
16
+ - This will start a FlowQuery command line where you can run statements.
17
+ - Test: ```npm test```
18
+ - This will run all unit tests.
19
+ - Build: ```npm run build``` (builds for both Node and web)
20
+
21
+ ## Examples
22
+ See also .\queries and .\tests\compute\runner.test.ts for more examples.
23
+ ```cypher
24
+ /*
25
+ Collect 10 random pieces of wisdom and create a letter histogram.
26
+ */
27
+ unwind range(0,10) as i
28
+ load json from "https://api.adviceslip.com/advice" as item
29
+ with join(collect(item.slip.advice),"") as wisdom
30
+ unwind split(wisdom,"") as letter
31
+ return letter, sum(1) as lettercount
32
+ ```
33
+ ```cypher
34
+ /*
35
+ This query fetches 10 cat facts from the Cat Facts API (https://catfact.ninja/fact)
36
+ and then uses the OpenAI API to analyze those cat facts and return a short summary
37
+ of the most interesting facts and what they imply about cats as pets.
38
+
39
+ To run this query, you need to set the OPENAI_API_KEY variable to your OpenAI API key.
40
+ You also need to set the OpenAI-Organization header to your organization ID.
41
+ You can find your organization ID in the OpenAI dashboard.
42
+ See https://platform.openai.com/docs/guides/chat for more information.
43
+ */
44
+ // Setup OpenAI API key and organization ID
45
+ with
46
+ 'YOUR_OPENAI_API_KEY' as OPENAI_API_KEY,
47
+ 'YOUR_OPENAI_ORGANIZATION_ID' as OPENAI_ORGANIZATION_ID
48
+
49
+ // Get 10 cat facts and collect them into a list
50
+ unwind range(0,10) as i
51
+ load json from "https://catfact.ninja/fact" as item
52
+ with collect(item.fact) as catfacts
53
+
54
+ // Create prompt to analyze cat facts
55
+ with f"
56
+ Analyze the following cat facts and answer with a short summary of the most interesting facts, and what they imply about cats as pets:
57
+ {join(catfacts, '\n')}
58
+ " as catfacts_analysis_prompt
59
+
60
+ // Call OpenAI API to analyze cat facts
61
+ load json from 'https://api.openai.com/v1/chat/completions'
62
+ headers {
63
+ `Content-Type`: 'application/json',
64
+ Authorization: f'Bearer {OPENAI_API_KEY}',
65
+ `OpenAI-Organization`: OPENAI_ORGANIZATION_ID
66
+ }
67
+ post {
68
+ model: 'gpt-4o-mini',
69
+ messages: [{role: 'user', content: catfacts_analysis_prompt}],
70
+ temperature: 0.7
71
+ } as openai_response
72
+ with openai_response.choices[0].message.content as catfacts_analysis
73
+
74
+ // Return the analysis
75
+ return catfacts_analysis
76
+ ```
77
+ ```cypher
78
+ // Test completion from Azure OpenAI API
79
+ with
80
+ 'YOUR_AZURE_OPENAI_API_KEY' as AZURE_OPENAI_API_KEY
81
+ load json from 'https://YOUR_DEPLOYMENT_NAME.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-08-01-preview'
82
+ headers {
83
+ `Content-Type`: 'application/json',
84
+ `api-key`: AZURE_OPENAI_API_KEY,
85
+ }
86
+ post {
87
+ messages: [{role: 'user', content: 'Answer with this is a test!'}],
88
+ temperature: 0.7
89
+ } as data
90
+ return data
91
+ ```
92
+
93
+ ## Contributing
94
+
95
+ This project welcomes contributions and suggestions. Most contributions require you to agree to a
96
+ Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
97
+ the rights to use your contribution. For details, visit [Contributor License Agreements](https://cla.opensource.microsoft.com).
98
+
99
+ When you submit a pull request, a CLA bot will automatically determine whether you need to provide
100
+ a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
101
+ provided by the bot. You will only need to do this once across all repos using our CLA.
102
+
103
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
104
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
105
+ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
106
+
107
+ ## Trademarks
108
+
109
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
110
+ trademarks or logos is subject to and must follow
111
+ [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general).
112
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
113
+ Any use of third-party trademarks or logos are subject to those third-party's policies.
package/SECURITY.md ADDED
@@ -0,0 +1,14 @@
1
+ <!-- BEGIN MICROSOFT SECURITY.MD V1.0.0 BLOCK -->
2
+
3
+ ## Security
4
+
5
+ Microsoft takes the security of our software products and services seriously, which
6
+ includes all source code repositories in our GitHub organizations.
7
+
8
+ **Please do not report security vulnerabilities through public GitHub issues.**
9
+
10
+ For security reporting information, locations, contact information, and policies,
11
+ please review the latest guidance for Microsoft repositories at
12
+ [https://aka.ms/SECURITY.md](https://aka.ms/SECURITY.md).
13
+
14
+ <!-- END MICROSOFT SECURITY.MD BLOCK -->
package/SUPPORT.md ADDED
@@ -0,0 +1,13 @@
1
+ # Support
2
+
3
+ ## How to file issues and get help
4
+
5
+ This project uses GitHub Issues to track bugs and feature requests. Please search the existing
6
+ issues before filing new issues to avoid duplicates. For new issues, file your bug or
7
+ feature request as a new Issue.
8
+
9
+ For help and questions about using this project, please use https://stackoverflow.com with the #FlowQuery tag.
10
+
11
+ ## Microsoft Support Policy
12
+
13
+ Support for this **PROJECT or PRODUCT** is limited to the resources listed above.
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FlowQuery=t():e.FlowQuery=t()}(self,(()=>(()=>{"use strict";var e={7474:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(7056));t.default=class{constructor(e=null){if(null===e||""===e)throw new Error("Statement cannot be null or empty");const t=(new i.default).parse(e);this.first=t.firstChild(),this.last=t.lastChild()}run(){return r(this,void 0,void 0,(function*(){return new Promise(((e,t)=>r(this,void 0,void 0,(function*(){try{yield this.first.run(),yield this.first.finish(),e()}catch(e){t(e)}}))))}))}get results(){return this.last.results}}},610:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(7474));t.default=n.default},5859:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(e){super(),this.alias=e}toString(){return`Alias (${this.alias})`}getAlias(){return this.alias}value(){return this.alias}}t.default=i},4275:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.AliasOption=void 0,function(e){e[e.NOT_ALLOWED=0]="NOT_ALLOWED",e[e.OPTIONAL=1]="OPTIONAL",e[e.REQUIRED=2]="REQUIRED"}(s||(t.AliasOption=s={}))},1542:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this._parent=null,this.children=[]}addChild(e){e._parent=this,this.children.push(e)}firstChild(){if(0===this.children.length)throw new Error("Expected child");return this.children[0]}lastChild(){if(0===this.children.length)throw new Error("Expected child");return this.children[this.children.length-1]}getChildren(){return this.children}childCount(){return this.children.length}value(){return null}isOperator(){return!1}isOperand(){return!this.isOperator()}get precedence(){return 0}get leftAssociative(){return!1}print(){return Array.from(this._print(0)).join("\n")}*_print(e){0===e?yield this.constructor.name:e>0&&(yield"-".repeat(e)+` ${this.toString()}`);for(const t of this.children)yield*t._print(e+1)}toString(){return this.constructor.name}}},3738:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(7847)),i=r(s(3479));t.default=class{constructor(){this.tokens=[],this.tokenIndex=0}tokenize(e){this.tokens=new i.default(e).tokenize(),this.tokenIndex=0}setNextToken(){this.tokenIndex++}peek(){return this.tokenIndex+1>=this.tokens.length?null:this.tokens[this.tokenIndex+1]}ahead(e,t=!0){let s=0;for(let r=this.tokenIndex;r<this.tokens.length;r++)if(!t||!this.tokens[r].isWhitespaceOrComment()){if(!this.tokens[r].equals(e[s]))return!1;if(s++,s===e.length)break}return s===e.length}get token(){return this.tokenIndex>=this.tokens.length?n.default.EOF:this.tokens[this.tokenIndex]}get previousToken(){return this.tokenIndex-1<0?n.default.EOF:this.tokens[this.tokenIndex-1]}}},3840:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}}t.default=i},970:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}value(){return this.children[0].value()}}t.default=i},9798:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}value(){return this.firstChild().value()||{}}}t.default=i},5956:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}}t.default=i},8587:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}}t.default=i},440:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}}t.default=i},2457:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}}t.default=i},9056:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.stack=[]}push(e){this.stack.push(e)}pop(){return this.stack.pop()}containsType(e){return this.stack.some((t=>t instanceof e))}}},122:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{addKeyValue(e){this.addChild(e)}toString(){return"AssociativeArray"}*_value(){for(const e of this.children){const t=e;yield{[t.key]:t._value}}}value(){return Object.assign({},...this._value())}}t.default=i},1363:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{addValue(e){this.addChild(e)}value(){return this.children.map((e=>e.value()))}}t.default=i},2073:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542)),i=r(s(3198));class u extends n.default{constructor(e,t){super(),this.addChild(new i.default(e)),this.addChild(t)}get key(){return this.children[0].value()}get _value(){return this.children[1].value()}toString(){return"KeyValuePair"}}t.default=u},9997:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}set index(e){this.addChild(e)}get index(){return this.children[0]}set variable(e){this.addChild(e)}get variable(){return this.children[1]}isOperand(){return!0}value(){return this.variable.value()[this.index.value()]}}t.default=i},3399:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}set from(e){this.addChild(e)}get from(){return this.children[0]}set to(e){this.addChild(e)}get to(){return this.children[1]}set variable(e){this.addChild(e)}get variable(){return this.children[2]}isOperand(){return!0}value(){const e=this.variable.value(),t=this.from.value()||0,s=this.to.value()||e.length;return this.variable.value().slice(t,s)}}t.default=i},3573:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542)),i=r(s(5481)),u=r(s(2730));class a extends n.default{constructor(){super(...arguments),this.operators=[],this.output=[],this._alias=null,this._overridden=null,this._reducers=null}addNode(e){if(e.isOperand())this.output.push(e);else if(e.isOperator()){const t=e;for(;this.operators.length>0;){let e=this.operators[this.operators.length-1];if(!(e.precedence>t.precedence||e.precedence===t.precedence&&t.leftAssociative))break;this.output.push(e),this.operators.pop()}this.operators.push(t)}}finish(){let e;for(;e=this.operators.pop();)this.output.push(e);this.addChild(this.toTree())}toTree(){const e=this.output.pop()||new n.default;if(e.isOperator()){const t=this.toTree(),s=this.toTree();e.addChild(s),e.addChild(t)}return e}nodesAdded(){return this.operators.length>0||this.output.length>0}value(){if(null!==this._overridden)return this._overridden;if(1!==this.childCount())throw new Error("Expected one child");return this.children[0].value()}setAlias(e){this._alias=e}set alias(e){this._alias=e}get alias(){return this.firstChild()instanceof u.default&&null===this._alias?this.firstChild().identifier:this._alias}toString(){return null!==this._alias?`Expression (${this._alias})`:"Expression"}reducers(){return null===this._reducers&&(this._reducers=[...this._extract_reducers()]),this._reducers}*_extract_reducers(e=this){e instanceof i.default&&(yield e);for(const t of e.getChildren())yield*this._extract_reducers(t)}mappable(){return 0===this.reducers().length}has_reducers(){return this.reducers().length>0}set overridden(e){this._overridden=e}}t.default=a},1153:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{value(){return this.getChildren().map((e=>e.value())).join("")}}t.default=i},5196:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(3198));class i extends n.default{toString(){return`Identifier (${this._value})`}value(){return super.value()}}t.default=i},3818:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(e){super(),-1!==e.indexOf(".")?this._value=parseFloat(e):this._value=parseInt(e)}value(){return this._value}toString(){return`${this.constructor.name} (${this._value})`}}t.default=i},4783:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Is=t.Not=t.Or=t.And=t.LessThanOrEqual=t.GreaterThanOrEqual=t.LessThan=t.GreaterThan=t.NotEquals=t.Equals=t.Power=t.Modulo=t.Divide=t.Multiply=t.Subtract=t.Add=t.Operator=void 0;const n=r(s(1542));class i extends n.default{constructor(e,t){super(),this._precedence=0,this._leftAssociative=!0,this._precedence=e,this._leftAssociative=t}isOperator(){return!0}get precedence(){return this._precedence}get leftAssociative(){return this._leftAssociative}get lhs(){return this.getChildren()[0]}get rhs(){return this.getChildren()[1]}}t.Operator=i,t.Add=class extends i{constructor(){super(1,!0)}value(){return this.lhs.value()+this.rhs.value()}},t.Subtract=class extends i{constructor(){super(1,!0)}value(){return this.lhs.value()-this.rhs.value()}},t.Multiply=class extends i{constructor(){super(2,!0)}value(){return this.lhs.value()*this.rhs.value()}},t.Divide=class extends i{constructor(){super(2,!0)}value(){return this.lhs.value()/this.rhs.value()}},t.Modulo=class extends i{constructor(){super(2,!0)}value(){return this.lhs.value()%this.rhs.value()}},t.Power=class extends i{constructor(){super(3,!1)}value(){return Math.pow(this.lhs.value(),this.rhs.value())}},t.Equals=class extends i{constructor(){super(0,!0)}value(){return this.lhs.value()===this.rhs.value()?1:0}},t.NotEquals=class extends i{constructor(){super(0,!0)}value(){return this.lhs.value()!==this.rhs.value()?1:0}},t.GreaterThan=class extends i{constructor(){super(0,!0)}value(){return this.lhs.value()>this.rhs.value()?1:0}},t.LessThan=class extends i{constructor(){super(0,!0)}value(){return this.lhs.value()<this.rhs.value()?1:0}},t.GreaterThanOrEqual=class extends i{constructor(){super(0,!0)}value(){return this.lhs.value()>=this.rhs.value()?1:0}},t.LessThanOrEqual=class extends i{constructor(){super(0,!0)}value(){return this.lhs.value()<=this.rhs.value()?1:0}},t.And=class extends i{constructor(){super(-1,!0)}value(){return this.lhs.value()&&this.rhs.value()?1:0}},t.Or=class extends i{constructor(){super(-1,!0)}value(){return this.lhs.value()||this.rhs.value()?1:0}},t.Not=class extends i{constructor(){super(0,!0)}isOperator(){return!1}value(){return this.lhs.value()?0:1}},t.Is=class extends i{constructor(){super(-1,!0)}value(){return this.lhs.value()===this.rhs.value()?1:0}}},2730:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5196));class i extends n.default{constructor(e,t=void 0){super(e),this._referred=void 0,this._referred=t}set referred(e){this._referred=e}toString(){return`Reference (${this._value})`}value(){var e;return null===(e=this._referred)||void 0===e?void 0:e.value()}get identifier(){return this._value}}t.default=i},3198:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(e){super(),this._value=e}value(){return this._value}toString(){return`String (${this._value})`}}t.default=i},5481:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517));class i extends n.default{constructor(e){super(e),this._overridden=null}reduce(e){throw new Error("Method not implemented.")}element(){throw new Error("Method not implemented.")}get overridden(){return this._overridden}set overridden(e){this._overridden=e}value(){return this._overridden}}t.default=i},8437:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5481)),i=r(s(1206));class u extends i.default{constructor(){super(...arguments),this._count=0,this._sum=null}get value(){return null===this._sum?null:this._sum/this._count}set value(e){this._count+=1,null!==this._sum?this._sum+=e:this._sum=e}}class a extends n.default{constructor(){super("avg"),this._expectedParameterCount=1}reduce(e){e.value=this.firstChild().value()}element(){return new u}}t.default=a},1567:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5481)),i=r(s(1206));class u extends i.default{constructor(){super(...arguments),this._value=[]}get value(){return this._value}set value(e){this._value.push(e)}}class a extends i.default{constructor(){super(...arguments),this._value=new Map}get value(){return Array.from(this._value.values())}set value(e){const t=JSON.stringify(e);this._value.has(t)||this._value.set(t,e)}}class l extends n.default{constructor(){super("collect"),this._distinct=!1,this._expectedParameterCount=1}reduce(e){e.value=this.firstChild().value()}element(){return this._distinct?new a:new u}set distinct(e){this._distinct=e}}t.default=l},5517:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(e){super(),this._expectedParameterCount=null,this._supports_distinct=!1,this._name=e}set parameters(e){if(null!==this._expectedParameterCount&&this._expectedParameterCount!==e.length)throw new Error(`Function ${this._name} expected ${this._expectedParameterCount} parameters, but got ${e.length}`);this.children=e}get name(){return this._name}toString(){return`Function (${this._name})`}set distinct(e){if(!this._supports_distinct)throw new Error(`Function ${this._name} does not support distinct`);this._supports_distinct=e}}t.default=i},2312:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(9854)),i=r(s(1567)),u=r(s(8437)),a=r(s(8240)),l=r(s(7514)),o=r(s(3605)),h=r(s(6781)),d=r(s(197)),c=r(s(8673)),f=r(s(2061)),p=r(s(3700)),_=r(s(9700)),v=r(s(5517));t.default=class{static create(e){switch(e.toLowerCase()){case"sum":return new n.default;case"collect":return new i.default;case"avg":return new u.default;case"range":return new a.default;case"rand":return new l.default;case"round":return new o.default;case"split":return new h.default;case"join":return new d.default;case"tojson":return new c.default;case"replace":return new f.default;case"stringify":return new p.default;case"size":return new _.default;default:return new v.default(e)}}}},197:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517)),i=r(s(3198));class u extends n.default{constructor(){super("join"),this._expectedParameterCount=2}set parameters(e){1===e.length&&e.push(new i.default("")),super.parameters=e}value(){const e=this.getChildren()[0].value(),t=this.getChildren()[1].value();if(!Array.isArray(e)||"string"!=typeof t)throw new Error("Invalid arguments for join function");return e.join(t)}}t.default=u},8963:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542)),i=r(s(2333));class u extends n.default{constructor(e){super(),this._valueHolder=new i.default,this._name=e}get reference(){return this.firstChild()}get array(){return this.getChildren()[1].firstChild()}get _return(){return this.getChildren()[2]}get where(){return 4===this.getChildren().length?this.getChildren()[3]:null}value(){throw new Error("Method not implemented.")}toString(){return`PredicateFunction (${this._name})`}}t.default=u},8706:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(8963)),i=r(s(2912));t.default=class{static create(e){return"sum"===e.toLowerCase()?new i.default:new n.default(e)}}},2912:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(8963));class i extends n.default{constructor(){super("sum")}value(){this.reference.referred=this._valueHolder;const e=this.array.value();if(null===e||!Array.isArray(e))throw new Error("Invalid array for sum function");let t=null;for(let s=0;s<e.length;s++)this._valueHolder.holder=e[s],(null===this.where||this.where.value())&&(null===t?t=this._return.value():t+=this._return.value());return t}}t.default=i},7514:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517));class i extends n.default{constructor(){super("rand"),this._expectedParameterCount=0}value(){return Math.random()}}t.default=i},8240:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517));class i extends n.default{constructor(){super("range"),this._expectedParameterCount=2}value(){const e=this.getChildren()[0].value(),t=this.getChildren()[1].value();if("number"!=typeof e||"number"!=typeof t)throw new Error("Invalid arguments for range function");return Array.from({length:t-e+1},((t,s)=>e+s))}}t.default=i},1206:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{get value(){throw new Error("Method not implemented.")}set value(e){throw new Error("Method not implemented.")}}},2061:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517));class i extends n.default{constructor(){super("replace"),this._expectedParameterCount=3}value(){const e=this.getChildren()[0].value(),t=this.getChildren()[1].value(),s=this.getChildren()[2].value();if("string"!=typeof e||"string"!=typeof t||"string"!=typeof s)throw new Error("Invalid arguments for replace function");return e.replace(new RegExp(t,"g"),s)}}t.default=i},3605:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517));class i extends n.default{constructor(){super("round"),this._expectedParameterCount=1}value(){const e=this.getChildren()[0].value();if("number"!=typeof e)throw new Error("Invalid argument for round function");return Math.round(e)}}t.default=i},9700:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517));class i extends n.default{constructor(){super("size"),this._expectedParameterCount=1}value(){const e=this.getChildren()[0].value();if(!Array.isArray(e))throw new Error("Invalid argument for size function");return e.length}}t.default=i},6781:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517)),i=r(s(3198));class u extends n.default{constructor(){super("split"),this._expectedParameterCount=2}set parameters(e){1===e.length&&e.push(new i.default("")),super.parameters=e}value(){const e=this.getChildren()[0].value(),t=this.getChildren()[1].value();if("string"!=typeof e||"string"!=typeof t)throw new Error("Invalid arguments for split function");return e.split(t)}}t.default=u},3700:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517)),i=r(s(3818));class u extends n.default{constructor(){super("stringify"),this._expectedParameterCount=2}set parameters(e){1===e.length&&e.push(new i.default("3")),super.parameters=e}value(){const e=this.getChildren()[0].value(),t=parseInt(this.getChildren()[1].value());if("object"!=typeof e)throw new Error("Invalid argument for stringify function");return JSON.stringify(e,null,t)}}t.default=u},9854:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5481)),i=r(s(1206));class u extends i.default{constructor(){super(...arguments),this._value=null}get value(){return this._value}set value(e){null!==this._value?this._value+=e:this._value=e}}class a extends n.default{constructor(){super("sum"),this._expectedParameterCount=1}reduce(e){e.value=this.firstChild().value()}element(){return new u}}t.default=a},8673:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5517));class i extends n.default{constructor(){super("tojson"),this._expectedParameterCount=1}value(){const e=this.getChildren()[0].value();if("string"!=typeof e)throw new Error("Invalid arguments for tojson function");return JSON.parse(e)}}t.default=i},2333:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{set holder(e){this._holder=e}value(){return this._holder}}t.default=i},6052:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542)),i=r(s(1740));class u extends n.default{constructor(){super()}value(){let e=0,t=this.getChildren()[e];for(;t instanceof i.default;){const s=this.getChildren()[e+1];if(t.value())return s.value();e+=2,t=this.getChildren()[e]}return t.value()}}t.default=u},3501:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}value(){return this.getChildren()[0].value()}}t.default=i},6263:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}}t.default=i},6667:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}value(){return this.getChildren()[0].value()}}t.default=i},1740:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(1542));class i extends n.default{constructor(){super()}value(){return this.getChildren()[0].value()}}t.default=i},8682:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(7342)),u=n(s(9025));class a extends i.default{constructor(){super(...arguments),this._group_by=new u.default(this.children)}run(){return r(this,void 0,void 0,(function*(){yield this._group_by.run()}))}get results(){return null!==this._where&&(this._group_by.where=this._where),Array.from(this._group_by.generate_results())}}t.default=a},6564:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(7342)),u=n(s(9025));class a extends i.default{constructor(){super(...arguments),this._group_by=new u.default(this.children)}run(){return r(this,void 0,void 0,(function*(){yield this._group_by.run()}))}finish(){const e=Object.create(null,{finish:{get:()=>super.finish}});return r(this,void 0,void 0,(function*(){var t;for(const e of this._group_by.generate_results())yield null===(t=this.next)||void 0===t?void 0:t.run();yield e.finish.call(this)}))}}t.default=a},9025:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(505));class u{constructor(e=null){this._children=new Map,this._elements=null,this._value=e}get value(){return this._value}get children(){return this._children}get elements(){return this._elements}set elements(e){this._elements=e}}class a extends i.default{constructor(){super(...arguments),this._root=new u,this._current=this._root,this._mappers=null,this._reducers=null,this._where=null}run(){return r(this,void 0,void 0,(function*(){this.resetTree(),this.map(),this.reduce()}))}get root(){return this._root}get current(){return this._current}set current(e){this._current=e}resetTree(){this.current=this.root}map(){let e=this.current;for(const t of this.mappers){const s=t.value();let r=e.children.get(s);void 0===r&&(r=new u(s),e.children.set(s,r)),e=r}this.current=e}reduce(){null===this.current.elements&&(this.current.elements=this.reducers.map((e=>e.element())));const e=this.current.elements;this.reducers.forEach(((t,s)=>{t.reduce(e[s])}))}get mappers(){return null===this._mappers&&(this._mappers=[...this._generate_mappers()]),this._mappers}*_generate_mappers(){for(const[e,t]of this.expressions())e.mappable()&&(yield e)}get reducers(){return null===this._reducers&&(this._reducers=this.children.map((e=>e.reducers())).flat()),this._reducers}*generate_results(e=0,t=this.root){var s;if(t.children.size>0)for(const s of t.children.values())this.mappers[e].overridden=s.value,yield*this.generate_results(e+1,s);else{null===(s=t.elements)||void 0===s||s.forEach(((e,t)=>{this.reducers[t].overridden=e.value}));const e={};for(const[t,s]of this.expressions())e[s]=t.value();this.where&&(yield e)}}set where(e){this._where=e}get where(){return null===this._where||this._where.value()}}t.default=a},8365:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(5239));class u extends i.default{constructor(e){super(),this.count=0,this.limit=0,this.limit=e}run(){return r(this,void 0,void 0,(function*(){var e;this.count>=this.limit||(this.count++,yield null===(e=this.next)||void 0===e?void 0:e.run())}))}reset(){this.count=0}}t.default=u},1816:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(5239)),u=n(s(5956)),a=n(s(2457)),l=n(s(9798)),o=n(s(440));class h extends i.default{constructor(){super(),this._value=null}get type(){return this.children[0]}get from(){return this.children[1].value()}get headers(){return this.childCount()>2&&this.children[2]instanceof l.default&&this.children[2].value()||{}}get payload(){let e=null;return this.childCount()>2&&this.children[2]instanceof o.default?e=this.children[2]:this.childCount()>3&&this.children[3]instanceof o.default&&(e=this.children[3]),null!==e?e.firstChild():null}method(){return null===this.payload?"GET":"POST"}options(){const e=this.headers,t=this.payload,s=null==t?void 0:t.value();return null===s||"object"!=typeof s||e.hasOwnProperty("Content-Type")||(e["Content-Type"]="application/json"),Object.assign({method:this.method(),headers:e},null!==t?{body:JSON.stringify(t.value())}:{})}load(){return r(this,void 0,void 0,(function*(){var e,t,s;const r=yield fetch(this.from,this.options());let n=null;if(this.type instanceof u.default?n=yield r.json():this.type instanceof a.default&&(n=yield r.text()),Array.isArray(n))for(const t of n)this._value=t,yield null===(e=this.next)||void 0===e?void 0:e.run();else"object"==typeof n&&null!==n?(this._value=n,yield null===(t=this.next)||void 0===t?void 0:t.run()):"string"==typeof n&&(this._value=n,yield null===(s=this.next)||void 0===s?void 0:s.run())}))}run(){return r(this,void 0,void 0,(function*(){try{yield this.load()}catch(e){throw new Error(`Failed to load data from ${this.from}. Error: ${e}`)}}))}value(){return this._value}}t.default=h},5239:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(1542));class u extends i.default{constructor(){super(),this._previous=null,this._next=null}get previous(){return this._previous}set previous(e){this._previous=e}get next(){return this._next}set next(e){this._next=e}addSibling(e){var t;null===(t=this._parent)||void 0===t||t.addChild(e),e.previous=this,this.next=e}run(){return r(this,void 0,void 0,(function*(){throw new Error("Not implemented")}))}finish(){return r(this,void 0,void 0,(function*(){var e;yield null===(e=this.next)||void 0===e?void 0:e.finish()}))}reset(){}get results(){throw new Error("Not implemented")}}t.default=u},505:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(5239));class i extends n.default{constructor(e){super(),this.children=e}*expressions(){for(let e=0;e<this.children.length;e++){const t=this.children[e],s=t.alias||`expr${e}`;yield[t,s]}}}t.default=i},7342:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(505));class u extends i.default{constructor(){super(...arguments),this._where=null,this._results=[]}set where(e){this._where=e}get where(){return null===this._where||this._where.value()}run(){return r(this,void 0,void 0,(function*(){if(!this.where)return;const e=new Map;for(const[t,s]of this.expressions()){const r=t.value();e.set(s,r)}this._results.push(Object.fromEntries(e))}))}get results(){return this._results}}t.default=u},577:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(5239));class u extends i.default{constructor(e){super(),this.addChild(e)}get expression(){return this.children[0]}get as(){return this.children[1].value}run(){return r(this,void 0,void 0,(function*(){var e,t;const s=this.expression.value();if(!Array.isArray(s))throw new Error("Expected array");for(let t=0;t<s.length;t++)this._value=s[t],yield null===(e=this.next)||void 0===e?void 0:e.run();null===(t=this.next)||void 0===t||t.reset()}))}value(){return this._value}}t.default=u},6001:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(5239));class u extends i.default{constructor(e){super(),this.addChild(e)}get expression(){return this.children[0]}run(){return r(this,void 0,void 0,(function*(){var e;this.expression.value()&&(yield null===(e=this.next)||void 0===e?void 0:e.run())}))}value(){return this.expression.value()}}t.default=u},696:function(e,t,s){var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(n,i){function u(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(s(505));class u extends i.default{run(){return r(this,void 0,void 0,(function*(){var e;yield null===(e=this.next)||void 0===e?void 0:e.run()}))}}t.default=u},7056:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(7342)),i=r(s(3573)),u=r(s(1542)),a=r(s(3738)),l=r(s(2312)),o=r(s(5517)),h=r(s(122)),d=r(s(1363)),c=r(s(2073)),f=r(s(696)),p=r(s(577)),_=r(s(6001)),v=s(4275),E=r(s(1816)),w=r(s(970)),O=r(s(5859)),m=r(s(9798)),x=r(s(6052)),g=r(s(1740)),k=r(s(3501)),T=r(s(6667)),A=r(s(9997)),C=s(4783),y=r(s(2730)),R=r(s(440)),N=r(s(8682)),S=r(s(9056)),M=r(s(5481)),D=r(s(3001)),P=r(s(7847)),I=r(s(8706)),L=r(s(1153)),b=r(s(3198)),W=r(s(6564)),j=r(s(5196)),K=r(s(8365)),Y=r(s(3399)),B=r(s(8587));class F extends a.default{constructor(){super(...arguments),this.variables=new Map,this.context=new S.default,this._returns=0}parse(e){this.tokenize(e);const t=new u.default;let s=null,r=null;for(;!this.token.isEOF();){if(t.childCount()>0?this.expectAndSkipWhitespaceAndComments():this.skipWhitespaceAndComments(),r=this.parseOperation(),null===r)throw new Error("Expected one of WITH, UNWIND, RETURN, or LOAD");if(this._returns>1)throw new Error("Only one RETURN statement is allowed");null!==s?s.addSibling(r):t.addChild(r);const e=this.parseWhere();null!==e&&(r instanceof n.default?r.where=e:(r.addSibling(e),r=e));const i=this.parseLimit();null!==i&&(r.addSibling(i),r=i),s=r}if(!(r instanceof n.default))throw new Error("Last statement must be a RETURN or a WHERE statement");return t}parseOperation(){return this.parseWith()||this.parseUnwind()||this.parseReturn()||this.parseLoad()}parseWith(){if(!this.token.isWith())return null;this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const e=Array.from(this.parseExpressions(v.AliasOption.REQUIRED));if(0===e.length)throw new Error("Expected expression");return e.some((e=>e.has_reducers()))?new W.default(e):new f.default(e)}parseUnwind(){if(!this.token.isUnwind())return null;this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const e=this.parseExpression();if(null===e)throw new Error("Expected expression");if(!D.default.isInstanceOfAny(e.firstChild(),[d.default,o.default,y.default,A.default,Y.default]))throw new Error("Expected array, function, reference, or lookup.");this.expectAndSkipWhitespaceAndComments();const t=this.parseAlias();if(null===t)throw new Error("Expected alias");e.setAlias(t.getAlias());const s=new p.default(e);return this.variables.set(t.getAlias(),s),s}parseReturn(){if(!this.token.isReturn())return null;this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const e=Array.from(this.parseExpressions(v.AliasOption.OPTIONAL));if(0===e.length)throw new Error("Expected expression");return e.some((e=>e.has_reducers()))?new N.default(e):(this._returns++,new n.default(e))}parseWhere(){if(!this.token.isWhere())return null;this.expectPreviousTokenToBeWhitespaceOrComment(),this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const e=this.parseExpression();if(null===e)throw new Error("Expected expression");if(D.default.isInstanceOfAny(e.firstChild(),[d.default,h.default]))throw new Error("Expected an expression which can be evaluated to a boolean");return new _.default(e)}parseLoad(){if(!this.token.isLoad())return null;const e=new E.default;if(this.setNextToken(),this.expectAndSkipWhitespaceAndComments(),!(this.token.isJSON()||this.token.isCSV()||this.token.isText()))throw new Error("Expected JSON, CSV, or TEXT");if(e.addChild(this.token.node),this.setNextToken(),this.expectAndSkipWhitespaceAndComments(),!this.token.isFrom())throw new Error("Expected FROM");this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const t=new w.default;e.addChild(t);const s=this.parseExpression();if(null===s)throw new Error("Expected expression");if(t.addChild(s),this.expectAndSkipWhitespaceAndComments(),this.token.isHeaders()){const t=new m.default;this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const s=this.parseExpression();if(null===s)throw new Error("Expected expression");t.addChild(s),e.addChild(t),this.expectAndSkipWhitespaceAndComments()}if(this.token.isPost()){const t=new R.default;this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const s=this.parseExpression();if(null===s)throw new Error("Expected expression");t.addChild(s),e.addChild(t),this.expectAndSkipWhitespaceAndComments()}const r=this.parseAlias();if(null===r)throw new Error("Expected alias");return e.addChild(r),this.variables.set(r.getAlias(),e),e}parseLimit(){if(this.skipWhitespaceAndComments(),!this.token.isLimit())return null;if(this.expectPreviousTokenToBeWhitespaceOrComment(),this.setNextToken(),this.expectAndSkipWhitespaceAndComments(),!this.token.isNumber())throw new Error("Expected number");const e=new K.default(parseInt(this.token.value||"0"));return this.setNextToken(),e}*parseExpressions(e=v.AliasOption.NOT_ALLOWED){for(;;){const t=this.parseExpression();if(null===t)break;{const s=this.parseAlias();if(t.firstChild()instanceof y.default&&null===s){const e=t.firstChild();t.setAlias(e.identifier),this.variables.set(e.identifier,t)}else{if(!(e!==v.AliasOption.REQUIRED||null!==s||t.firstChild()instanceof y.default))throw new Error("Alias required");if(e===v.AliasOption.NOT_ALLOWED&&null!==s)throw new Error("Alias not allowed");[v.AliasOption.OPTIONAL,v.AliasOption.REQUIRED].includes(e)&&null!==s&&(t.setAlias(s.getAlias()),this.variables.set(s.getAlias(),t))}yield t}if(this.skipWhitespaceAndComments(),!this.token.isComma())break;this.setNextToken()}}parseExpression(){var e,t;const s=new i.default;for(;;){if(this.skipWhitespaceAndComments(),this.token.isIdentifier()&&!(null===(e=this.peek())||void 0===e?void 0:e.isLeftParenthesis())){const e=this.token.value||"",t=new y.default(e,this.variables.get(e));this.setNextToken();const r=this.parseLookup(t);s.addNode(r)}else if(this.token.isIdentifier()&&(null===(t=this.peek())||void 0===t?void 0:t.isLeftParenthesis())){const e=this.parsePredicateFunction()||this.parseFunction();if(null!==e){const t=this.parseLookup(e);s.addNode(t)}}else if(this.token.isOperand())s.addNode(this.token.node),this.setNextToken();else if(this.token.isFString()){const e=this.parseFString();if(null===e)throw new Error("Expected f-string");s.addNode(e)}else if(this.token.isLeftParenthesis()){this.setNextToken();const e=this.parseExpression();if(null===e)throw new Error("Expected expression");if(!this.token.isRightParenthesis())throw new Error("Expected right parenthesis");this.setNextToken();const t=this.parseLookup(e);s.addNode(t)}else if(this.token.isOpeningBrace()||this.token.isOpeningBracket()){const e=this.parseJSON();if(null===e)throw new Error("Expected JSON object");const t=this.parseLookup(e);s.addNode(t)}else if(this.token.isCase()){const e=this.parseCase();if(null===e)throw new Error("Expected CASE statement");s.addNode(e)}else{if(!this.token.isNot()){if(s.nodesAdded())throw new Error("Expected operand or left parenthesis");break}{const e=new C.Not;this.setNextToken();const t=this.parseExpression();if(null===t)throw new Error("Expected expression");e.addChild(t),s.addNode(e)}}if(this.skipWhitespaceAndComments(),!this.token.isOperator())break;s.addNode(this.token.node),this.setNextToken()}return s.nodesAdded()?(s.finish(),s):null}parseLookup(e){let t=e,s=null;for(;;){if(this.token.isDot()){if(this.setNextToken(),!this.token.isIdentifier()&&!this.token.isKeyword())throw new Error("Expected identifier");s=new A.default,s.index=new j.default(this.token.value||""),s.variable=t,this.setNextToken()}else{if(!this.token.isOpeningBracket())break;{this.setNextToken(),this.skipWhitespaceAndComments();const e=this.parseExpression();let r=null;if(this.skipWhitespaceAndComments(),this.token.isColon())this.setNextToken(),this.skipWhitespaceAndComments(),s=new Y.default,r=this.parseExpression();else{if(null===e)throw new Error("Expected expression");s=new A.default}if(this.skipWhitespaceAndComments(),!this.token.isClosingBracket())throw new Error("Expected closing bracket");this.setNextToken(),s instanceof Y.default?(s.from=e||new B.default,s.to=r||new B.default):s instanceof A.default&&null!==e&&(s.index=e),s.variable=t}}t=s||t}return t}parseCase(){if(!this.token.isCase())return null;this.setNextToken();const e=new x.default;let t=0;for(this.expectAndSkipWhitespaceAndComments();;){const s=this.parseWhen();if(null===s&&0===t)throw new Error("Expected WHEN");if(null===s&&t>0)break;null!==s&&e.addChild(s),this.expectAndSkipWhitespaceAndComments();const r=this.parseThen();if(null===r)throw new Error("Expected THEN");e.addChild(r),this.expectAndSkipWhitespaceAndComments(),t++}const s=this.parseElse();if(null===s)throw new Error("Expected ELSE");if(e.addChild(s),this.expectAndSkipWhitespaceAndComments(),!this.token.isEnd())throw new Error("Expected END");return this.setNextToken(),e}parseWhen(){if(!this.token.isWhen())return null;this.setNextToken();const e=new g.default;this.expectAndSkipWhitespaceAndComments();const t=this.parseExpression();if(null===t)throw new Error("Expected expression");return e.addChild(t),e}parseThen(){if(!this.token.isThen())return null;this.setNextToken();const e=new T.default;this.expectAndSkipWhitespaceAndComments();const t=this.parseExpression();if(null===t)throw new Error("Expected expression");return e.addChild(t),e}parseElse(){if(!this.token.isElse())return null;this.setNextToken();const e=new k.default;this.expectAndSkipWhitespaceAndComments();const t=this.parseExpression();if(null===t)throw new Error("Expected expression");return e.addChild(t),e}parseAlias(){if(this.skipWhitespaceAndComments(),!this.token.isAs())return null;if(this.expectPreviousTokenToBeWhitespaceOrComment(),this.setNextToken(),this.expectAndSkipWhitespaceAndComments(),!this.token.isIdentifier()&&!this.token.isKeyword()||null===this.token.value)throw new Error("Expected identifier");const e=new O.default(this.token.value||"");return this.setNextToken(),e}parseFunction(){var e;if(!this.token.isIdentifier())return null;if(null===this.token.value)throw new Error("Expected identifier");if(!(null===(e=this.peek())||void 0===e?void 0:e.isLeftParenthesis()))return null;const t=l.default.create(this.token.value);if(t instanceof M.default&&this.context.containsType(M.default))throw new Error("Aggregate functions cannot be nested");if(this.context.push(t),this.setNextToken(),this.setNextToken(),this.skipWhitespaceAndComments(),this.token.isDistinct()&&(t.distinct=!0,this.setNextToken(),this.expectAndSkipWhitespaceAndComments()),t.parameters=Array.from(this.parseExpressions(v.AliasOption.NOT_ALLOWED)),this.skipWhitespaceAndComments(),!this.token.isRightParenthesis())throw new Error("Expected right parenthesis");return this.setNextToken(),this.context.pop(),t}parsePredicateFunction(){if(!this.ahead([P.default.IDENTIFIER(""),P.default.LEFT_PARENTHESIS,P.default.IDENTIFIER(""),P.default.IN]))return null;if(null===this.token.value)throw new Error("Expected identifier");const e=I.default.create(this.token.value);if(this.setNextToken(),!this.token.isLeftParenthesis())throw new Error("Expected left parenthesis");if(this.setNextToken(),this.skipWhitespaceAndComments(),!this.token.isIdentifier())throw new Error("Expected identifier");const t=new y.default(this.token.value);if(this.variables.set(t.identifier,t),e.addChild(t),this.setNextToken(),this.expectAndSkipWhitespaceAndComments(),!this.token.isIn())throw new Error("Expected IN");this.setNextToken(),this.expectAndSkipWhitespaceAndComments();const s=this.parseExpression();if(null===s)throw new Error("Expected expression");if(!D.default.isInstanceOfAny(s.firstChild(),[d.default,y.default,A.default,o.default]))throw new Error("Expected array or reference");if(e.addChild(s),this.skipWhitespaceAndComments(),!this.token.isPipe())throw new Error("Expected pipe");this.setNextToken();const r=this.parseExpression();if(null===r)throw new Error("Expected expression");e.addChild(r);const n=this.parseWhere();if(null!==n&&e.addChild(n),this.skipWhitespaceAndComments(),!this.token.isRightParenthesis())throw new Error("Expected right parenthesis");return this.setNextToken(),this.variables.delete(t.identifier),e}parseFString(){if(!this.token.isFString())return null;const e=new L.default;for(;this.token.isFString()&&(null!==this.token.value&&e.addChild(new b.default(this.token.value)),this.setNextToken(),this.token.isOpeningBrace());){this.setNextToken();const t=this.parseExpression();if(null===t)throw new Error("Expected expression");if(e.addChild(t),!this.token.isClosingBrace())throw new Error("Expected closing brace");this.setNextToken()}return e}parseJSON(){if(this.token.isOpeningBrace()){const e=this.parseAssociativeArray();if(null===e)throw new Error("Expected associative array");return e}if(this.token.isOpeningBracket()){const e=this.parseJSONArray();if(null===e)throw new Error("Expected JSON array");return e}throw new Error("Expected opening brace or bracket")}parseAssociativeArray(){if(!this.token.isOpeningBrace())return null;const e=new h.default;for(this.setNextToken();this.skipWhitespaceAndComments(),!this.token.isClosingBrace();){if(!this.token.isIdentifier()&&!this.token.isKeyword())throw new Error("Expected identifier");const t=this.token.value;if(null===t)throw new Error("Expected string");if(this.setNextToken(),this.skipWhitespaceAndComments(),!this.token.isColon())throw new Error("Expected colon");this.setNextToken(),this.skipWhitespaceAndComments();const s=this.parseExpression();if(null===s)throw new Error("Expected expression");e.addKeyValue(new c.default(t,s)),this.skipWhitespaceAndComments(),this.token.isComma()&&this.setNextToken()}return this.setNextToken(),e}parseJSONArray(){if(!this.token.isOpeningBracket())return null;const e=new d.default;for(this.setNextToken();this.skipWhitespaceAndComments(),!this.token.isClosingBracket();){const t=this.parseExpression();if(null===t)throw new Error("Expected expression");e.addValue(t),this.skipWhitespaceAndComments(),this.token.isComma()&&this.setNextToken()}return this.setNextToken(),e}expectAndSkipWhitespaceAndComments(){if(!this.skipWhitespaceAndComments())throw new Error("Expected whitespace or comment")}skipWhitespaceAndComments(){let e=this.previousToken.isWhitespaceOrComment();for(;this.token.isWhitespace()||this.token.isComment();)this.setNextToken(),e=!0;return e}expectPreviousTokenToBeWhitespaceOrComment(){if(!this.previousToken.isWhitespaceOrComment())throw new Error("Expected whitespace or comment")}}t.default=F},8595:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=s(4783),i=r(s(3198)),u=r(s(5196)),a=r(s(3818)),l=r(s(1542)),o=r(s(5956)),h=r(s(3840)),d=r(s(2457)),c=r(s(1740)),f=r(s(6667)),p=r(s(3501)),_=r(s(6263)),v=r(s(8587));t.default=class{static convert(e){if(e.isNumber()){if(null===e.value)throw new Error("Number token has no value");return new a.default(e.value)}if(e.isString()){if(null===e.value)throw new Error("String token has no value");return new i.default(e.value)}if(e.isIdentifier()){if(null===e.value)throw new Error("Identifier token has no value");return new u.default(e.value)}if(e.isOperator()){if(e.isAdd())return new n.Add;if(e.isSubtract())return new n.Subtract;if(e.isMultiply())return new n.Multiply;if(e.isDivide())return new n.Divide;if(e.isModulo())return new n.Modulo;if(e.isExponent())return new n.Power;if(e.isEquals())return new n.Equals;if(e.isLessThan())return new n.LessThan;if(e.isGreaterThan())return new n.GreaterThan;if(e.isGreaterThanOrEqual())return new n.GreaterThanOrEqual;if(e.isLessThanOrEqual())return new n.LessThanOrEqual;if(e.isAnd())return new n.And;if(e.isOr())return new n.Or;if(e.isIs())return new n.Is}else if(e.isUnaryOperator()){if(e.isNot())return new n.Not}else{if(!e.isKeyword())throw new Error("Unknown token");if(e.isJSON())return new o.default;if(e.isCSV())return new h.default;if(e.isText())return new d.default;if(e.isWhen())return new c.default;if(e.isThen())return new f.default;if(e.isElse())return new p.default;if(e.isEnd())return new _.default;if(e.isNull())return new v.default}return new l.default}}},7825:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.RETURN="RETURN",e.MATCH="MATCH",e.WHERE="WHERE",e.CREATE="CREATE",e.MERGE="MERGE",e.DELETE="DELETE",e.DETACH="DETACH",e.SET="SET",e.REMOVE="REMOVE",e.FOREACH="FOREACH",e.WITH="WITH",e.CALL="CALL",e.YIELD="YIELD",e.LOAD="LOAD",e.HEADERS="HEADERS",e.POST="POST",e.FROM="FROM",e.CSV="CSV",e.JSON="JSON",e.TEXT="TEXT",e.AS="AS",e.UNWIND="UNWIND",e.SUM="SUM",e.COLLECT="COLLECT",e.DISTINCT="DISTINCT",e.ORDER="ORDER",e.BY="BY",e.ASC="ASC",e.DESC="DESC",e.SKIP="SKIP",e.LIMIT="LIMIT",e.EOF="EOF",e.CASE="CASE",e.WHEN="WHEN",e.THEN="THEN",e.ELSE="ELSE",e.END="END",e.NULL="NULL",e.IN="IN"}(s||(s={})),t.default=s},2008:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.ADD="+",e.SUBTRACT="-",e.MULTIPLY="*",e.DIVIDE="/",e.MODULO="%",e.EXPONENT="^",e.EQUALS="=",e.NOT_EQUALS="<>",e.LESS_THAN="<",e.LESS_THAN_OR_EQUAL="<=",e.GREATER_THAN=">",e.GREATER_THAN_OR_EQUAL=">=",e.IS="IS",e.AND="AND",e.OR="OR",e.NOT="NOT",e.IN="IN",e.PIPE="|"}(s||(s={})),t.default=s},178:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(6519));t.default=class{constructor(e){this.text=e,this._position=0}get position(){return this._position}get currentChar(){return this.text[this.position]}get nextChar(){return this.text[this.position+1]}get previousChar(){return this.text[this.position-1]}get isAtEnd(){return this.position>=this.text.length}getString(e){return this.text.substring(e,this.position)}getRemainingString(){return this.text.substring(this.position)}checkForSingleComment(){if(this.singleLineCommentStart()){for(;!this.isAtEnd&&!this.newLine();)this._position++;return!0}return!1}checkForMultiLineComment(){if(this.multiLineCommentStart()){for(;!this.isAtEnd;){if(this.multiLineCommentEnd())return this._position+=2,!0;this._position++}throw new Error(`Unterminated multi-line comment at position ${this.position}`)}return!1}singleLineCommentStart(){return"/"===this.currentChar&&"/"===this.nextChar}multiLineCommentStart(){return"/"===this.currentChar&&"*"===this.nextChar}multiLineCommentEnd(){return"*"===this.currentChar&&"/"===this.nextChar}newLine(){return"\n"===this.currentChar}escaped(e){return"\\"===this.currentChar&&this.nextChar===e}escapedBrace(){return"{"===this.currentChar&&"{"===this.nextChar||"}"===this.currentChar&&"}"===this.nextChar}openingBrace(){return"{"===this.currentChar}closingBrace(){return"}"===this.currentChar}checkForUnderScore(){const e="_"===this.currentChar;return e&&this._position++,e}checkForLetter(){const e=n.default.letters.includes(this.currentChar.toLowerCase());return e&&this._position++,e}checkForDigit(){const e=n.default.digits.includes(this.currentChar);return e&&this._position++,e}checkForQuote(){const e=this.currentChar;return'"'===e||"'"===e||"`"===e?(this._position++,e):null}checkForString(e){const t=this.text.substring(this.position,this.position+e.length).toLowerCase()===e.toLowerCase();return t&&(this._position+=e.length),t}checkForWhitespace(){return n.default.whitespace.includes(this.currentChar)}checkForFStringStart(){return"f"===this.currentChar.toLowerCase()&&["'",'"',"`"].includes(this.nextChar)}moveNext(){this._position++}moveBy(e){this._position+=e}movePrevious(){this._position--}is_word(e){return null!==e&&this.text.substring(this.position,this.position+e.length)===e}word_continuation(e){const t=this.text[this.position+e.length];return n.default.word_valid_chars.includes(t)}}},4020:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.LEFT_PARENTHESIS="(",e.RIGHT_PARENTHESIS=")",e.COMMA=",",e.DOT=".",e.COLON=":",e.WHITESPACE="",e.OPENING_BRACE="{",e.CLOSING_BRACE="}",e.OPENING_BRACKET="[",e.CLOSING_BRACKET="]",e.BACKTICK="`"}(s||(s={})),t.default=s},7847:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(8898)),i=r(s(7825)),u=r(s(4020)),a=r(s(2008)),l=r(s(8595)),o=r(s(6519));class h{constructor(e,t=null){this._position=-1,this._case_sensitive_value=null,this._can_be_identifier=!1,this._type=e,this._value=t,this._can_be_identifier=o.default.can_be_identifier(t||"")}equals(e){return this._type===n.default.IDENTIFIER&&e.type===n.default.IDENTIFIER||this._type===e.type&&this._value===e.value}set position(e){this._position=e}get position(){return this._position}get type(){return this._type}get value(){return this._case_sensitive_value||this._value}set case_sensitive_value(e){this._case_sensitive_value=e}get can_be_identifier(){return this._can_be_identifier}get node(){return l.default.convert(this)}toString(){return`${this._type} ${this._value}`}static COMMENT(e){return new h(n.default.COMMENT,e)}isComment(){return this._type===n.default.COMMENT}static IDENTIFIER(e){return new h(n.default.IDENTIFIER,e)}isIdentifier(){return this._type===n.default.IDENTIFIER||this._type===n.default.BACKTICK_STRING}static STRING(e,t='"'){const s=o.default.unquote(e),r=o.default.removeEscapedQuotes(s,t);return new h(n.default.STRING,r)}isString(){return this._type===n.default.STRING||this._type===n.default.BACKTICK_STRING}static BACKTICK_STRING(e,t='"'){const s=o.default.unquote(e),r=o.default.removeEscapedQuotes(s,t);return new h(n.default.BACKTICK_STRING,r)}static F_STRING(e,t='"'){const s=o.default.unquote(e),r=o.default.removeEscapedQuotes(s,t),i=o.default.removeEscapedBraces(r);return new h(n.default.F_STRING,i)}isFString(){return this._type===n.default.F_STRING}static NUMBER(e){return new h(n.default.NUMBER,e)}isNumber(){return this._type===n.default.NUMBER}static get LEFT_PARENTHESIS(){return new h(n.default.SYMBOL,u.default.LEFT_PARENTHESIS)}isLeftParenthesis(){return this._type===n.default.SYMBOL&&this._value===u.default.LEFT_PARENTHESIS}static get RIGHT_PARENTHESIS(){return new h(n.default.SYMBOL,u.default.RIGHT_PARENTHESIS)}isRightParenthesis(){return this._type===n.default.SYMBOL&&this._value===u.default.RIGHT_PARENTHESIS}static get COMMA(){return new h(n.default.SYMBOL,u.default.COMMA)}isComma(){return this._type===n.default.SYMBOL&&this._value===u.default.COMMA}static get DOT(){return new h(n.default.SYMBOL,u.default.DOT)}isDot(){return this._type===n.default.SYMBOL&&this._value===u.default.DOT}static get COLON(){return new h(n.default.SYMBOL,u.default.COLON)}isColon(){return this._type===n.default.SYMBOL&&this._value===u.default.COLON}static get OPENING_BRACE(){return new h(n.default.SYMBOL,u.default.OPENING_BRACE)}isOpeningBrace(){return this._type===n.default.SYMBOL&&this._value===u.default.OPENING_BRACE}static get CLOSING_BRACE(){return new h(n.default.SYMBOL,u.default.CLOSING_BRACE)}isClosingBrace(){return this._type===n.default.SYMBOL&&this._value===u.default.CLOSING_BRACE}static get OPENING_BRACKET(){return new h(n.default.SYMBOL,u.default.OPENING_BRACKET)}isOpeningBracket(){return this._type===n.default.SYMBOL&&this._value===u.default.OPENING_BRACKET}static get CLOSING_BRACKET(){return new h(n.default.SYMBOL,u.default.CLOSING_BRACKET)}isClosingBracket(){return this._type===n.default.SYMBOL&&this._value===u.default.CLOSING_BRACKET}static get WHITESPACE(){return new h(n.default.WHITESPACE)}isWhitespace(){return this._type===n.default.WHITESPACE}isOperator(){return this._type===n.default.OPERATOR}isUnaryOperator(){return this._type===n.default.UNARY_OPERATOR}static get ADD(){return new h(n.default.OPERATOR,a.default.ADD)}isAdd(){return this._type===n.default.OPERATOR&&this._value===a.default.ADD}static get SUBTRACT(){return new h(n.default.OPERATOR,a.default.SUBTRACT)}isSubtract(){return this._type===n.default.OPERATOR&&this._value===a.default.SUBTRACT}isNegation(){return this.isSubtract()}static get MULTIPLY(){return new h(n.default.OPERATOR,a.default.MULTIPLY)}isMultiply(){return this._type===n.default.OPERATOR&&this._value===a.default.MULTIPLY}static get DIVIDE(){return new h(n.default.OPERATOR,a.default.DIVIDE)}isDivide(){return this._type===n.default.OPERATOR&&this._value===a.default.DIVIDE}static get EXPONENT(){return new h(n.default.OPERATOR,a.default.EXPONENT)}isExponent(){return this._type===n.default.OPERATOR&&this._value===a.default.EXPONENT}static get MODULO(){return new h(n.default.OPERATOR,a.default.MODULO)}isModulo(){return this._type===n.default.OPERATOR&&this._value===a.default.MODULO}static get EQUALS(){return new h(n.default.OPERATOR,a.default.EQUALS)}isEquals(){return this._type===n.default.OPERATOR&&this._value===a.default.EQUALS}static get NOT_EQUALS(){return new h(n.default.OPERATOR,a.default.NOT_EQUALS)}isNotEquals(){return this._type===n.default.OPERATOR&&this._value===a.default.NOT_EQUALS}static get LESS_THAN(){return new h(n.default.OPERATOR,a.default.LESS_THAN)}isLessThan(){return this._type===n.default.OPERATOR&&this._value===a.default.LESS_THAN}static get LESS_THAN_OR_EQUAL(){return new h(n.default.OPERATOR,a.default.LESS_THAN_OR_EQUAL)}isLessThanOrEqual(){return this._type===n.default.OPERATOR&&this._value===a.default.LESS_THAN_OR_EQUAL}static get GREATER_THAN(){return new h(n.default.OPERATOR,a.default.GREATER_THAN)}isGreaterThan(){return this._type===n.default.OPERATOR&&this._value===a.default.GREATER_THAN}static get GREATER_THAN_OR_EQUAL(){return new h(n.default.OPERATOR,a.default.GREATER_THAN_OR_EQUAL)}isGreaterThanOrEqual(){return this._type===n.default.OPERATOR&&this._value===a.default.GREATER_THAN_OR_EQUAL}static get AND(){return new h(n.default.OPERATOR,a.default.AND)}isAnd(){return this._type===n.default.OPERATOR&&this._value===a.default.AND}static get OR(){return new h(n.default.OPERATOR,a.default.OR)}isOr(){return this._type===n.default.OPERATOR&&this._value===a.default.OR}static get NOT(){return new h(n.default.UNARY_OPERATOR,a.default.NOT)}isNot(){return this._type===n.default.UNARY_OPERATOR&&this._value===a.default.NOT}static get IS(){return new h(n.default.OPERATOR,a.default.IS)}isIs(){return this._type===n.default.OPERATOR&&this._value===a.default.IS}isKeyword(){return this._type===n.default.KEYWORD}static get WITH(){return new h(n.default.KEYWORD,i.default.WITH)}isWith(){return this._type===n.default.KEYWORD&&this._value===i.default.WITH}static get RETURN(){return new h(n.default.KEYWORD,i.default.RETURN)}isReturn(){return this._type===n.default.KEYWORD&&this._value===i.default.RETURN}static get LOAD(){return new h(n.default.KEYWORD,i.default.LOAD)}isLoad(){return this._type===n.default.KEYWORD&&this._value===i.default.LOAD}static get JSON(){return new h(n.default.KEYWORD,i.default.JSON)}isJSON(){return this._type===n.default.KEYWORD&&this._value===i.default.JSON}static get CSV(){return new h(n.default.KEYWORD,i.default.CSV)}isCSV(){return this._type===n.default.KEYWORD&&this._value===i.default.CSV}static get TEXT(){return new h(n.default.KEYWORD,i.default.TEXT)}isText(){return this._type===n.default.KEYWORD&&this._value===i.default.TEXT}static get FROM(){return new h(n.default.KEYWORD,i.default.FROM)}isFrom(){return this._type===n.default.KEYWORD&&this._value===i.default.FROM}static get HEADERS(){return new h(n.default.KEYWORD,i.default.HEADERS)}isHeaders(){return this._type===n.default.KEYWORD&&this._value===i.default.HEADERS}static get POST(){return new h(n.default.KEYWORD,i.default.POST)}isPost(){return this._type===n.default.KEYWORD&&this._value===i.default.POST}static get UNWIND(){return new h(n.default.KEYWORD,i.default.UNWIND)}isUnwind(){return this._type===n.default.KEYWORD&&this._value===i.default.UNWIND}static get MATCH(){return new h(n.default.KEYWORD,i.default.MATCH)}isMatch(){return this._type===n.default.KEYWORD&&this._value===i.default.MATCH}static get AS(){return new h(n.default.KEYWORD,i.default.AS)}isAs(){return this._type===n.default.KEYWORD&&this._value===i.default.AS}static get WHERE(){return new h(n.default.KEYWORD,i.default.WHERE)}isWhere(){return this._type===n.default.KEYWORD&&this._value===i.default.WHERE}static get MERGE(){return new h(n.default.KEYWORD,i.default.MERGE)}isMerge(){return this._type===n.default.KEYWORD&&this._value===i.default.MERGE}static get CREATE(){return new h(n.default.KEYWORD,i.default.CREATE)}isCreate(){return this._type===n.default.KEYWORD&&this._value===i.default.CREATE}static get DELETE(){return new h(n.default.KEYWORD,i.default.DELETE)}isDelete(){return this._type===n.default.KEYWORD&&this._value===i.default.DELETE}static get SET(){return new h(n.default.KEYWORD,i.default.SET)}isSet(){return this._type===n.default.KEYWORD&&this._value===i.default.SET}static get REMOVE(){return new h(n.default.KEYWORD,i.default.REMOVE)}isRemove(){return this._type===n.default.KEYWORD&&this._value===i.default.REMOVE}static get CASE(){return new h(n.default.KEYWORD,i.default.CASE)}isCase(){return this._type===n.default.KEYWORD&&this._value===i.default.CASE}static get WHEN(){return new h(n.default.KEYWORD,i.default.WHEN)}isWhen(){return this._type===n.default.KEYWORD&&this._value===i.default.WHEN}static get THEN(){return new h(n.default.KEYWORD,i.default.THEN)}isThen(){return this._type===n.default.KEYWORD&&this._value===i.default.THEN}static get ELSE(){return new h(n.default.KEYWORD,i.default.ELSE)}isElse(){return this._type===n.default.KEYWORD&&this._value===i.default.ELSE}static get END(){return new h(n.default.KEYWORD,i.default.END)}isEnd(){return this._type===n.default.KEYWORD&&this._value===i.default.END}static get NULL(){return new h(n.default.KEYWORD,i.default.NULL)}isNull(){return this._type===n.default.KEYWORD&&this._value===i.default.NULL}static get IN(){return new h(n.default.KEYWORD,i.default.IN)}isIn(){return this._type===n.default.KEYWORD&&this._value===i.default.IN}static get PIPE(){return new h(n.default.KEYWORD,a.default.PIPE)}isPipe(){return this._type===n.default.KEYWORD&&this._value===a.default.PIPE}static get DISTINCT(){return new h(n.default.KEYWORD,i.default.DISTINCT)}isDistinct(){return this._type===n.default.KEYWORD&&this._value===i.default.DISTINCT}static get LIMIT(){return new h(n.default.KEYWORD,i.default.LIMIT)}isLimit(){return this._type===n.default.KEYWORD&&this._value===i.default.LIMIT}static get EOF(){return new h(n.default.EOF)}isEOF(){return this._type===n.default.EOF}isOperand(){return this.isNumber()||this.isString()||this.isNull()}isWhitespaceOrComment(){return this.isWhitespace()||this.isComment()}isSymbol(){return this._type===n.default.SYMBOL}static method(e){return h[e.toUpperCase()]}}t.default=h},299:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(7847)),i=r(s(8652));t.default=class{constructor(e){this._enum=e,this._trie=new i.default;for(const[t,s]of Object.entries(e)){const e=n.default.method(t);void 0!==e&&null!==e.value&&this._trie.insert(e)}}map(e){return this._trie.find(e)}get last_found(){return this._trie.last_found}}},8898:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.KEYWORD="KEYWORD",e.OPERATOR="OPERATOR",e.UNARY_OPERATOR="UNARY_OPERATOR",e.IDENTIFIER="IDENTIFIER",e.STRING="STRING",e.F_STRING="F-STRING",e.BACKTICK_STRING="BACKTICK_STRING",e.NUMBER="NUMBER",e.SYMBOL="SYMBOL",e.WHITESPACE="WHITESPACE",e.COMMENT="COMMENT",e.EOF="EOF"}(s||(s={})),t.default=s},3479:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(s(7825)),i=r(s(7847)),u=r(s(178)),a=r(s(6519)),l=r(s(4020)),o=r(s(2008)),h=r(s(299));t.default=class{constructor(e){this.keywords=new h.default(n.default),this.symbols=new h.default(l.default),this.operators=new h.default(o.default),this.walker=new u.default(e)}tokenize(){const e=[];let t=null;for(;!this.walker.isAtEnd;){e.push(...this.f_string()),t=this.getLastNonWhitespaceOrNonCommentToken(e)||t;const s=this.getNextToken(t);if(null===s)throw new Error(`Unrecognized token at position ${this.walker.position}`);s.position=this.walker.position,e.push(s)}return e}getLastNonWhitespaceOrNonCommentToken(e){return 0===e.length||e[e.length-1].isWhitespaceOrComment()?null:e[e.length-1]}getNextToken(e=null){return this.walker.isAtEnd?i.default.EOF:this.comment()||this.whitespace()||this.lookup(this.keywords)||this.lookup(this.operators,e,this.skipMinus)||this.identifier()||this.string()||this.number()||this.lookup(this.symbols)}comment(){const e=this.walker.position;if(this.walker.checkForSingleComment()||this.walker.checkForMultiLineComment()){const t=a.default.uncomment(this.walker.getString(e));return i.default.COMMENT(t)}return null}identifier(){const e=this.walker.position;if(this.walker.checkForUnderScore()||this.walker.checkForLetter()){for(;!this.walker.isAtEnd&&(this.walker.checkForLetter()||this.walker.checkForDigit()||this.walker.checkForUnderScore()););return i.default.IDENTIFIER(this.walker.getString(e))}return null}string(){const e=this.walker.position,t=this.walker.checkForQuote();if(null===t)return null;for(;!this.walker.isAtEnd;)if(this.walker.escaped(t))this.walker.moveNext(),this.walker.moveNext();else{if(this.walker.checkForString(t)){const s=this.walker.getString(e);return t===l.default.BACKTICK?i.default.BACKTICK_STRING(s,t):i.default.STRING(s,t)}this.walker.moveNext()}throw new Error(`Unterminated string at position ${e}`)}*f_string(){if(!this.walker.checkForFStringStart())return;this.walker.moveNext();let e=this.walker.position;const t=this.walker.checkForQuote();if(null!==t)for(;!this.walker.isAtEnd;)if(this.walker.escaped(t)||this.walker.escapedBrace())this.walker.moveNext(),this.walker.moveNext();else{if(this.walker.openingBrace())for(yield i.default.F_STRING(this.walker.getString(e),t),e=this.walker.position,yield i.default.OPENING_BRACE,this.walker.moveNext(),e=this.walker.position;!this.walker.isAtEnd&&!this.walker.closingBrace();){const t=this.getNextToken();if(null===t)break;if(yield t,this.walker.closingBrace()){yield i.default.CLOSING_BRACE,this.walker.moveNext(),e=this.walker.position;break}}if(this.walker.checkForString(t))return void(yield i.default.F_STRING(this.walker.getString(e),t));this.walker.moveNext()}}whitespace(){let e=!1;for(;!this.walker.isAtEnd&&this.walker.checkForWhitespace();)this.walker.moveNext(),e=!0;return e?i.default.WHITESPACE:null}number(){const e=this.walker.position;if(this.walker.checkForString("-")||this.walker.checkForDigit()){for(;!this.walker.isAtEnd&&this.walker.checkForDigit(););if(this.walker.checkForString(l.default.DOT))for(;!this.walker.isAtEnd&&this.walker.checkForDigit(););const t=this.walker.getString(e);return i.default.NUMBER(t)}return null}lookup(e,t=null,s){const r=e.map(this.walker.getRemainingString());return void 0!==r&&null!==r.value?r.can_be_identifier&&this.walker.word_continuation(r.value)||s&&t&&s(t,r)?null:(this.walker.moveBy(r.value.length),null!==e.last_found&&(r.case_sensitive_value=e.last_found),r):null}skipMinus(e,t){return null!==e&&!(!(e.isKeyword()||e.isComma()||e.isColon())||!t.isNegation())}}},8652:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class s{constructor(){this._children=new Map,this._token=void 0}map(e){return this._children.get(e)||this._children.set(e,new s).get(e)}retrieve(e){return this._children.get(e)}set token(e){this._token=e}get token(){return this._token}is_end_of_word(){return void 0!==this._token}no_children(){return 0===this._children.size}}t.default=class{constructor(){this._root=new s,this._max_length=0,this._last_found=null}insert(e){if(null===e.value||0===e.value.length)throw new Error("Token value cannot be null or empty");let t=this._root;for(const s of e.value)t=t.map(s.toLowerCase());e.value.length>this._max_length&&(this._max_length=e.value.length),t.token=e}find(e){if(0===e.length)return;let t,s,r=0;for(this._last_found=null;void 0!==(t=(t||this._root).retrieve(e[r].toLowerCase()))&&(t.is_end_of_word()&&(s=t.token,this._last_found=e.substring(0,r+1)),r++,!(r===e.length||r>this._max_length)););return(null==t?void 0:t.is_end_of_word())&&(s=t.token,this._last_found=e.substring(0,r)),s}get last_found(){return this._last_found}}},3001:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static isInstanceOfAny(e,t){return t.some((t=>e instanceof t))}}},6519:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class s{static unquote(e){if(0===e.length)return e;if(1===e.length&&s.quotes.includes(e))return"";const t=e[0],r=e[e.length-1];return s.quotes.includes(t)&&t===r?e.substring(1,e.length-1):s.quotes.includes(r)&&t!==r?e.substring(0,e.length-1):s.quotes.includes(t)&&t!==r?e.substring(1):e}static uncomment(e){return e.length<2?e:"/"===e[0]&&"/"===e[1]?e.substring(2):"/"===e[0]&&"*"===e[1]&&"*"===e[e.length-2]&&"/"===e[e.length-1]?e.substring(2,e.length-2):e}static removeEscapedQuotes(e,t){let s="";for(let r=0;r<e.length;r++)"\\"===e[r]&&e[r+1]===t&&r++,s+=e[r];return s}static removeEscapedBraces(e){let t="";for(let s=0;s<e.length;s++)("{"===e[s]&&"{"===e[s+1]||"}"===e[s]&&"}"===e[s+1])&&s++,t+=e[s];return t}static can_be_identifier(e){const t=e.toLowerCase();return 0!==t.length&&!(!s.letters.includes(t[0])&&"_"!==t[0])&&t.split("").every((e=>s.word_valid_chars.includes(e)))}}s.quotes=['"',"'","`"],s.letters="abcdefghijklmnopqrstuvwxyz",s.digits="0123456789",s.whitespace=" \t\n\r",s.word_valid_chars=s.letters+s.digits+"_",t.default=s}},t={},s=function s(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,s),i.exports}(610);return s.default})()));
@@ -0,0 +1,105 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <script src="flowquery.min.js"></script>
7
+ <title>FlowQuery</title>
8
+ <style>
9
+ body {
10
+ display: flex;
11
+ flex-direction: column;
12
+ align-items: center;
13
+ justify-content: center;
14
+ height: 100vh;
15
+ margin: 0; /* Prevent unexpected scroll issues */
16
+ padding: 0;
17
+ box-sizing: border-box;
18
+ }
19
+
20
+ #input {
21
+ margin-top: 5px;
22
+ width: 100%;
23
+ height: 300px;
24
+ font-family: monospace;
25
+ resize: none;
26
+ box-sizing: border-box; /* Include padding/border in width/height */
27
+ }
28
+
29
+ #output {
30
+ margin-top: 5px;
31
+ width: 100%;
32
+ flex-grow: 1;
33
+ overflow-y: auto;
34
+ font-family: monospace;
35
+ box-sizing: border-box;
36
+ max-height: calc(100vh - 300px - 5px); /* Prevent excessive growth */
37
+ }
38
+ </style>
39
+ <script>
40
+ function createTable(results) {
41
+ const table = document.createElement("table");
42
+
43
+ if (results.length === 0) return table;
44
+
45
+ const headerRow = document.createElement("tr");
46
+ Object.entries(results[0]).forEach(([key, _]) => {
47
+ const th = document.createElement("th");
48
+ th.style.textAlign = "left";
49
+ th.textContent = key;
50
+ headerRow.appendChild(th);
51
+ });
52
+
53
+ table.appendChild(headerRow);
54
+
55
+ results.forEach(row => {
56
+ const tr = document.createElement("tr");
57
+ Object.entries(row).forEach(([_, value]) => {
58
+ const td = document.createElement("td");
59
+ if (typeof value === "object" || Array.isArray(value)) {
60
+ td.textContent = JSON.stringify(value);
61
+ } else {
62
+ td.textContent = value;
63
+ }
64
+ tr.appendChild(td);
65
+ });
66
+ table.appendChild(tr);
67
+ });
68
+
69
+ return table;
70
+ }
71
+
72
+ function run() {
73
+ const input = document.getElementById("input").value;
74
+ const output = document.getElementById("output");
75
+ output.innerHTML = "";
76
+ try {
77
+ const flowquery = new FlowQuery(input);
78
+ flowquery.run().then(() => {
79
+ const table = createTable(flowquery.results);
80
+ output.appendChild(table);
81
+ }).catch(e => {
82
+ console.error(e);
83
+ output.innerHTML = e.message;
84
+ });
85
+ } catch (e) {
86
+ console.error(e);
87
+ output.innerHTML = e.message;
88
+ return;
89
+ }
90
+ }
91
+ </script>
92
+ </head>
93
+ <body>
94
+ <textarea
95
+ id="input"
96
+ rows="10"
97
+ placeholder="Type your FlowQuery statement here and press Shift+Enter to run it."
98
+ onkeydown="if (event.key === 'Enter' && event.shiftKey) {
99
+ run();
100
+ event.preventDefault();
101
+ }"
102
+ ></textarea>
103
+ <div id="output"></div>
104
+ </body>
105
+ </html>
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from '@vscode/test-cli';
2
+
3
+ export default defineConfig({
4
+ files: 'test/**/*.test.js',
5
+ });
@@ -0,0 +1,13 @@
1
+ .vscode/**
2
+ .vscode-test/**
3
+ test/**
4
+ demo/**
5
+ _vsix_extract/**
6
+ node_modules/**
7
+ .gitignore
8
+ .yarnrc
9
+ vsc-extension-quickstart.md
10
+ **/jsconfig.json
11
+ **/*.map
12
+ **/eslint.config.mjs
13
+ **/.vscode-test.*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,11 @@
1
+ # FlowQuery for VSCode
2
+
3
+ Run FlowQuery statements from within VSCode.
4
+
5
+ ### Howto?
6
+ 1. Open a .cql file and press shift+enter.
7
+ 2. Query results show up in a separate tab.
8
+
9
+ You can create a .env (key=value pairs) file in the same directory as your .cql files and refer to variables defined in the .env file from cql files, for example '$key'.
10
+
11
+ ![FlowQuery Demo](https://raw.githubusercontent.com/microsoft/FlowQuery/refs/heads/main/flowquery-vscode/demo/FlowQueryVSCodeDemo.gif).