flowquery 1.0.67 → 1.0.68

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 CHANGED
@@ -256,12 +256,24 @@ console.log(runner.metadata);
256
256
  #### Statement Info: Labels, Properties, and Source Lineage
257
257
 
258
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.
259
+ query touches — independent of execution. It captures:
260
+
261
+ - The node labels and relationship types referenced.
262
+ - The data sources backing the underlying virtual definitions.
263
+ - The node/relationship properties **consumed** by the query
264
+ `alias.prop` accesses anywhere in `MATCH`, `WHERE`, `WITH`, `RETURN`,
265
+ `ORDER BY`, or function arguments, plus inline pattern properties
266
+ like `(u:User {id: 'rick.o'})`.
267
+ - The properties **declared** by each virtual's `RETURN` clause via
268
+ `info.declared`, so you can validate that a query references only
269
+ declared properties.
270
+ - Literal values supplied for properties at the call site via
271
+ `info.nodes[Label].literal_values` — collected from inline pattern
272
+ properties and from equality / `IN` predicates such as
273
+ `WHERE u.id = 'rick.o'` or `WHERE u.id IN ['a', 'b']`.
274
+
275
+ This is useful for governance, lineage UIs, query-cost estimation, schema
276
+ validation, or routing decisions before the query runs.
265
277
 
266
278
  The same `StatementInfoCrawler` can also be used directly on any parsed
267
279
  AST without going through a `Runner`:
@@ -280,30 +292,48 @@ per-entity `nodes` and `relationships` maps:
280
292
  const runner = new FlowQuery(`
281
293
  CREATE VIRTUAL (:City) AS {
282
294
  LOAD JSON FROM "https://example.com/cities" AS c
283
- RETURN c.id AS id, c.name AS name
295
+ RETURN c.id AS id, c.name AS name, c.country AS country
284
296
  };
285
297
  CREATE VIRTUAL (:City)-[:FLIGHT]-(:City) AS {
286
298
  LOAD JSON FROM "https://example.com/flights" AS f
287
299
  RETURN f.left_id AS left_id, f.right_id AS right_id, f.airline AS airline
288
300
  };
289
- MATCH (a:City)-[r:FLIGHT]->(b:City)
301
+ MATCH (a:City {name: 'NYC'})-[r:FLIGHT]->(b:City)
302
+ WHERE b.country IN ['US', 'CA']
290
303
  RETURN a.name AS origin, b.name AS destination, r.airline AS airline
291
304
  `);
292
305
  const { info } = runner.metadata;
306
+
293
307
  console.log(info.nodes);
294
- // { City: { properties: ["name"], sources: ["https://example.com/cities"] } }
308
+ // {
309
+ // City: {
310
+ // properties: ["country", "name"],
311
+ // sources: ["https://example.com/cities"],
312
+ // literal_values: { country: ["US", "CA"], name: ["NYC"] }
313
+ // }
314
+ // }
295
315
  console.log(info.relationships);
296
- // { FLIGHT: { properties: ["airline"], sources: ["https://example.com/flights"] } }
316
+ // {
317
+ // FLIGHT: {
318
+ // properties: ["airline"],
319
+ // sources: ["https://example.com/flights"],
320
+ // literal_values: {}
321
+ // }
322
+ // }
323
+ console.log(info.declared.nodes.City);
324
+ // { properties: ["country", "id", "name"], sources: ["https://example.com/cities"] }
297
325
  console.log(info.sources);
298
326
  // ["https://example.com/cities", "https://example.com/flights"]
299
327
  ```
300
328
 
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.
329
+ `StatementInfo` resolves sources and declared schemas for **any** virtual
330
+ the query touches — both inline `CREATE VIRTUAL` clauses and
331
+ previously-registered virtuals reached via `MATCH` or `DELETE`. The flat
332
+ `node_labels`, `relationship_types`, `sources`, `node_properties`, and
333
+ `relationship_properties` fields stay in sync with the per-entity `nodes` /
334
+ `relationships` maps and are convenient for quick aggregate checks. Only
335
+ purely literal AST subtrees end up in `literal_values` — values that depend
336
+ on parameters, references, f-strings, or subqueries are skipped.
307
337
 
308
338
  ### WHERE Clause
309
339