Replace better-sqlite3 with built-in SQLite drivers
All checks were successful
npm release / verify (push) Successful in 24s
npm release / publish to npm (push) Successful in 11s

This commit is contained in:
2026-05-12 16:52:22 +09:00
parent b77e8eea40
commit 6accd62df5
8 changed files with 222 additions and 94 deletions

43
tests/bun-runtime.test.ts Normal file
View File

@@ -0,0 +1,43 @@
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
import { describe, expect, it } from 'vitest';
const execFileAsync = promisify(execFile);
describe('Bun runtime compatibility', () => {
it('connects to sqlite from the package in Bun', async () => {
const script = [
"import { IdentityDB } from './src/index.ts';",
"const db = await IdentityDB.connect({ client: 'sqlite', filename: ':memory:' });",
'await db.initialize();',
"console.log('bun-sqlite-ok');",
'await db.close();',
].join('\n');
const result = await execFileAsync('bun', ['--eval', script], {
cwd: process.cwd(),
});
expect(result.stdout).toContain('bun-sqlite-ok');
});
it('supports writes and reads through the Bun sqlite adapter path', async () => {
const script = [
"import { IdentityDB } from './src/index.ts';",
"const db = await IdentityDB.connect({ client: 'sqlite', filename: ':memory:' });",
'await db.initialize();',
"await db.addFact({ statement: 'Bun supports sqlite.', topics: [{ name: 'Bun', category: 'entity', granularity: 'concrete' }, { name: 'sqlite', category: 'concept', granularity: 'concrete' }] });",
"const facts = await db.getTopicFacts('Bun');",
"if (facts.length !== 1 || facts[0]?.statement !== 'Bun supports sqlite.') throw new Error('bun sqlite CRUD failed');",
"console.log('bun-sqlite-crud-ok');",
'await db.close();',
].join('\n');
const result = await execFileAsync('bun', ['--eval', script], {
cwd: process.cwd(),
});
expect(result.stdout).toContain('bun-sqlite-crud-ok');
});
});