Skip to content

Commit 7455f98

Browse files
committed
Docs
1 parent 3840734 commit 7455f98

35 files changed

+969
-2
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,4 +422,7 @@ dist/
422422
node_modules/
423423
.vscode/
424424
.env
425-
coaching_prototype.cql
425+
coaching_prototype.cql
426+
427+
# TypeDoc API documentation (generated)
428+
docs/api/

package-lock.json

Lines changed: 223 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"start": "ts-node src/index.ts",
88
"test": "jest",
99
"build": "webpack && copy dist\\flowquery.min.js web\\flowquery.min.js && copy dist\\flowquery.min.js docs\\flowquery.min.js && copy web\\index.html docs\\index.html",
10-
"main": "tsc & node dist/index.js"
10+
"main": "tsc & node dist/index.js",
11+
"docs": "typedoc --out docs/api src/index.ts"
1112
},
1213
"keywords": [],
1314
"author": "",
@@ -17,6 +18,7 @@
1718
"jest": "^29.7.0",
1819
"ts-jest": "^29.2.5",
1920
"ts-loader": "^9.5.1",
21+
"typedoc": "^0.28.14",
2022
"typescript": "^5.7.2",
2123
"webpack": "^5.97.1",
2224
"webpack-cli": "^6.0.1"

src/compute/runner.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
import Operation from "../parsing/operations/operation";
22
import Parser from "../parsing/parser";
33

4+
/**
5+
* Executes a FlowQuery statement and retrieves the results.
6+
*
7+
* The Runner class parses a FlowQuery statement into an AST and executes it,
8+
* managing the execution flow from the first operation to the final return statement.
9+
*
10+
* @example
11+
* ```typescript
12+
* const runner = new Runner("WITH x = 1 RETURN x");
13+
* await runner.run();
14+
* console.log(runner.results); // [{ x: 1 }]
15+
* ```
16+
*/
417
class Runner {
518
private first: Operation;
619
private last: Operation;
20+
21+
/**
22+
* Creates a new Runner instance and parses the FlowQuery statement.
23+
*
24+
* @param statement - The FlowQuery statement to execute
25+
* @throws {Error} If the statement is null, empty, or contains syntax errors
26+
*/
727
constructor(statement: string | null = null) {
828
if(statement === null || statement === "") {
929
throw new Error("Statement cannot be null or empty");
@@ -13,6 +33,13 @@ class Runner {
1333
this.first = ast.firstChild() as Operation;
1434
this.last = ast.lastChild() as Operation;
1535
}
36+
37+
/**
38+
* Executes the parsed FlowQuery statement.
39+
*
40+
* @returns A promise that resolves when execution completes
41+
* @throws {Error} If an error occurs during execution
42+
*/
1643
public async run(): Promise<void> {
1744
return new Promise<void>(async (resolve, reject) => {
1845
try {
@@ -24,6 +51,12 @@ class Runner {
2451
}
2552
});
2653
}
54+
55+
/**
56+
* Gets the results from the executed statement.
57+
*
58+
* @returns The results from the last operation (typically a RETURN statement)
59+
*/
2760
public get results(): any {
2861
return this.last.results;
2962
}

0 commit comments

Comments
 (0)