rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
58 lines • 1.85 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataFlowEdgeCollection = exports.DataFlowConnection = void 0;
/**
* Represents a connection between nodes in the data flow
*/
class DataFlowConnection {
constructor(from, to, label) {
this.from = from;
this.to = to;
this.label = label;
}
getMermaidRepresentation() {
const arrow = this.label ? ` -->|${this.label}| ` : ' --> ';
return `${this.from}${arrow}${this.to}`;
}
static create(from, to, label) {
return new DataFlowConnection(from, to, label);
}
static createWithNullability(from, to, isNullable) {
const label = isNullable ? 'NULLABLE' : 'NOT NULL';
return new DataFlowConnection(from, to, label);
}
}
exports.DataFlowConnection = DataFlowConnection;
/**
* Collection of edges with utilities for managing connections
*/
class DataFlowEdgeCollection {
constructor() {
this.edges = [];
this.connectionSet = new Set();
}
add(edge) {
const key = `${edge.from}->${edge.to}`;
if (!this.connectionSet.has(key)) {
this.edges.push(edge);
this.connectionSet.add(key);
}
}
addConnection(from, to, label) {
this.add(DataFlowConnection.create(from, to, label));
}
addJoinConnection(from, to, isNullable) {
this.add(DataFlowConnection.createWithNullability(from, to, isNullable));
}
hasConnection(from, to) {
return this.connectionSet.has(`${from}->${to}`);
}
getAll() {
return [...this.edges];
}
getMermaidRepresentation() {
return this.edges.map(edge => edge.getMermaidRepresentation()).join('\n ');
}
}
exports.DataFlowEdgeCollection = DataFlowEdgeCollection;
//# sourceMappingURL=DataFlowEdge.js.map
;