@duckcodeailabs/dql-core 0.3.2 → 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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lineage/builder.d.ts +43 -0
- package/dist/lineage/builder.d.ts.map +1 -0
- package/dist/lineage/builder.js +192 -0
- package/dist/lineage/builder.js.map +1 -0
- package/dist/lineage/dependency-resolver.d.ts +44 -0
- package/dist/lineage/dependency-resolver.d.ts.map +1 -0
- package/dist/lineage/dependency-resolver.js +168 -0
- package/dist/lineage/dependency-resolver.js.map +1 -0
- package/dist/lineage/domain-lineage.d.ts +96 -0
- package/dist/lineage/domain-lineage.d.ts.map +1 -0
- package/dist/lineage/domain-lineage.js +140 -0
- package/dist/lineage/domain-lineage.js.map +1 -0
- package/dist/lineage/index.d.ts +6 -0
- package/dist/lineage/index.d.ts.map +1 -0
- package/dist/lineage/index.js +7 -0
- package/dist/lineage/index.js.map +1 -0
- package/dist/lineage/lineage-graph.d.ts +97 -0
- package/dist/lineage/lineage-graph.d.ts.map +1 -0
- package/dist/lineage/lineage-graph.js +198 -0
- package/dist/lineage/lineage-graph.js.map +1 -0
- package/dist/lineage/sql-parser.d.ts +23 -0
- package/dist/lineage/sql-parser.d.ts.map +1 -0
- package/dist/lineage/sql-parser.js +110 -0
- package/dist/lineage/sql-parser.js.map +1 -0
- package/dist/semantic/index.d.ts +1 -1
- package/dist/semantic/index.d.ts.map +1 -1
- package/dist/semantic/index.js +1 -1
- package/dist/semantic/index.js.map +1 -1
- package/dist/semantic/providers/index.d.ts +1 -1
- package/dist/semantic/providers/index.d.ts.map +1 -1
- package/dist/semantic/providers/index.js +1 -1
- package/dist/semantic/providers/index.js.map +1 -1
- package/dist/semantic/providers/registry.d.ts +7 -0
- package/dist/semantic/providers/registry.d.ts.map +1 -1
- package/dist/semantic/providers/registry.js +30 -0
- package/dist/semantic/providers/registry.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,OAAO,IAAI,CAAC;IAEnC,MAAM,KAAK,GAAqB,EAAE,CAAC;IACnC,MAAM,eAAe,GAAwC,EAAE,CAAC;IAEhE,IAAI,UAA8B,CAAC;IAEnC,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI;YAAE,SAAS;QAEpB,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC;QACtD,KAAK,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,iBAAiB;SAClB,CAAC,CAAC;QAEH,IAAI,UAAU,IAAI,IAAI,CAAC,MAAM,IAAI,UAAU,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5D,eAAe,CAAC,IAAI,CAAC,EAAE,IA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C9C,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.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,oCAAoC;IACpC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,oCAAoC;IACpC,IAAI,SAAS,IAAI,MAAM,CAEtB;CACF"}
|
|
@@ -0,0 +1,198 @@
|
|
|
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 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,CAAC;IAClC,qCAAqC;IAC7B,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IACpD,qCAAqC;IAC7B,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEpD,0DAA0D;IAC1D,OAAO,CAAC,IAAiB;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,oEAAoE;IACpE,OAAO,CAAC,IAAiB;QACvB,4EAA4E;QAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,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AE,CAAC;YAC9B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oCAAoC;IACpC,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,oCAAoC;IACpC,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;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"}
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Extract table references from a SQL string.
|
|
10
|
+
*
|
|
11
|
+
* Identifies tables in FROM and JOIN clauses, filters out CTE definitions,
|
|
12
|
+
* and detects ref("block_name") calls.
|
|
13
|
+
*/
|
|
14
|
+
export function extractTablesFromSql(sql) {
|
|
15
|
+
const ctes = extractCteNames(sql);
|
|
16
|
+
// Strip comments first (refs inside comments should be ignored)
|
|
17
|
+
const noComments = stripComments(sql);
|
|
18
|
+
// Strip non-ref string literals, then extract refs from the result.
|
|
19
|
+
// This ensures ref("block") and ref('block') are preserved, but
|
|
20
|
+
// 'ref("fake")' (a string literal containing ref) is stripped.
|
|
21
|
+
const withoutStringLiterals = stripStringLiterals(noComments);
|
|
22
|
+
const refs = extractRefs(withoutStringLiterals);
|
|
23
|
+
// For table extraction, use the fully cleaned version
|
|
24
|
+
const cleaned = withoutStringLiterals;
|
|
25
|
+
const rawTables = new Set();
|
|
26
|
+
// FROM <table> — handles FROM table, FROM schema.table, FROM "table"
|
|
27
|
+
const fromPattern = /\bFROM\s+(?:LATERAL\s+)?([a-zA-Z_][a-zA-Z0-9_.]*|"[^"]+")/gi;
|
|
28
|
+
for (const match of cleaned.matchAll(fromPattern)) {
|
|
29
|
+
addTableRef(rawTables, match[1]);
|
|
30
|
+
}
|
|
31
|
+
// JOIN <table> — all join types
|
|
32
|
+
const joinPattern = /\bJOIN\s+(?:LATERAL\s+)?([a-zA-Z_][a-zA-Z0-9_.]*|"[^"]+")/gi;
|
|
33
|
+
for (const match of cleaned.matchAll(joinPattern)) {
|
|
34
|
+
addTableRef(rawTables, match[1]);
|
|
35
|
+
}
|
|
36
|
+
// INTO <table> (INSERT INTO, MERGE INTO)
|
|
37
|
+
const intoPattern = /\bINTO\s+([a-zA-Z_][a-zA-Z0-9_.]*|"[^"]+")/gi;
|
|
38
|
+
for (const match of cleaned.matchAll(intoPattern)) {
|
|
39
|
+
addTableRef(rawTables, match[1]);
|
|
40
|
+
}
|
|
41
|
+
// Filter out CTEs, SQL keywords that might match, and DuckDB functions
|
|
42
|
+
const sqlKeywords = new Set([
|
|
43
|
+
'select', 'where', 'group', 'order', 'having', 'limit', 'offset',
|
|
44
|
+
'union', 'except', 'intersect', 'values', 'set', 'lateral',
|
|
45
|
+
'unnest', 'generate_series', 'read_csv_auto', 'read_csv', 'read_parquet',
|
|
46
|
+
'read_json', 'read_json_auto', 'range', 'information_schema', 'ref',
|
|
47
|
+
]);
|
|
48
|
+
const cteNamesLower = new Set(ctes.map((c) => c.toLowerCase()));
|
|
49
|
+
const tables = [...rawTables].filter((t) => {
|
|
50
|
+
const lower = t.toLowerCase();
|
|
51
|
+
return !cteNamesLower.has(lower) && !sqlKeywords.has(lower);
|
|
52
|
+
});
|
|
53
|
+
return { tables, ctes, refs };
|
|
54
|
+
}
|
|
55
|
+
/** Extract CTE names from WITH ... AS (...) patterns */
|
|
56
|
+
function extractCteNames(sql) {
|
|
57
|
+
const ctes = [];
|
|
58
|
+
// Match WITH ... AS and recursive WITH
|
|
59
|
+
const withPattern = /\bWITH\s+(?:RECURSIVE\s+)?/gi;
|
|
60
|
+
const withMatch = withPattern.exec(sql);
|
|
61
|
+
if (!withMatch)
|
|
62
|
+
return ctes;
|
|
63
|
+
// From the WITH keyword, extract comma-separated CTE definitions
|
|
64
|
+
const afterWith = sql.slice(withMatch.index + withMatch[0].length);
|
|
65
|
+
const cteDefPattern = /([a-zA-Z_][a-zA-Z0-9_]*)\s+AS\s*\(/gi;
|
|
66
|
+
for (const match of afterWith.matchAll(cteDefPattern)) {
|
|
67
|
+
ctes.push(match[1]);
|
|
68
|
+
}
|
|
69
|
+
return ctes;
|
|
70
|
+
}
|
|
71
|
+
/** Extract ref("block_name") calls from SQL */
|
|
72
|
+
function extractRefs(sql) {
|
|
73
|
+
const refs = [];
|
|
74
|
+
const refPattern = /\bref\s*\(\s*["']([^"']+)["']\s*\)/gi;
|
|
75
|
+
for (const match of sql.matchAll(refPattern)) {
|
|
76
|
+
refs.push(match[1]);
|
|
77
|
+
}
|
|
78
|
+
return refs;
|
|
79
|
+
}
|
|
80
|
+
/** Strip comments only */
|
|
81
|
+
function stripComments(sql) {
|
|
82
|
+
return sql
|
|
83
|
+
.replace(/\/\*[\s\S]*?\*\//g, ' ')
|
|
84
|
+
.replace(/--[^\n]*/g, ' ');
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Strip single-quoted string literals, but preserve those inside ref() calls.
|
|
88
|
+
* This ensures ref('block_name') works, while 'ref("fake")' is stripped.
|
|
89
|
+
*/
|
|
90
|
+
function stripStringLiterals(sql) {
|
|
91
|
+
// First, temporarily protect ref() arguments by replacing them with placeholders
|
|
92
|
+
const refArgs = [];
|
|
93
|
+
const withPlaceholders = sql.replace(/\bref\s*\(\s*'([^']*)'\s*\)/gi, (_match, arg) => {
|
|
94
|
+
refArgs.push(arg);
|
|
95
|
+
return `ref("__REF_PLACEHOLDER_${refArgs.length - 1}__")`;
|
|
96
|
+
});
|
|
97
|
+
// Strip all remaining single-quoted strings
|
|
98
|
+
const stripped = withPlaceholders.replace(/'(?:[^'\\]|\\.)*'/g, "''");
|
|
99
|
+
// Restore ref() arguments
|
|
100
|
+
return stripped.replace(/ref\("__REF_PLACEHOLDER_(\d+)__"\)/g, (_match, idx) => `ref('${refArgs[parseInt(idx)]}')`);
|
|
101
|
+
}
|
|
102
|
+
/** Normalize and add a table reference */
|
|
103
|
+
function addTableRef(tables, ref) {
|
|
104
|
+
// Remove surrounding quotes
|
|
105
|
+
const cleaned = ref.replace(/^"|"$/g, '');
|
|
106
|
+
if (cleaned.length > 0) {
|
|
107
|
+
tables.add(cleaned);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=sql-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-parser.js","sourceRoot":"","sources":["../../src/lineage/sql-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAElC,gEAAgE;IAChE,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAEtC,oEAAoE;IACpE,gEAAgE;IAChE,+DAA+D;IAC/D,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAEhD,sDAAsD;IACtD,MAAM,OAAO,GAAG,qBAAqB,CAAC;IAEtC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAEpC,qEAAqE;IACrE,MAAM,WAAW,GAAG,6DAA6D,CAAC;IAClF,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAClD,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,gCAAgC;IAChC,MAAM,WAAW,GAAG,6DAA6D,CAAC;IAClF,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;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,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,0BAA0B,OAAO,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC;IAC5D,CAAC,CACF,CAAC;IACF,4CAA4C;IAC5C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IACtE,0BAA0B;IAC1B,OAAO,QAAQ,CAAC,OAAO,CACrB,qCAAqC,EACrC,CAAC,MAAM,EAAE,GAAW,EAAE,EAAE,CAAC,QAAQ,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAC5D,CAAC;AACJ,CAAC;AAED,0CAA0C;AAC1C,SAAS,WAAW,CAAC,MAAmB,EAAE,GAAW;IACnD,4BAA4B;IAC5B,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
package/dist/semantic/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { SemanticAnalyzer, analyze } from './analyzer.js';
|
|
|
2
2
|
export { SemanticLayer, parseMetricDefinition, parseDimensionDefinition, parseHierarchyDefinition, parseBlockCompanionDefinition, parseCubeDefinition, } from './semantic-layer.js';
|
|
3
3
|
export type { MetricDefinition, DimensionDefinition, HierarchyDefinition, BlockCompanionDefinition, HierarchyLevelDefinition, HierarchyDrillPathDefinition, HierarchyRollupType, SemanticLayerConfig, JoinDefinition, TimeDimensionDefinition, CubeDefinition, ComposeQueryOptions, ComposeQueryResult, } from './semantic-layer.js';
|
|
4
4
|
export { loadSemanticLayerFromDir, loadSemanticLayerFromConfig, } from './yaml-loader.js';
|
|
5
|
-
export { resolveSemanticLayer, resolveSemanticLayerWithDiagnostics, pullCachedRepo, resolveRepoSource } from './providers/index.js';
|
|
5
|
+
export { resolveSemanticLayer, resolveSemanticLayerWithDiagnostics, resolveSemanticLayerAsync, pullCachedRepo, resolveRepoSource } from './providers/index.js';
|
|
6
6
|
export type { SemanticLayerProviderConfig, SemanticLayerResult, RepoResolveResult } from './providers/index.js';
|
|
7
7
|
export { SnowflakeSemanticProvider } from './providers/index.js';
|
|
8
8
|
export type { SnowflakeQueryExecutor, SnowflakeQueryResult } from './providers/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,mCAAmC,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,gBAAgB,EAChB,mBAA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