feat(04-01): add sql.js dependency and graph schema
- Add sql.js ^1.12.0 dependency for WASM SQLite - Add GRAPH_SCHEMA constant with nodes/edges tables - Nodes use virtual id from JSON body for upserts - Edges indexed by source and target for relationship queries Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,25 @@
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const initSqlJs = require('sql.js');
|
||||
|
||||
// Graph database schema (simple-graph pattern)
|
||||
const GRAPH_SCHEMA = `
|
||||
CREATE TABLE IF NOT EXISTS nodes (
|
||||
body TEXT,
|
||||
id TEXT GENERATED ALWAYS AS (json_extract(body, '$.id')) VIRTUAL NOT NULL UNIQUE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS id_idx ON nodes(id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS edges (
|
||||
source TEXT NOT NULL,
|
||||
target TEXT NOT NULL,
|
||||
relationship TEXT DEFAULT 'depends_on',
|
||||
UNIQUE(source, target, relationship) ON CONFLICT REPLACE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS source_idx ON edges(source);
|
||||
CREATE INDEX IF NOT EXISTS target_idx ON edges(target);
|
||||
`;
|
||||
|
||||
// JS/TS file extensions to index
|
||||
const INDEXABLE_EXTENSIONS = ['.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs'];
|
||||
|
||||
@@ -32,5 +32,8 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"sql.js": "^1.12.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user