flowquery 1.0.65 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -1
- package/dist/compute/runner.d.ts +17 -2
- package/dist/compute/runner.d.ts.map +1 -1
- package/dist/compute/runner.js +15 -3
- package/dist/compute/runner.js.map +1 -1
- package/dist/flowquery.min.js +1 -1
- package/dist/graph/node.d.ts.map +1 -1
- package/dist/graph/node.js +8 -1
- package/dist/graph/node.js.map +1 -1
- package/dist/graph/physical_node.d.ts.map +1 -1
- package/dist/graph/physical_node.js +5 -2
- package/dist/graph/physical_node.js.map +1 -1
- package/dist/graph/physical_relationship.d.ts.map +1 -1
- package/dist/graph/physical_relationship.js +5 -2
- package/dist/graph/physical_relationship.js.map +1 -1
- package/dist/index.browser.d.ts +2 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.d.ts +2 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js.map +1 -1
- package/dist/parsing/functions/function_factory.d.ts +1 -0
- package/dist/parsing/functions/function_factory.d.ts.map +1 -1
- package/dist/parsing/functions/function_factory.js +1 -0
- package/dist/parsing/functions/function_factory.js.map +1 -1
- package/dist/parsing/functions/length.d.ts +7 -0
- package/dist/parsing/functions/length.d.ts.map +1 -0
- package/dist/parsing/functions/length.js +65 -0
- package/dist/parsing/functions/length.js.map +1 -0
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +8 -2
- package/dist/parsing/parser.js.map +1 -1
- package/dist/parsing/statement_info_crawler.d.ts +118 -0
- package/dist/parsing/statement_info_crawler.d.ts.map +1 -0
- package/dist/parsing/statement_info_crawler.js +377 -0
- package/dist/parsing/statement_info_crawler.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -249,9 +249,62 @@ const runner = new FlowQuery("CREATE VIRTUAL (:X) AS { RETURN 1 AS id }; MATCH (
|
|
|
249
249
|
await runner.run();
|
|
250
250
|
console.log(runner.metadata);
|
|
251
251
|
// { virtual_nodes_created: 1, virtual_relationships_created: 0,
|
|
252
|
-
// virtual_nodes_deleted: 0, virtual_relationships_deleted: 0
|
|
252
|
+
// virtual_nodes_deleted: 0, virtual_relationships_deleted: 0,
|
|
253
|
+
// info: { node_labels: ["X"], relationship_types: [], sources: [], ... } }
|
|
253
254
|
```
|
|
254
255
|
|
|
256
|
+
#### Statement Info: Labels, Properties, and Source Lineage
|
|
257
|
+
|
|
258
|
+
`metadata.info` carries a `StatementInfo` describing the _structure_ the
|
|
259
|
+
query touches — independent of execution. It captures the node labels and
|
|
260
|
+
relationship types referenced, the data sources backing the underlying
|
|
261
|
+
virtual definitions, and the node/relationship properties accessed by the
|
|
262
|
+
query (i.e. `n.name`, not the columns produced by the virtual definition's
|
|
263
|
+
inner sub-query). This is useful for governance, lineage UIs, query-cost
|
|
264
|
+
estimation, or routing decisions before the query runs.
|
|
265
|
+
|
|
266
|
+
The same `StatementInfoCrawler` can also be used directly on any parsed
|
|
267
|
+
AST without going through a `Runner`:
|
|
268
|
+
|
|
269
|
+
```javascript
|
|
270
|
+
import { StatementInfoCrawler } from "flowquery";
|
|
271
|
+
|
|
272
|
+
const crawler = new StatementInfoCrawler();
|
|
273
|
+
const info = crawler.crawl(parsedAst);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
For end-to-end lineage from a property to its data source, use the
|
|
277
|
+
per-entity `nodes` and `relationships` maps:
|
|
278
|
+
|
|
279
|
+
```javascript
|
|
280
|
+
const runner = new FlowQuery(`
|
|
281
|
+
CREATE VIRTUAL (:City) AS {
|
|
282
|
+
LOAD JSON FROM "https://example.com/cities" AS c
|
|
283
|
+
RETURN c.id AS id, c.name AS name
|
|
284
|
+
};
|
|
285
|
+
CREATE VIRTUAL (:City)-[:FLIGHT]-(:City) AS {
|
|
286
|
+
LOAD JSON FROM "https://example.com/flights" AS f
|
|
287
|
+
RETURN f.left_id AS left_id, f.right_id AS right_id, f.airline AS airline
|
|
288
|
+
};
|
|
289
|
+
MATCH (a:City)-[r:FLIGHT]->(b:City)
|
|
290
|
+
RETURN a.name AS origin, b.name AS destination, r.airline AS airline
|
|
291
|
+
`);
|
|
292
|
+
const { info } = runner.metadata;
|
|
293
|
+
console.log(info.nodes);
|
|
294
|
+
// { City: { properties: ["name"], sources: ["https://example.com/cities"] } }
|
|
295
|
+
console.log(info.relationships);
|
|
296
|
+
// { FLIGHT: { properties: ["airline"], sources: ["https://example.com/flights"] } }
|
|
297
|
+
console.log(info.sources);
|
|
298
|
+
// ["https://example.com/cities", "https://example.com/flights"]
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
`StatementInfo` resolves sources for **any** virtual the query touches — both
|
|
302
|
+
inline `CREATE VIRTUAL` clauses and previously-registered virtuals reached
|
|
303
|
+
via `MATCH` or `DELETE`. The flat `node_labels`, `relationship_types`,
|
|
304
|
+
`sources`, `node_properties`, and `relationship_properties` fields stay in
|
|
305
|
+
sync with the per-entity `nodes` / `relationships` maps and are convenient
|
|
306
|
+
for quick aggregate checks.
|
|
307
|
+
|
|
255
308
|
### WHERE Clause
|
|
256
309
|
|
|
257
310
|
Filters rows based on conditions. Supports the following operators:
|
package/dist/compute/runner.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import ASTNode from "../parsing/ast_node";
|
|
2
|
+
import { StatementInfo } from "../parsing/statement_info_crawler";
|
|
3
|
+
export type { StatementInfo } from "../parsing/statement_info_crawler";
|
|
2
4
|
/**
|
|
3
5
|
* Metadata about the operations performed by a Runner execution.
|
|
6
|
+
*
|
|
7
|
+
* The four counters track CREATE/DELETE VIRTUAL operations. The optional
|
|
8
|
+
* `info` field carries deeper structural information about the statement(s)
|
|
9
|
+
* — labels, relationship types, sources, and properties — produced by
|
|
10
|
+
* {@link StatementInfoCrawler}.
|
|
4
11
|
*/
|
|
5
12
|
export interface RunnerMetadata {
|
|
6
13
|
virtual_nodes_created: number;
|
|
7
14
|
virtual_relationships_created: number;
|
|
8
15
|
virtual_nodes_deleted: number;
|
|
9
16
|
virtual_relationships_deleted: number;
|
|
17
|
+
/**
|
|
18
|
+
* Optional structural info produced by walking the parsed statement(s).
|
|
19
|
+
* Populated by the Runner whenever metadata is requested.
|
|
20
|
+
*/
|
|
21
|
+
info?: StatementInfo;
|
|
10
22
|
}
|
|
11
23
|
/**
|
|
12
24
|
* Executes a FlowQuery statement and retrieves the results.
|
|
@@ -42,7 +54,9 @@ declare class Runner {
|
|
|
42
54
|
constructor(statement?: string | null, ast?: ASTNode | null, args?: Record<string, any> | null);
|
|
43
55
|
private static toStatement;
|
|
44
56
|
/**
|
|
45
|
-
* Walks all statement ASTs to count CREATE/DELETE operations
|
|
57
|
+
* Walks all statement ASTs to count CREATE/DELETE operations and to
|
|
58
|
+
* crawl the statements for richer structural info via
|
|
59
|
+
* {@link StatementInfoCrawler}.
|
|
46
60
|
*/
|
|
47
61
|
private computeMetadata;
|
|
48
62
|
/**
|
|
@@ -68,7 +82,8 @@ declare class Runner {
|
|
|
68
82
|
/**
|
|
69
83
|
* Gets metadata about the operations in this query.
|
|
70
84
|
*
|
|
71
|
-
*
|
|
85
|
+
* Returns a deep copy so callers can mutate the result without affecting
|
|
86
|
+
* subsequent reads.
|
|
72
87
|
*/
|
|
73
88
|
get metadata(): RunnerMetadata;
|
|
74
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/compute/runner.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/compute/runner.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAQ1C,OAA6B,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAExF,YAAY,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6BAA6B,EAAE,MAAM,CAAC;IACtC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6BAA6B,EAAE,MAAM,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;CACxB;AAQD;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,MAAM;IACR,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,SAAS,CAAiB;IAElC;;;;;;;OAOG;gBAEC,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,GAAG,GAAE,OAAO,GAAG,IAAW,EAC1B,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAW;IAqB3C,OAAO,CAAC,MAAM,CAAC,WAAW;IAQ1B;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAqBvB;;;;;OAKG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBjC;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAetB;;;;OAIG;IACH,IAAW,OAAO,IAAI,GAAG,CAExB;IAED;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,cAAc,CASpC;CACJ;AAED,eAAe,MAAM,CAAC"}
|
package/dist/compute/runner.js
CHANGED
|
@@ -20,6 +20,7 @@ const create_relationship_1 = __importDefault(require("../parsing/operations/cre
|
|
|
20
20
|
const delete_node_1 = __importDefault(require("../parsing/operations/delete_node"));
|
|
21
21
|
const delete_relationship_1 = __importDefault(require("../parsing/operations/delete_relationship"));
|
|
22
22
|
const parser_1 = __importDefault(require("../parsing/parser"));
|
|
23
|
+
const statement_info_crawler_1 = __importDefault(require("../parsing/statement_info_crawler"));
|
|
23
24
|
/**
|
|
24
25
|
* Executes a FlowQuery statement and retrieves the results.
|
|
25
26
|
*
|
|
@@ -71,7 +72,9 @@ class Runner {
|
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
|
-
* Walks all statement ASTs to count CREATE/DELETE operations
|
|
75
|
+
* Walks all statement ASTs to count CREATE/DELETE operations and to
|
|
76
|
+
* crawl the statements for richer structural info via
|
|
77
|
+
* {@link StatementInfoCrawler}.
|
|
75
78
|
*/
|
|
76
79
|
computeMetadata() {
|
|
77
80
|
const metadata = {
|
|
@@ -94,6 +97,7 @@ class Runner {
|
|
|
94
97
|
op = op.next;
|
|
95
98
|
}
|
|
96
99
|
}
|
|
100
|
+
metadata.info = new statement_info_crawler_1.default().crawl(this._statements.map((s) => s.ast));
|
|
97
101
|
return metadata;
|
|
98
102
|
}
|
|
99
103
|
/**
|
|
@@ -156,10 +160,18 @@ class Runner {
|
|
|
156
160
|
/**
|
|
157
161
|
* Gets metadata about the operations in this query.
|
|
158
162
|
*
|
|
159
|
-
*
|
|
163
|
+
* Returns a deep copy so callers can mutate the result without affecting
|
|
164
|
+
* subsequent reads.
|
|
160
165
|
*/
|
|
161
166
|
get metadata() {
|
|
162
|
-
|
|
167
|
+
const m = this._metadata;
|
|
168
|
+
return {
|
|
169
|
+
virtual_nodes_created: m.virtual_nodes_created,
|
|
170
|
+
virtual_relationships_created: m.virtual_relationships_created,
|
|
171
|
+
virtual_nodes_deleted: m.virtual_nodes_deleted,
|
|
172
|
+
virtual_relationships_deleted: m.virtual_relationships_deleted,
|
|
173
|
+
info: m.info ? statement_info_crawler_1.default.clone(m.info) : undefined,
|
|
174
|
+
};
|
|
163
175
|
}
|
|
164
176
|
}
|
|
165
177
|
exports.default = Runner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/compute/runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qEAA4C;AAC5C,2EAAkD;AAElD,qGAA4E;AAC5E,oFAA2D;AAC3D,oGAA2E;AAC3E,oFAA2D;AAC3D,oG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