feat(storage): index local records and expand global search

This commit is contained in:
Codex committed 2026-10-07 14:55:05 +08:00
1 parent f31d3933ae
commit 3877d4f986
23 files changed
+184 -62

No files matched your search

+8 -2
View File
@@ -4,6 +4,7 @@ import vm from "node:vm";
const worker = await import(new URL("../dist/server/index.js", import.meta.url));
assert.equal(typeof worker.default?.fetch, "function");
const assets = await import(new URL("../dist/server/assets.js", import.meta.url));
const localAssets = await import(new URL("../dist/server/local-assets.js", import.meta.url));
const source = await readFile(new URL("../public/index.html", import.meta.url), "utf8");
assert.match(assets.indexHtml, /!\[1,2,3\]\.includes\(d\.schemaVersion\)/);
assert.doesNotMatch(assets.indexHtml, /localizeDynamicText|createTreeWalker|NodeFilter\.SHOW_TEXT|const ZH=/);
@@ -22,6 +23,10 @@ assert.match(assets.addonsJs, /lifeos_sync_outbox_v1/);
assert.match(assets.addonsJs, /function openSyncCenter/);
assert.match(assets.addonsJs, /resolveSavedConflict/);
assert.match(assets.serviceWorker, /SKIP_WAITING/);
assert.match(localAssets.localDbWorkerJs, /CREATE TABLE IF NOT EXISTS memories/);
assert.match(localAssets.localDbWorkerJs, /CREATE INDEX IF NOT EXISTS idx_tasks_due_done/);
assert.match(localAssets.localDbWorkerJs, /action === 'search'/);
assert.match(assets.indexHtml, /LifeOSLocalDB\.search/);
assert.match(assets.i18nRenderersJs, /dialog\.goals/);
assert.match(assets.i18nRenderersJs, /shell\.wallpaperTitle/);
assert.match(assets.i18nRenderersJs, /window\.museumApp/);
@@ -279,7 +284,7 @@ assert.ok(command('date').message.length > 8);
assert.ok(command('time').message.includes(':'));
assert.ok(command('datetime').message.length > 12);
assert.equal(command('uptime').message, 'terminal.uptime');
assert.equal(command('version').message, 'Life OS v1.21.0');
assert.equal(command('version').message, 'Life OS v1.22.0');
assert.equal(command('status').message, 'terminal.status');
assert.match(command('apps').message, /calendar/);
assert.equal(command('echo "hello Life OS"').message, 'hello Life OS');
@@ -302,7 +307,7 @@ const makeStorage = initial => {
};
const backupStorage = makeStorage({
lifeos_memories: '[]', lifeos_museum: '[]', lifeos_profile: '{}', lifeos_settings: '{}', lifeos_system: '{"schemaVersion":2}',
lifeos_notifications_v1: '{"memory":{"enabled":true}}', lifeos_storage_mode_v1: 'local', lifeos_cloud_baseline_v3: '{"internal":true}'
lifeos_notifications_v1: '{"memory":{"enabled":true}}', lifeos_storage_mode_v1: 'local', lifeos_cloud_baseline_v3: '{"internal":true}', lifeos_sync_outbox_v1: '[{"kind":"memory"}]'
});
Object.defineProperties(backupStorage, { length: { get: () => backupStorage.values.size } });
backupStorage.key = index => [...backupStorage.values.keys()][index] ?? null;
@@ -320,6 +325,7 @@ assert.equal(portableBackup.schemaVersion, 3);
assert.equal(portableBackup.records.lifeos_notifications_v1, '{"memory":{"enabled":true}}');
assert.equal(portableBackup.records.lifeos_storage_mode_v1, undefined, 'device storage choice does not migrate');
assert.equal(portableBackup.records.lifeos_cloud_baseline_v3, undefined, 'cloud internals do not migrate');
assert.equal(portableBackup.records.lifeos_sync_outbox_v1, undefined, 'sync queue does not migrate');
assert.equal(await backupContext.LifeOSBackup.validate(portableBackup), true);
portableBackup.records.lifeos_notifications_v1 = '{}';
assert.equal(await backupContext.LifeOSBackup.validate(portableBackup), false, 'checksum rejects a modified backup');