@duckcodeailabs/dql-core 0.3.1 → 0.6.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 (42) hide show
  1. package/LICENSE +123 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/lineage/builder.d.ts +43 -0
  7. package/dist/lineage/builder.d.ts.map +1 -0
  8. package/dist/lineage/builder.js +192 -0
  9. package/dist/lineage/builder.js.map +1 -0
  10. package/dist/lineage/dependency-resolver.d.ts +44 -0
  11. package/dist/lineage/dependency-resolver.d.ts.map +1 -0
  12. package/dist/lineage/dependency-resolver.js +168 -0
  13. package/dist/lineage/dependency-resolver.js.map +1 -0
  14. package/dist/lineage/domain-lineage.d.ts +96 -0
  15. package/dist/lineage/domain-lineage.d.ts.map +1 -0
  16. package/dist/lineage/domain-lineage.js +140 -0
  17. package/dist/lineage/domain-lineage.js.map +1 -0
  18. package/dist/lineage/index.d.ts +6 -0
  19. package/dist/lineage/index.d.ts.map +1 -0
  20. package/dist/lineage/index.js +7 -0
  21. package/dist/lineage/index.js.map +1 -0
  22. package/dist/lineage/lineage-graph.d.ts +97 -0
  23. package/dist/lineage/lineage-graph.d.ts.map +1 -0
  24. package/dist/lineage/lineage-graph.js +198 -0
  25. package/dist/lineage/lineage-graph.js.map +1 -0
  26. package/dist/lineage/sql-parser.d.ts +23 -0
  27. package/dist/lineage/sql-parser.d.ts.map +1 -0
  28. package/dist/lineage/sql-parser.js +110 -0
  29. package/dist/lineage/sql-parser.js.map +1 -0
  30. package/dist/semantic/index.d.ts +1 -1
  31. package/dist/semantic/index.d.ts.map +1 -1
  32. package/dist/semantic/index.js +1 -1
  33. package/dist/semantic/index.js.map +1 -1
  34. package/dist/semantic/providers/index.d.ts +1 -1
  35. package/dist/semantic/providers/index.d.ts.map +1 -1
  36. package/dist/semantic/providers/index.js +1 -1
  37. package/dist/semantic/providers/index.js.map +1 -1
  38. package/dist/semantic/providers/registry.d.ts +7 -0
  39. package/dist/semantic/providers/registry.d.ts.map +1 -1
  40. package/dist/semantic/providers/registry.js +30 -0
  41. package/dist/semantic/providers/registry.js.map +1 -1
  42. package/package.json +8 -9
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Domain-specific lineage analysis — DQL's key differentiator.
3
+ *
4
+ * Tracks how data flows across business domains, creating "trust chains"
5
+ * where certified blocks serve as trust checkpoints. Enables impact analysis
6
+ * across domain boundaries.
7
+ */
8
+ import type { LineageGraph, LineageEdge } from './lineage-graph.js';
9
+ export interface TrustChainNode {
10
+ nodeId: string;
11
+ name: string;
12
+ domain?: string;
13
+ status?: string;
14
+ owner?: string;
15
+ /** Whether this node is a trust checkpoint (certified block) */
16
+ isTrustCheckpoint: boolean;
17
+ }
18
+ export interface TrustChain {
19
+ /** Ordered nodes from source to target */
20
+ nodes: TrustChainNode[];
21
+ /** Number of certified checkpoints in the chain */
22
+ certifiedCount: number;
23
+ /** Number of uncertified nodes (trust gaps) */
24
+ uncertifiedCount: number;
25
+ /** Trust score: certified / total (0.0 to 1.0) */
26
+ trustScore: number;
27
+ /** Domain boundaries crossed */
28
+ domainCrossings: Array<{
29
+ from: string;
30
+ to: string;
31
+ }>;
32
+ }
33
+ export interface DomainImpact {
34
+ /** Domain name */
35
+ domain: string;
36
+ /** Nodes in this domain that are affected */
37
+ affectedNodes: Array<{
38
+ id: string;
39
+ name: string;
40
+ status?: string;
41
+ }>;
42
+ /** Number of certified blocks affected */
43
+ certifiedBlocksAffected: number;
44
+ }
45
+ export interface ImpactAnalysis {
46
+ /** The source node being analyzed */
47
+ sourceNode: string;
48
+ /** Total downstream nodes affected */
49
+ totalAffected: number;
50
+ /** Breakdown by domain */
51
+ domainImpacts: DomainImpact[];
52
+ /** Cross-domain edges in the impact path */
53
+ domainCrossings: Array<{
54
+ from: string;
55
+ to: string;
56
+ edgeCount: number;
57
+ }>;
58
+ }
59
+ export interface DomainFlow {
60
+ /** Source domain */
61
+ from: string;
62
+ /** Target domain */
63
+ to: string;
64
+ /** Edges connecting these domains */
65
+ edges: LineageEdge[];
66
+ /** Nodes at the boundary (source side) */
67
+ sourceNodes: string[];
68
+ /** Nodes at the boundary (target side) */
69
+ targetNodes: string[];
70
+ }
71
+ /**
72
+ * Build a trust chain from a source node to a target node.
73
+ * Shows certification status at every step.
74
+ */
75
+ export declare function buildTrustChain(graph: LineageGraph, fromId: string, toId: string): TrustChain | null;
76
+ /**
77
+ * Analyze the impact of changing a node — which domains and blocks are affected downstream.
78
+ */
79
+ export declare function analyzeImpact(graph: LineageGraph, nodeId: string): ImpactAnalysis;
80
+ /**
81
+ * Detect all cross-domain data flows in the graph.
82
+ */
83
+ export declare function detectDomainFlows(graph: LineageGraph): DomainFlow[];
84
+ /**
85
+ * Get a trust overview for all blocks in a domain.
86
+ */
87
+ export declare function getDomainTrustOverview(graph: LineageGraph, domain: string): {
88
+ totalBlocks: number;
89
+ certified: number;
90
+ draft: number;
91
+ review: number;
92
+ deprecated: number;
93
+ pendingRecertification: number;
94
+ trustScore: number;
95
+ };
96
+ //# sourceMappingURL=domain-lineage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-lineage.d.ts","sourceRoot":"","sources":["../../src/lineage/domain-lineage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAe,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,0CAA0C;IAC1C,KAAK,EAAE,cAA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,MAAM,EACd,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,IAAI,CAuCnB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CA6CjF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,UAAU,EAAE,CAyBnE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,GACb;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB,CAmBA"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Domain-specific lineage analysis — DQL's key differentiator.
3
+ *
4
+ * Tracks how data flows across business domains, creating "trust chains"
5
+ * where certified blocks serve as trust checkpoints. Enables impact analysis
6
+ * across domain boundaries.
7
+ */
8
+ /**
9
+ * Build a trust chain from a source node to a target node.
10
+ * Shows certification status at every step.
11
+ */
12
+ export function buildTrustChain(graph, fromId, toId) {
13
+ const path = graph.pathBetween(fromId, toId);
14
+ if (path.length === 0)
15
+ return null;
16
+ const nodes = [];
17
+ const domainCrossings = [];
18
+ let prevDomain;
19
+ for (const nodeId of path) {
20
+ const node = graph.getNode(nodeId);
21
+ if (!node)
22
+ continue;
23
+ const isTrustCheckpoint = node.status === 'certified';
24
+ nodes.push({
25
+ nodeId: node.id,
26
+ name: node.name,
27
+ domain: node.domain,
28
+ status: node.status,
29
+ owner: node.owner,
30
+ isTrustCheckpoint,
31
+ });
32
+ if (prevDomain && node.domain && prevDomain !== node.domain) {
33
+ domainCrossings.push({ from: prevDomain, to: node.domain });
34
+ }
35
+ if (node.domain)
36
+ prevDomain = node.domain;
37
+ }
38
+ const certifiedCount = nodes.filter((n) => n.isTrustCheckpoint).length;
39
+ const total = nodes.length;
40
+ return {
41
+ nodes,
42
+ certifiedCount,
43
+ uncertifiedCount: total - certifiedCount,
44
+ trustScore: total > 0 ? certifiedCount / total : 0,
45
+ domainCrossings,
46
+ };
47
+ }
48
+ /**
49
+ * Analyze the impact of changing a node — which domains and blocks are affected downstream.
50
+ */
51
+ export function analyzeImpact(graph, nodeId) {
52
+ const descendants = graph.descendants(nodeId);
53
+ // Group by domain
54
+ const byDomain = new Map();
55
+ for (const node of descendants) {
56
+ const domain = node.domain ?? '(unassigned)';
57
+ const list = byDomain.get(domain) ?? [];
58
+ list.push(node);
59
+ byDomain.set(domain, list);
60
+ }
61
+ const domainImpacts = [];
62
+ for (const [domain, nodes] of byDomain) {
63
+ domainImpacts.push({
64
+ domain,
65
+ affectedNodes: nodes.map((n) => ({ id: n.id, name: n.name, status: n.status })),
66
+ certifiedBlocksAffected: nodes.filter((n) => n.status === 'certified').length,
67
+ });
68
+ }
69
+ // Find domain crossings in the impact zone
70
+ const descendantIds = new Set(descendants.map((n) => n.id));
71
+ descendantIds.add(nodeId);
72
+ const crossingMap = new Map();
73
+ const crossingEdges = [];
74
+ for (const edge of graph.getCrossDomainEdges()) {
75
+ if (descendantIds.has(edge.source) && descendantIds.has(edge.target)) {
76
+ const key = `${edge.sourceDomain}→${edge.targetDomain}`;
77
+ crossingMap.set(key, (crossingMap.get(key) ?? 0) + 1);
78
+ }
79
+ }
80
+ for (const [key, count] of crossingMap) {
81
+ const [from, to] = key.split('→');
82
+ crossingEdges.push({ from, to, edgeCount: count });
83
+ }
84
+ return {
85
+ sourceNode: nodeId,
86
+ totalAffected: descendants.length,
87
+ domainImpacts,
88
+ domainCrossings: crossingEdges,
89
+ };
90
+ }
91
+ /**
92
+ * Detect all cross-domain data flows in the graph.
93
+ */
94
+ export function detectDomainFlows(graph) {
95
+ const flowMap = new Map();
96
+ for (const edge of graph.getCrossDomainEdges()) {
97
+ if (!edge.sourceDomain || !edge.targetDomain)
98
+ continue;
99
+ const key = `${edge.sourceDomain}→${edge.targetDomain}`;
100
+ let flow = flowMap.get(key);
101
+ if (!flow) {
102
+ flow = {
103
+ from: edge.sourceDomain,
104
+ to: edge.targetDomain,
105
+ edges: [],
106
+ sourceNodes: [],
107
+ targetNodes: [],
108
+ };
109
+ flowMap.set(key, flow);
110
+ }
111
+ flow.edges.push(edge);
112
+ if (!flow.sourceNodes.includes(edge.source))
113
+ flow.sourceNodes.push(edge.source);
114
+ if (!flow.targetNodes.includes(edge.target))
115
+ flow.targetNodes.push(edge.target);
116
+ }
117
+ return [...flowMap.values()];
118
+ }
119
+ /**
120
+ * Get a trust overview for all blocks in a domain.
121
+ */
122
+ export function getDomainTrustOverview(graph, domain) {
123
+ const nodes = graph.getNodesByDomain(domain).filter((n) => n.type === 'block');
124
+ const total = nodes.length;
125
+ const certified = nodes.filter((n) => n.status === 'certified').length;
126
+ const draft = nodes.filter((n) => n.status === 'draft').length;
127
+ const review = nodes.filter((n) => n.status === 'review').length;
128
+ const deprecated = nodes.filter((n) => n.status === 'deprecated').length;
129
+ const pendingRecertification = nodes.filter((n) => n.status === 'pending_recertification').length;
130
+ return {
131
+ totalBlocks: total,
132
+ certified,
133
+ draft,
134
+ review,
135
+ deprecated,
136
+ pendingRecertification,
137
+ trustScore: total > 0 ? certified / total : 0,
138
+ };
139
+ }
140
+ //# sourceMappingURL=domain-lineage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-lineage.js","sourceRoot":"","sources":["../../src/lineage/domain-lineage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkEH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAmB,EACnB,MAAc,EACd,IAAY;IAEZ,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OA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KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM,CAAC;IAC/D,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;IACjE,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,MAAM,CAAC;IACzE,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,yBAAyB,CAAC,CAAC,MAAM,CAAC;IAElG,OAAO;QACL,WAAW,EAAE,KAAK;QAClB,SAAS;QACT,KAAK;QACL,MAAM;QACN,UAAU;QACV,sBAAsB;QACtB,UAAU,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { extractTablesFromSql, type SqlParseResult, } from './sql-parser.js';
2
+ export { resolveDependencies, getUpstream, getDownstream, type BlockDependencyInfo, type DependencyResolutionResult, } from './dependency-resolver.js';
3
+ export { LineageGraph, type LineageNode, type LineageEdge, type LineageNodeType, type LineageEdgeType, type LineageGraphJSON, } from './lineage-graph.js';
4
+ export { buildLineageGraph, type LineageBlockInput, type LineageMetricInput, type LineageDimensionInput, type LineageBuilderOptions, } from './builder.js';
5
+ export { buildTrustChain, analyzeImpact, detectDomainFlows, getDomainTrustOverview, type TrustChain, type TrustChainNode, type ImpactAnalysis, type DomainImpact, type DomainFlow, } from './domain-lineage.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lineage/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,7 @@
1
+ // Lineage analysis — SQL parsing, dependency resolution, graph building, and domain lineage
2
+ export { extractTablesFromSql, } from './sql-parser.js';
3
+ export { resolveDependencies, getUpstream, getDownstream, } from './dependency-resolver.js';
4
+ export { LineageGraph, } from './lineage-graph.js';
5
+ export { buildLineageGraph, } from './builder.js';
6
+ export { buildTrustChain, analyzeImpact, detectDomainFlows, getDomainTrustOverview, } from './domain-lineage.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lineage/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAE5F,OAAO,EACL,oBAAoB,GAErB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,GAGd,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,YAAY,GAMb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,iBAAiB,GAKlB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,sBAAsB,GAMvB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Multi-granularity lineage graph for DQL's answer layer.
3
+ *
4
+ * Tracks data flow from source tables through blocks, semantic metrics,
5
+ * domains, and charts — the full "trust chain" from raw data to rendered answer.
6
+ */
7
+ export type LineageNodeType = 'source_table' | 'block' | 'metric' | 'dimension' | 'domain' | 'chart';
8
+ export interface LineageNode {
9
+ /** Unique identifier (e.g., "block:revenue_by_segment", "metric:total_revenue") */
10
+ id: string;
11
+ type: LineageNodeType;
12
+ name: string;
13
+ /** Business domain this node belongs to */
14
+ domain?: string;
15
+ /** Certification status (for blocks) */
16
+ status?: 'draft' | 'review' | 'certified' | 'deprecated' | 'pending_recertification';
17
+ /** Owner of the block/metric */
18
+ owner?: string;
19
+ /** Additional metadata */
20
+ metadata?: Record<string, unknown>;
21
+ }
22
+ export type LineageEdgeType = 'reads_from' | 'feeds_into' | 'aggregates' | 'visualizes' | 'crosses_domain' | 'certified_by';
23
+ export interface LineageEdge {
24
+ source: string;
25
+ target: string;
26
+ type: LineageEdgeType;
27
+ /** For crosses_domain: source and target domain names */
28
+ sourceDomain?: string;
29
+ targetDomain?: string;
30
+ /** Additional metadata */
31
+ metadata?: Record<string, unknown>;
32
+ }
33
+ export interface LineageGraphJSON {
34
+ nodes: LineageNode[];
35
+ edges: LineageEdge[];
36
+ }
37
+ export declare class LineageGraph {
38
+ private nodes;
39
+ private edges;
40
+ /** Outgoing edges: source → edges */
41
+ private outgoing;
42
+ /** Incoming edges: target → edges */
43
+ private incoming;
44
+ /** Add a node to the graph. Updates if already exists. */
45
+ addNode(node: LineageNode): void;
46
+ /** Add an edge to the graph. Deduplicates by source+target+type. */
47
+ addEdge(edge: LineageEdge): void;
48
+ /** Get a node by ID. */
49
+ getNode(id: string): LineageNode | undefined;
50
+ /** Get all nodes. */
51
+ getAllNodes(): LineageNode[];
52
+ /** Get all edges. */
53
+ getAllEdges(): LineageEdge[];
54
+ /** Get nodes by type. */
55
+ getNodesByType(type: LineageNodeType): LineageNode[];
56
+ /** Get nodes by domain. */
57
+ getNodesByDomain(domain: string): LineageNode[];
58
+ /** Get all unique domains in the graph. */
59
+ getDomains(): string[];
60
+ /** Get outgoing edges from a node. */
61
+ getOutgoingEdges(nodeId: string): LineageEdge[];
62
+ /** Get incoming edges to a node. */
63
+ getIncomingEdges(nodeId: string): LineageEdge[];
64
+ /**
65
+ * Get all ancestors (upstream) of a node via BFS.
66
+ * Follows incoming edges backwards.
67
+ */
68
+ ancestors(nodeId: string): LineageNode[];
69
+ /**
70
+ * Get all descendants (downstream) of a node via BFS.
71
+ * Follows outgoing edges forward.
72
+ */
73
+ descendants(nodeId: string): LineageNode[];
74
+ /**
75
+ * Find the shortest path between two nodes (BFS).
76
+ * Returns node IDs in order, or empty array if no path exists.
77
+ */
78
+ pathBetween(fromId: string, toId: string): string[];
79
+ /**
80
+ * Extract a subgraph containing only nodes matching a filter and
81
+ * edges between those nodes.
82
+ */
83
+ subgraph(filter: (node: LineageNode) => boolean): LineageGraph;
84
+ /**
85
+ * Get edges that cross domain boundaries.
86
+ */
87
+ getCrossDomainEdges(): LineageEdge[];
88
+ /** Serialize the graph to JSON. */
89
+ toJSON(): LineageGraphJSON;
90
+ /** Deserialize a graph from JSON. */
91
+ static fromJSON(json: LineageGraphJSON): LineageGraph;
92
+ /** Number of nodes in the graph. */
93
+ get nodeCount(): number;
94
+ /** Number of edges in the graph. */
95
+ get edgeCount(): number;
96
+ }
97
+ //# sourceMappingURL=lineage-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-graph.d.ts","sourceRoot":"","sources":["../../src/lineage/lineage-graph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,eAAe,G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er.
3
+ *
4
+ * Tracks data flow from source tables through blocks, semantic metrics,
5
+ * domains, and charts — the full "trust chain" from raw data to rendered answer.
6
+ */
7
+ export class LineageGraph {
8
+ nodes = new Map();
9
+ edges = [];
10
+ /** Outgoing edges: source → edges */
11
+ outgoing = new Map();
12
+ /** Incoming edges: target → edges */
13
+ incoming = new Map();
14
+ /** Add a node to the graph. Updates if already exists. */
15
+ addNode(node) {
16
+ this.nodes.set(node.id, node);
17
+ if (!this.outgoing.has(node.id))
18
+ this.outgoing.set(node.id, []);
19
+ if (!this.incoming.has(node.id))
20
+ this.incoming.set(node.id, []);
21
+ }
22
+ /** Add an edge to the graph. Deduplicates by source+target+type. */
23
+ addEdge(edge) {
24
+ // Deduplicate: skip if an identical edge (same source, target, type) exists
25
+ const existing = this.outgoing.get(edge.source);
26
+ if (existing?.some((e) => e.target === edge.target && e.type === edge.type)) {
27
+ return;
28
+ }
29
+ this.edges.push(edge);
30
+ // Ensure adjacency lists exist even if nodes weren't added explicitly
31
+ if (!this.outgoing.has(edge.source))
32
+ this.outgoing.set(edge.source, []);
33
+ if (!this.incoming.has(edge.target))
34
+ this.incoming.set(edge.target, []);
35
+ this.outgoing.get(edge.source).push(edge);
36
+ this.incoming.get(edge.target).push(edge);
37
+ }
38
+ /** Get a node by ID. */
39
+ getNode(id) {
40
+ return this.nodes.get(id);
41
+ }
42
+ /** Get all nodes. */
43
+ getAllNodes() {
44
+ return [...this.nodes.values()];
45
+ }
46
+ /** Get all edges. */
47
+ getAllEdges() {
48
+ return [...this.edges];
49
+ }
50
+ /** Get nodes by type. */
51
+ getNodesByType(type) {
52
+ return [...this.nodes.values()].filter((n) => n.type === type);
53
+ }
54
+ /** Get nodes by domain. */
55
+ getNodesByDomain(domain) {
56
+ return [...this.nodes.values()].filter((n) => n.domain === domain);
57
+ }
58
+ /** Get all unique domains in the graph. */
59
+ getDomains() {
60
+ const domains = new Set();
61
+ for (const node of this.nodes.values()) {
62
+ if (node.domain)
63
+ domains.add(node.domain);
64
+ }
65
+ return [...domains];
66
+ }
67
+ /** Get outgoing edges from a node. */
68
+ getOutgoingEdges(nodeId) {
69
+ return this.outgoing.get(nodeId) ?? [];
70
+ }
71
+ /** Get incoming edges to a node. */
72
+ getIncomingEdges(nodeId) {
73
+ return this.incoming.get(nodeId) ?? [];
74
+ }
75
+ /**
76
+ * Get all ancestors (upstream) of a node via BFS.
77
+ * Follows incoming edges backwards.
78
+ */
79
+ ancestors(nodeId) {
80
+ const visited = new Set();
81
+ const queue = [nodeId];
82
+ while (queue.length > 0) {
83
+ const current = queue.shift();
84
+ for (const edge of this.incoming.get(current) ?? []) {
85
+ if (!visited.has(edge.source)) {
86
+ visited.add(edge.source);
87
+ queue.push(edge.source);
88
+ }
89
+ }
90
+ }
91
+ return [...visited].map((id) => this.nodes.get(id)).filter(Boolean);
92
+ }
93
+ /**
94
+ * Get all descendants (downstream) of a node via BFS.
95
+ * Follows outgoing edges forward.
96
+ */
97
+ descendants(nodeId) {
98
+ const visited = new Set();
99
+ const queue = [nodeId];
100
+ while (queue.length > 0) {
101
+ const current = queue.shift();
102
+ for (const edge of this.outgoing.get(current) ?? []) {
103
+ if (!visited.has(edge.target)) {
104
+ visited.add(edge.target);
105
+ queue.push(edge.target);
106
+ }
107
+ }
108
+ }
109
+ return [...visited].map((id) => this.nodes.get(id)).filter(Boolean);
110
+ }
111
+ /**
112
+ * Find the shortest path between two nodes (BFS).
113
+ * Returns node IDs in order, or empty array if no path exists.
114
+ */
115
+ pathBetween(fromId, toId) {
116
+ if (fromId === toId)
117
+ return [fromId];
118
+ if (!this.nodes.has(fromId) || !this.nodes.has(toId))
119
+ return [];
120
+ const visited = new Set([fromId]);
121
+ const parent = new Map();
122
+ const queue = [fromId];
123
+ while (queue.length > 0) {
124
+ const current = queue.shift();
125
+ for (const edge of this.outgoing.get(current) ?? []) {
126
+ if (!visited.has(edge.target)) {
127
+ visited.add(edge.target);
128
+ parent.set(edge.target, current);
129
+ if (edge.target === toId) {
130
+ // Reconstruct path
131
+ const path = [toId];
132
+ let node = toId;
133
+ while (parent.has(node)) {
134
+ node = parent.get(node);
135
+ path.unshift(node);
136
+ }
137
+ return path;
138
+ }
139
+ queue.push(edge.target);
140
+ }
141
+ }
142
+ }
143
+ return []; // No path found
144
+ }
145
+ /**
146
+ * Extract a subgraph containing only nodes matching a filter and
147
+ * edges between those nodes.
148
+ */
149
+ subgraph(filter) {
150
+ const sub = new LineageGraph();
151
+ const included = new Set();
152
+ for (const node of this.nodes.values()) {
153
+ if (filter(node)) {
154
+ sub.addNode(node);
155
+ included.add(node.id);
156
+ }
157
+ }
158
+ for (const edge of this.edges) {
159
+ if (included.has(edge.source) && included.has(edge.target)) {
160
+ sub.addEdge(edge);
161
+ }
162
+ }
163
+ return sub;
164
+ }
165
+ /**
166
+ * Get edges that cross domain boundaries.
167
+ */
168
+ getCrossDomainEdges() {
169
+ return this.edges.filter((e) => e.type === 'crosses_domain');
170
+ }
171
+ /** Serialize the graph to JSON. */
172
+ toJSON() {
173
+ return {
174
+ nodes: [...this.nodes.values()],
175
+ edges: [...this.edges],
176
+ };
177
+ }
178
+ /** Deserialize a graph from JSON. */
179
+ static fromJSON(json) {
180
+ const graph = new LineageGraph();
181
+ for (const node of json.nodes) {
182
+ graph.addNode(node);
183
+ }
184
+ for (const edge of json.edges) {
185
+ graph.addEdge(edge);
186
+ }
187
+ return graph;
188
+ }
189
+ /** Number of nodes in the graph. */
190
+ get nodeCount() {
191
+ return this.nodes.size;
192
+ }
193
+ /** Number of edges in the graph. */
194
+ get edgeCount() {
195
+ return this.edges.length;
196
+ }
197
+ }
198
+ //# sourceMappingURL=lineage-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-graph.js","sourceRoot":"","sources":["../../src/lineage/lineage-graph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuDH,MAAM,OAAO,YAAY;IACf,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IACvC,KAAK,GAAkB,EAAE,CA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AAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Lightweight SQL table extractor for lineage analysis.
3
+ *
4
+ * Extracts table references from SQL statements without a full AST parser.
5
+ * Handles FROM, JOIN, subqueries, and CTEs. Filters out CTE names so only
6
+ * external table dependencies are returned.
7
+ */
8
+ export interface SqlParseResult {
9
+ /** External table dependencies (CTEs excluded) */
10
+ tables: string[];
11
+ /** CTE names defined in this query */
12
+ ctes: string[];
13
+ /** ref() calls found in the SQL */
14
+ refs: string[];
15
+ }
16
+ /**
17
+ * Extract table references from a SQL string.
18
+ *
19
+ * Identifies tables in FROM and JOIN clauses, filters out CTE definitions,
20
+ * and detects ref("block_name") calls.
21
+ */
22
+ export declare function extractTablesFromSql(sql: string): SqlParseResult;
23
+ //# sourceMappingURL=sql-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-parser.d.ts","sourceRoot":"","sources":["../../src/lineage/sql-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,sCAAsC;IACtC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,mCAAmC;IACnC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAmDhE"}