release: v0.5.1 — 存储后端生产级硬化(CRC-32/全库加密/WAL分片/页面化存储/多标签页锁/e2e)+ 深度审查修复(假实现接线/死代码清理)
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>MetonaSqlark E2E Harness</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>MetonaSqlark E2E Harness</h1>
|
||||
<div id="status">loading</div>
|
||||
<script src="/dist/metona-sqlark.js"></script>
|
||||
<script>
|
||||
// E2E 驱动器:暴露全局 API,测试通过 page.evaluate 调用
|
||||
// 使用高层 API(MetonaSqlark.create),保证 e2e 覆盖真实入口路径
|
||||
window.__ms = {
|
||||
version: () => (window.MetonaSqlark ? window.MetonaSqlark.VERSION : null),
|
||||
|
||||
/**
|
||||
* 创建并打开 Aria 库。
|
||||
* opts: {
|
||||
* name, diskEngine ('opfs'|'indexeddb'|'memory'),
|
||||
* walSyncMode, checkpointInterval,
|
||||
* encryptionPassword, memtableSizeThreshold
|
||||
* }
|
||||
*/
|
||||
open: async (opts) => {
|
||||
const db = await window.MetonaSqlark.create({
|
||||
name: opts.name,
|
||||
mode: 'aria',
|
||||
diskEngine: opts.diskEngine || 'opfs',
|
||||
aria: {
|
||||
walSyncMode: opts.walSyncMode || 'full',
|
||||
checkpointInterval: opts.checkpointInterval || 100000,
|
||||
memtableSizeThreshold: opts.memtableSizeThreshold || 64 * 1024 * 1024,
|
||||
...(opts.encryptionPassword ? { encryption: { password: opts.encryptionPassword } } : {}),
|
||||
},
|
||||
});
|
||||
window.__ms.__db = db;
|
||||
return { ok: true, engineName: db.getEngine().name };
|
||||
},
|
||||
|
||||
createTable: async (opts) => {
|
||||
const db = window.__ms.__db;
|
||||
const columns = {};
|
||||
for (const col of opts.columns) {
|
||||
columns[col.name] = { type: col.type, primaryKey: !!col.primaryKey, index: !!col.index };
|
||||
}
|
||||
await db.defineTable(opts.table, columns);
|
||||
return { ok: true };
|
||||
},
|
||||
|
||||
insert: async (opts) => {
|
||||
const db = window.__ms.__db;
|
||||
const pks = await db.table(opts.table).insertMany(opts.rows);
|
||||
return { pks };
|
||||
},
|
||||
|
||||
count: async (opts) => {
|
||||
const db = window.__ms.__db;
|
||||
return { count: await db.table(opts.table).count() };
|
||||
},
|
||||
|
||||
find: async (opts) => {
|
||||
const db = window.__ms.__db;
|
||||
const rows = await db.table(opts.table).select().where(opts.where || {}).execute();
|
||||
return { rows };
|
||||
},
|
||||
|
||||
query: async (opts) => {
|
||||
const db = window.__ms.__db;
|
||||
return { rows: await db.query(opts.sql) };
|
||||
},
|
||||
|
||||
repair: async () => {
|
||||
const db = window.__ms.__db;
|
||||
await db.repair();
|
||||
return { ok: true };
|
||||
},
|
||||
|
||||
clearAll: async () => {
|
||||
const db = window.__ms.__db;
|
||||
await db.clearAll();
|
||||
return { ok: true };
|
||||
},
|
||||
|
||||
close: async () => {
|
||||
const db = window.__ms.__db;
|
||||
await db.close();
|
||||
window.__ms.__db = null;
|
||||
return { ok: true };
|
||||
},
|
||||
|
||||
getEngine: () => (window.__ms.__db ? window.__ms.__db.getEngine() : null),
|
||||
};
|
||||
document.getElementById('status').textContent = 'ready';
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user