dbgraph 0.1.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/LICENSE +21 -0
- package/README.md +347 -0
- package/dist/bin/dbgraph.d.ts +8 -0
- package/dist/bin/dbgraph.d.ts.map +1 -0
- package/dist/bin/dbgraph.js +382 -0
- package/dist/bin/dbgraph.js.map +1 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +158 -0
- package/dist/config.js.map +1 -0
- package/dist/context/formatter.d.ts +94 -0
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +288 -0
- package/dist/context/formatter.js.map +1 -0
- package/dist/context/index.d.ts +77 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +458 -0
- package/dist/context/index.js.map +1 -0
- package/dist/db/index.d.ts +26 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +127 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +8 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +39 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/queries.d.ts +46 -0
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +436 -0
- package/dist/db/queries.js.map +1 -0
- package/dist/db/schema.sql +113 -0
- package/dist/db/sqlite-adapter.d.ts +30 -0
- package/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/db/sqlite-adapter.js +78 -0
- package/dist/db/sqlite-adapter.js.map +1 -0
- package/dist/directory.d.ts +37 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +160 -0
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +46 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +90 -0
- package/dist/errors.js.map +1 -0
- package/dist/graph/traversal.d.ts +157 -0
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +531 -0
- package/dist/graph/traversal.js.map +1 -0
- package/dist/index.d.ts +183 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +435 -0
- package/dist/index.js.map +1 -0
- package/dist/introspect/base.d.ts +62 -0
- package/dist/introspect/base.d.ts.map +1 -0
- package/dist/introspect/base.js +107 -0
- package/dist/introspect/base.js.map +1 -0
- package/dist/introspect/connection.d.ts +30 -0
- package/dist/introspect/connection.d.ts.map +1 -0
- package/dist/introspect/connection.js +232 -0
- package/dist/introspect/connection.js.map +1 -0
- package/dist/introspect/index.d.ts +23 -0
- package/dist/introspect/index.d.ts.map +1 -0
- package/dist/introspect/index.js +46 -0
- package/dist/introspect/index.js.map +1 -0
- package/dist/introspect/mysql.d.ts +64 -0
- package/dist/introspect/mysql.d.ts.map +1 -0
- package/dist/introspect/mysql.js +360 -0
- package/dist/introspect/mysql.js.map +1 -0
- package/dist/introspect/postgres.d.ts +55 -0
- package/dist/introspect/postgres.d.ts.map +1 -0
- package/dist/introspect/postgres.js +372 -0
- package/dist/introspect/postgres.js.map +1 -0
- package/dist/introspect/sqlite.d.ts +33 -0
- package/dist/introspect/sqlite.d.ts.map +1 -0
- package/dist/introspect/sqlite.js +207 -0
- package/dist/introspect/sqlite.js.map +1 -0
- package/dist/mcp/engine.d.ts +92 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +261 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +33 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +119 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +9 -0
- package/dist/mcp/server-instructions.d.ts.map +1 -0
- package/dist/mcp/server-instructions.js +71 -0
- package/dist/mcp/server-instructions.js.map +1 -0
- package/dist/mcp/session.d.ts +35 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +140 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +99 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +499 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/transport.d.ts +78 -0
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +182 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/search/query-parser.d.ts +66 -0
- package/dist/search/query-parser.d.ts.map +1 -0
- package/dist/search/query-parser.js +163 -0
- package/dist/search/query-parser.js.map +1 -0
- package/dist/search/query-utils.d.ts +78 -0
- package/dist/search/query-utils.d.ts.map +1 -0
- package/dist/search/query-utils.js +203 -0
- package/dist/search/query-utils.js.map +1 -0
- package/dist/types.d.ts +279 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +47 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +40 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +190 -0
- package/dist/utils.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Query Utilities
|
|
4
|
+
*
|
|
5
|
+
* Scoring and relevance helpers for search results. These functions provide
|
|
6
|
+
* small numeric boosts that can be composed with FTS5 scores to improve
|
|
7
|
+
* result ranking for database schema objects.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.kindBonus = kindBonus;
|
|
11
|
+
exports.scorePathRelevance = scorePathRelevance;
|
|
12
|
+
exports.nameMatchBonus = nameMatchBonus;
|
|
13
|
+
exports.computeAugmentedScore = computeAugmentedScore;
|
|
14
|
+
exports.rerankResults = rerankResults;
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Constants
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Base relevance bonus applied by kindBonus().
|
|
20
|
+
* Tables, views, and columns rank highest since they're the most
|
|
21
|
+
* commonly sought schema objects.
|
|
22
|
+
*/
|
|
23
|
+
const KIND_BONUSES = {
|
|
24
|
+
table: 0.15,
|
|
25
|
+
view: 0.15,
|
|
26
|
+
column: 0.12,
|
|
27
|
+
foreign_key: 0.10,
|
|
28
|
+
index: 0.08,
|
|
29
|
+
constraint: 0.08,
|
|
30
|
+
trigger: 0.06,
|
|
31
|
+
stored_procedure: 0.06,
|
|
32
|
+
function: 0.06,
|
|
33
|
+
sequence: 0.05,
|
|
34
|
+
schema: 0.04,
|
|
35
|
+
database: 0.03,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Default bonus for unrecognized or low-value kinds.
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_KIND_BONUS = 0.02;
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// kindBonus
|
|
43
|
+
// =============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* Boost score for certain node kinds.
|
|
46
|
+
*
|
|
47
|
+
* Tables and views get the highest boost (0.15), columns are next (0.12),
|
|
48
|
+
* indexes and constraints get a moderate boost (0.08), and utility objects
|
|
49
|
+
* like triggers / functions / sequences get a smaller boost (0.05–0.06).
|
|
50
|
+
* Schema and database container nodes get a minimal boost (0.03–0.04).
|
|
51
|
+
*
|
|
52
|
+
* @param kind - The node kind string (e.g., "table", "column", "index").
|
|
53
|
+
* @returns A bonus value in [0.02, 0.15] to add to the base score.
|
|
54
|
+
*/
|
|
55
|
+
function kindBonus(kind) {
|
|
56
|
+
return KIND_BONUSES[kind.toLowerCase()] ?? DEFAULT_KIND_BONUS;
|
|
57
|
+
}
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// scorePathRelevance
|
|
60
|
+
// =============================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Boost score when the query matches part of the node's source path.
|
|
63
|
+
*
|
|
64
|
+
* The filePath field (stored as `source` in graph terminology) is a URI
|
|
65
|
+
* like `db://@prod/public` or `db://host:5432/dbname/schema`. When a
|
|
66
|
+
* query token matches part of this path, it indicates the user is
|
|
67
|
+
* narrowing their search to a specific database or schema.
|
|
68
|
+
*
|
|
69
|
+
* Matching logic:
|
|
70
|
+
* - Exact match of any path segment → 0.10 boost.
|
|
71
|
+
* - Prefix match of any path segment → 0.05 boost.
|
|
72
|
+
* - Substring match anywhere in path → 0.02 boost.
|
|
73
|
+
* - No match → 0.
|
|
74
|
+
*
|
|
75
|
+
* @param filePath - The node's source path (Node.filePath).
|
|
76
|
+
* @param query - The raw search query text.
|
|
77
|
+
* @returns A bonus value in [0, 0.10].
|
|
78
|
+
*/
|
|
79
|
+
function scorePathRelevance(filePath, query) {
|
|
80
|
+
if (!filePath || !query)
|
|
81
|
+
return 0;
|
|
82
|
+
const lowerPath = filePath.toLowerCase();
|
|
83
|
+
const tokens = query
|
|
84
|
+
.toLowerCase()
|
|
85
|
+
.split(/\s+/)
|
|
86
|
+
.filter((t) => t.length > 0);
|
|
87
|
+
if (tokens.length === 0)
|
|
88
|
+
return 0;
|
|
89
|
+
// Split the path into segments by / : @ .
|
|
90
|
+
const segments = lowerPath.split(/[/:@.#]+/).filter((s) => s.length > 0);
|
|
91
|
+
let best = 0;
|
|
92
|
+
for (const token of tokens) {
|
|
93
|
+
// Skip very short tokens to avoid noise
|
|
94
|
+
if (token.length < 2)
|
|
95
|
+
continue;
|
|
96
|
+
// Exact match against any segment
|
|
97
|
+
if (segments.some((seg) => seg === token)) {
|
|
98
|
+
best = Math.max(best, 0.10);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
// Prefix match against any segment
|
|
102
|
+
if (segments.some((seg) => seg.startsWith(token))) {
|
|
103
|
+
best = Math.max(best, 0.05);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// Substring match anywhere in the path
|
|
107
|
+
if (lowerPath.includes(token)) {
|
|
108
|
+
best = Math.max(best, 0.02);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return best;
|
|
112
|
+
}
|
|
113
|
+
// =============================================================================
|
|
114
|
+
// nameMatchBonus
|
|
115
|
+
// =============================================================================
|
|
116
|
+
/**
|
|
117
|
+
* Boost exact name matches over prefix or substring matches.
|
|
118
|
+
*
|
|
119
|
+
* When a query token matches a node's name with different degrees of
|
|
120
|
+
* specificity, this function returns a higher bonus for closer matches:
|
|
121
|
+
*
|
|
122
|
+
* - Exact match (case-insensitive) → 0.20
|
|
123
|
+
* - Exact match of one token (multi-word) → 0.15
|
|
124
|
+
* - Prefix match (name starts with query) → 0.10
|
|
125
|
+
* - Substring match → 0.05
|
|
126
|
+
* - No match → 0
|
|
127
|
+
*
|
|
128
|
+
* @param name - The node's name (Node.name).
|
|
129
|
+
* @param query - The raw search query text.
|
|
130
|
+
* @returns A bonus value in [0, 0.20].
|
|
131
|
+
*/
|
|
132
|
+
function nameMatchBonus(name, query) {
|
|
133
|
+
if (!name || !query)
|
|
134
|
+
return 0;
|
|
135
|
+
const lowerName = name.toLowerCase();
|
|
136
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
137
|
+
if (lowerQuery.length === 0)
|
|
138
|
+
return 0;
|
|
139
|
+
// Exact match (case-insensitive)
|
|
140
|
+
if (lowerName === lowerQuery)
|
|
141
|
+
return 0.20;
|
|
142
|
+
// Tokenize the query and check per-token exact matches
|
|
143
|
+
const queryTokens = lowerQuery.split(/\s+/).filter((t) => t.length > 0);
|
|
144
|
+
for (const token of queryTokens) {
|
|
145
|
+
if (token.length < 2)
|
|
146
|
+
continue;
|
|
147
|
+
if (lowerName === token)
|
|
148
|
+
return 0.15;
|
|
149
|
+
}
|
|
150
|
+
// Prefix match — query string is a prefix of the name
|
|
151
|
+
if (lowerName.startsWith(lowerQuery))
|
|
152
|
+
return 0.10;
|
|
153
|
+
// Check if any query token is a prefix of the name
|
|
154
|
+
for (const token of queryTokens) {
|
|
155
|
+
if (token.length >= 2 && lowerName.startsWith(token))
|
|
156
|
+
return 0.10;
|
|
157
|
+
}
|
|
158
|
+
// Substring match
|
|
159
|
+
if (lowerName.includes(lowerQuery))
|
|
160
|
+
return 0.05;
|
|
161
|
+
for (const token of queryTokens) {
|
|
162
|
+
if (token.length >= 2 && lowerName.includes(token))
|
|
163
|
+
return 0.05;
|
|
164
|
+
}
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
// =============================================================================
|
|
168
|
+
// Combined scoring helpers
|
|
169
|
+
// =============================================================================
|
|
170
|
+
/**
|
|
171
|
+
* Compute an augmented score for a single search result by composing the
|
|
172
|
+
* base relevance score with the kind, path, and name bonuses.
|
|
173
|
+
*
|
|
174
|
+
* This is useful when re-ranking results after retrieving them from
|
|
175
|
+
* QueryBuilder.searchNodes.
|
|
176
|
+
*
|
|
177
|
+
* @param result - A SearchResult from QueryBuilder.
|
|
178
|
+
* @param query - The original query text (for name/path relevance).
|
|
179
|
+
* @returns A new score with all applicable bonuses added.
|
|
180
|
+
*/
|
|
181
|
+
function computeAugmentedScore(result, query) {
|
|
182
|
+
const base = result.score;
|
|
183
|
+
const kindB = kindBonus(result.node.kind);
|
|
184
|
+
const pathB = scorePathRelevance(result.node.filePath, query);
|
|
185
|
+
const nameB = nameMatchBonus(result.node.name, query);
|
|
186
|
+
return base + kindB + pathB + nameB;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Re-rank an array of SearchResults by their augmented score in
|
|
190
|
+
* descending order. Mutates the input array in place.
|
|
191
|
+
*
|
|
192
|
+
* @param results - Search results to re-rank.
|
|
193
|
+
* @param query - The original query text.
|
|
194
|
+
* @returns The same array (sorted in place) for chaining.
|
|
195
|
+
*/
|
|
196
|
+
function rerankResults(results, query) {
|
|
197
|
+
for (const r of results) {
|
|
198
|
+
r.score = computeAugmentedScore(r, query);
|
|
199
|
+
}
|
|
200
|
+
results.sort((a, b) => b.score - a.score);
|
|
201
|
+
return results;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=query-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-utils.js","sourceRoot":"","sources":["../../src/search/query-utils.ts"],"names":[],"mappings":";AAAA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MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEtD,OAAO,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,OAAuB,EAAE,KAAa;IAClE,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,CAAC,CAAC,KAAK,GAAG,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DBGraph Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types for the database schema knowledge graph system.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Types of nodes in the database knowledge graph.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NODE_KINDS: readonly ["server", "database", "schema", "table", "view", "column", "index", "trigger", "stored_procedure", "function", "sequence", "constraint", "foreign_key", "module", "namespace"];
|
|
10
|
+
export type NodeKind = (typeof NODE_KINDS)[number];
|
|
11
|
+
/**
|
|
12
|
+
* Types of edges (relationships) between nodes
|
|
13
|
+
*/
|
|
14
|
+
export type EdgeKind = 'contains' | 'references' | 'primary_key' | 'foreign_key' | 'indexed_by' | 'depends_on' | 'imports' | 'exports';
|
|
15
|
+
/**
|
|
16
|
+
* Database engine types
|
|
17
|
+
*/
|
|
18
|
+
export declare const DB_ENGINES: readonly ["postgresql", "mysql", "mariadb", "mssql", "sqlite", "oracle", "mongodb"];
|
|
19
|
+
export type DbEngine = (typeof DB_ENGINES)[number];
|
|
20
|
+
/**
|
|
21
|
+
* A node in the database knowledge graph representing a schema object
|
|
22
|
+
*/
|
|
23
|
+
export interface Node {
|
|
24
|
+
/** Unique identifier (hash of source URI + qualified name) */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Type of schema object */
|
|
27
|
+
kind: NodeKind;
|
|
28
|
+
/** Simple name (e.g., "orders", "total_amount") */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Fully qualified name (e.g., "ecommerce.public.orders.total_amount") */
|
|
31
|
+
qualifiedName: string;
|
|
32
|
+
/** Source identifier: db://@alias/schema or db://host:port/db/schema */
|
|
33
|
+
filePath: string;
|
|
34
|
+
/** Database engine */
|
|
35
|
+
language: string;
|
|
36
|
+
/** Starting line number (for views/SPs that have source) */
|
|
37
|
+
startLine: number;
|
|
38
|
+
endLine: number;
|
|
39
|
+
/** Additional properties as JSON object */
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
/** DDL / definition string (e.g., CREATE VIEW statement, column definition) */
|
|
42
|
+
signature?: string;
|
|
43
|
+
/** Comment / description */
|
|
44
|
+
docstring?: string;
|
|
45
|
+
/** When the node was last updated */
|
|
46
|
+
updatedAt: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* An edge representing a relationship between two schema objects
|
|
50
|
+
*/
|
|
51
|
+
export interface Edge {
|
|
52
|
+
/** Source node ID */
|
|
53
|
+
source: string;
|
|
54
|
+
/** Target node ID */
|
|
55
|
+
target: string;
|
|
56
|
+
/** Type of relationship */
|
|
57
|
+
kind: EdgeKind;
|
|
58
|
+
/** Additional context about the relationship */
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
60
|
+
/** How this edge was created */
|
|
61
|
+
provenance?: 'introspect' | 'heuristic' | 'manual';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Metadata about a tracked database
|
|
65
|
+
*/
|
|
66
|
+
export interface DbSourceRecord {
|
|
67
|
+
/** Unique alias (as defined in config) */
|
|
68
|
+
alias: string;
|
|
69
|
+
/** Database engine type */
|
|
70
|
+
engine: DbEngine;
|
|
71
|
+
/** Database name */
|
|
72
|
+
database: string;
|
|
73
|
+
/** Host (for network DBs) */
|
|
74
|
+
host?: string;
|
|
75
|
+
/** Port */
|
|
76
|
+
port?: number;
|
|
77
|
+
/** Connection URI for display */
|
|
78
|
+
displayUri: string;
|
|
79
|
+
/** When last indexed */
|
|
80
|
+
indexedAt: number;
|
|
81
|
+
/** Number of nodes extracted from this source */
|
|
82
|
+
nodeCount: number;
|
|
83
|
+
/** Any extraction errors */
|
|
84
|
+
errors?: string[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Result from introspecting a database
|
|
88
|
+
*/
|
|
89
|
+
export interface IntrospectResult {
|
|
90
|
+
/** Extracted nodes */
|
|
91
|
+
nodes: Node[];
|
|
92
|
+
/** Extracted edges */
|
|
93
|
+
edges: Edge[];
|
|
94
|
+
/** Extraction duration in milliseconds */
|
|
95
|
+
durationMs: number;
|
|
96
|
+
/** Any errors during extraction */
|
|
97
|
+
errors: string[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Database connection config (from config file)
|
|
101
|
+
*/
|
|
102
|
+
export interface DbConnectionConfig {
|
|
103
|
+
/** Unique alias for this database */
|
|
104
|
+
alias: string;
|
|
105
|
+
/** Database engine */
|
|
106
|
+
engine: DbEngine;
|
|
107
|
+
/** Hostname or IP */
|
|
108
|
+
host?: string;
|
|
109
|
+
/** Port number */
|
|
110
|
+
port?: number;
|
|
111
|
+
/** Database name */
|
|
112
|
+
database: string;
|
|
113
|
+
/** Schemas to include (default: all) */
|
|
114
|
+
schemas?: string[];
|
|
115
|
+
/** Path for file-based DBs (SQLite) */
|
|
116
|
+
path?: string;
|
|
117
|
+
/** Authentication method */
|
|
118
|
+
auth?: string;
|
|
119
|
+
/** SSL settings */
|
|
120
|
+
ssl?: boolean;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A subgraph containing a subset of the knowledge graph
|
|
124
|
+
*/
|
|
125
|
+
export interface Subgraph {
|
|
126
|
+
/** Nodes in this subgraph */
|
|
127
|
+
nodes: Map<string, Node>;
|
|
128
|
+
/** Edges in this subgraph */
|
|
129
|
+
edges: Edge[];
|
|
130
|
+
/** Root node IDs (entry points) */
|
|
131
|
+
roots: string[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Options for graph traversal
|
|
135
|
+
*/
|
|
136
|
+
export interface TraversalOptions {
|
|
137
|
+
/** Maximum depth to traverse (default: Infinity) */
|
|
138
|
+
maxDepth?: number;
|
|
139
|
+
/** Edge types to follow (default: all) */
|
|
140
|
+
edgeKinds?: EdgeKind[];
|
|
141
|
+
/** Node types to include (default: all) */
|
|
142
|
+
nodeKinds?: NodeKind[];
|
|
143
|
+
/** Direction of traversal */
|
|
144
|
+
direction?: 'outgoing' | 'incoming' | 'both';
|
|
145
|
+
/** Maximum nodes to return */
|
|
146
|
+
limit?: number;
|
|
147
|
+
/** Whether to include the starting node */
|
|
148
|
+
includeStart?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Options for searching the graph
|
|
152
|
+
*/
|
|
153
|
+
export interface SearchOptions {
|
|
154
|
+
/** Node types to search */
|
|
155
|
+
kinds?: NodeKind[];
|
|
156
|
+
/** Source filter (db://@alias prefix) */
|
|
157
|
+
source?: string;
|
|
158
|
+
/** Maximum results to return */
|
|
159
|
+
limit?: number;
|
|
160
|
+
/** Offset for pagination */
|
|
161
|
+
offset?: number;
|
|
162
|
+
/** Whether search is case-sensitive */
|
|
163
|
+
caseSensitive?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A search result with relevance scoring
|
|
167
|
+
*/
|
|
168
|
+
export interface SearchResult {
|
|
169
|
+
/** Matching node */
|
|
170
|
+
node: Node;
|
|
171
|
+
/** Relevance score (0-1) */
|
|
172
|
+
score: number;
|
|
173
|
+
/** Matched text snippets for highlighting */
|
|
174
|
+
highlights?: string[];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Context information for schema understanding
|
|
178
|
+
*/
|
|
179
|
+
export interface Context {
|
|
180
|
+
/** Primary node being examined */
|
|
181
|
+
focal: Node;
|
|
182
|
+
/** Nodes containing the focal node (database, schema, table) */
|
|
183
|
+
ancestors: Node[];
|
|
184
|
+
/** Nodes directly contained by focal node */
|
|
185
|
+
children: Node[];
|
|
186
|
+
/** Incoming references (what references this node) */
|
|
187
|
+
incomingRefs: Array<{
|
|
188
|
+
node: Node;
|
|
189
|
+
edge: Edge;
|
|
190
|
+
}>;
|
|
191
|
+
/** Outgoing references (what this node references) */
|
|
192
|
+
outgoingRefs: Array<{
|
|
193
|
+
node: Node;
|
|
194
|
+
edge: Edge;
|
|
195
|
+
}>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Full schema description for a table (composed from graph)
|
|
199
|
+
*/
|
|
200
|
+
export interface TableSchema {
|
|
201
|
+
/** Table name */
|
|
202
|
+
name: string;
|
|
203
|
+
/** Qualified name */
|
|
204
|
+
qualifiedName: string;
|
|
205
|
+
/** Database source */
|
|
206
|
+
source: string;
|
|
207
|
+
/** Table comment */
|
|
208
|
+
comment?: string;
|
|
209
|
+
/** Columns */
|
|
210
|
+
columns: ColumnSchema[];
|
|
211
|
+
/** Primary key columns */
|
|
212
|
+
primaryKey: string[];
|
|
213
|
+
/** Foreign keys */
|
|
214
|
+
foreignKeys: ForeignKeySchema[];
|
|
215
|
+
/** Indexes */
|
|
216
|
+
indexes: IndexSchema[];
|
|
217
|
+
/** Table type (table, view) */
|
|
218
|
+
kind: 'table' | 'view';
|
|
219
|
+
/** View DDL if applicable */
|
|
220
|
+
definition?: string;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Column schema
|
|
224
|
+
*/
|
|
225
|
+
export interface ColumnSchema {
|
|
226
|
+
name: string;
|
|
227
|
+
dataType: string;
|
|
228
|
+
isNullable: boolean;
|
|
229
|
+
defaultValue?: string;
|
|
230
|
+
isPrimaryKey: boolean;
|
|
231
|
+
maxLength?: number;
|
|
232
|
+
numericPrecision?: number;
|
|
233
|
+
numericScale?: number;
|
|
234
|
+
comment?: string;
|
|
235
|
+
charSet?: string;
|
|
236
|
+
collation?: string;
|
|
237
|
+
autoIncrement?: boolean;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Foreign key relationship
|
|
241
|
+
*/
|
|
242
|
+
export interface ForeignKeySchema {
|
|
243
|
+
constraintName: string;
|
|
244
|
+
columns: string[];
|
|
245
|
+
referencedTable: string;
|
|
246
|
+
referencedColumns: string[];
|
|
247
|
+
onUpdate?: string;
|
|
248
|
+
onDelete?: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Index information
|
|
252
|
+
*/
|
|
253
|
+
export interface IndexSchema {
|
|
254
|
+
name: string;
|
|
255
|
+
columns: string[];
|
|
256
|
+
unique: boolean;
|
|
257
|
+
primary: boolean;
|
|
258
|
+
method?: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Statistics about the knowledge graph
|
|
262
|
+
*/
|
|
263
|
+
export interface GraphStats {
|
|
264
|
+
/** Total number of nodes */
|
|
265
|
+
nodeCount: number;
|
|
266
|
+
/** Total number of edges */
|
|
267
|
+
edgeCount: number;
|
|
268
|
+
/** Number of tracked databases */
|
|
269
|
+
dbCount: number;
|
|
270
|
+
/** Node counts by kind */
|
|
271
|
+
nodesByKind: Record<string, number>;
|
|
272
|
+
/** Edge counts by kind */
|
|
273
|
+
edgesByKind: Record<string, number>;
|
|
274
|
+
/** Database size in bytes */
|
|
275
|
+
dbSizeBytes: number;
|
|
276
|
+
/** Last update timestamp */
|
|
277
|
+
lastUpdated: number;
|
|
278
|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;CACrB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DBGraph Type Definitions
|
|
4
|
+
*
|
|
5
|
+
* Core types for the database schema knowledge graph system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DB_ENGINES = exports.NODE_KINDS = void 0;
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Union Types
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Types of nodes in the database knowledge graph.
|
|
14
|
+
*/
|
|
15
|
+
exports.NODE_KINDS = [
|
|
16
|
+
// Container / namespace
|
|
17
|
+
'server',
|
|
18
|
+
'database',
|
|
19
|
+
'schema',
|
|
20
|
+
// Schema objects
|
|
21
|
+
'table',
|
|
22
|
+
'view',
|
|
23
|
+
'column',
|
|
24
|
+
'index',
|
|
25
|
+
'trigger',
|
|
26
|
+
'stored_procedure',
|
|
27
|
+
'function',
|
|
28
|
+
'sequence',
|
|
29
|
+
'constraint',
|
|
30
|
+
'foreign_key',
|
|
31
|
+
// Legacy code-symbol kinds kept for graph-generic query compatibility
|
|
32
|
+
'module',
|
|
33
|
+
'namespace',
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Database engine types
|
|
37
|
+
*/
|
|
38
|
+
exports.DB_ENGINES = [
|
|
39
|
+
'postgresql',
|
|
40
|
+
'mysql',
|
|
41
|
+
'mariadb',
|
|
42
|
+
'mssql',
|
|
43
|
+
'sqlite',
|
|
44
|
+
'oracle',
|
|
45
|
+
'mongodb',
|
|
46
|
+
];
|
|
47
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,wBAAwB;IACxB,QAAQ;IACR,UAAU;IACV,QAAQ;IAER,iBAAiB;IACjB,OAAO;IACP,MAAM;IACN,QAAQ;IACR,OAAO;IACP,SAAS;IACT,kBAAkB;IAClB,UAAU;IACV,UAAU;IACV,YAAY;IACZ,aAAa;IAEb,sEAAsE;IACtE,QAAQ;IACR,WAAW;CACH,CAAC;AAsBX;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,YAAY;IACZ,OAAO;IACP,SAAS;IACT,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;CACD,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DBGraph Utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Safely parse JSON with a fallback value
|
|
6
|
+
*/
|
|
7
|
+
export declare function safeJsonParse<T>(value: string, fallback: T): T;
|
|
8
|
+
/**
|
|
9
|
+
* Cross-process file lock
|
|
10
|
+
*/
|
|
11
|
+
export declare class FileLock {
|
|
12
|
+
private lockPath;
|
|
13
|
+
private held;
|
|
14
|
+
private static readonly STALE_TIMEOUT_MS;
|
|
15
|
+
constructor(lockPath: string);
|
|
16
|
+
acquire(): void;
|
|
17
|
+
release(): void;
|
|
18
|
+
withLock<T>(fn: () => T): T;
|
|
19
|
+
withLockAsync<T>(fn: () => Promise<T>): Promise<T>;
|
|
20
|
+
private isProcessAlive;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Simple mutex lock
|
|
24
|
+
*/
|
|
25
|
+
export declare class Mutex {
|
|
26
|
+
private locked;
|
|
27
|
+
private waitQueue;
|
|
28
|
+
acquire(): Promise<() => void>;
|
|
29
|
+
withLock<T>(fn: () => Promise<T> | T): Promise<T>;
|
|
30
|
+
isLocked(): boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Generate a stable hash string from input
|
|
34
|
+
*/
|
|
35
|
+
export declare function hashString(input: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Escape identifier for SQL display
|
|
38
|
+
*/
|
|
39
|
+
export declare function quoteIdentifier(name: string, engine: string): string;
|
|
40
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAM9D;AAED;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAiB;gBAE7C,QAAQ,EAAE,MAAM;IAI5B,OAAO,IAAI,IAAI;IAqCf,OAAO,IAAI,IAAI;IAWf,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAKrB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxD,OAAO,CAAC,cAAc;CAIvB;AAED;;GAEG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAyB;IAEpC,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC;IAY9B,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKvD,QAAQ,IAAI,OAAO;CACpB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGpE"}
|