Initial curated chimera source from a8ae5b1db07fb49926c94585e2718e5130330974

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:38:08 +02:00
commit c737a37f71
531 files changed
+119270

No files matched your search

@@ -0,0 +1,23 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const database = require('../../src/database');
const { createSqliteTrophySnapshotRepository, parseTrophySnapshot } = require('../../src/services/trophy-snapshot-service');
test('production database adapter stores imported history immutably with parameterized reads', async t => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'chimera-trophy-history-'));
t.after(() => { database.close(); fs.rmSync(root, { recursive: true, force: true }); });
database.configure({ dataDir: root, logger: { info() {}, warn() {}, error() {} } });
await database.initialize();
const repository = createSqliteTrophySnapshotRepository({ db: database });
const parsed = parseTrophySnapshot({ schemaVersion: 1, provider: { id: 'authorized-psn-readonly', version: 'psn-api-2.18.0' }, account: { accountId: '1234567890', onlineId: 'Player_One' }, context: { region: 'BE', language: 'nl-BE' }, fetchedAt: '2026-08-11T12:00:00.000Z', warnings: [], titles: [{ npCommunicationId: 'NPWR20002_00', titleId: '', contentId: '', name: 'Native Game', platform: 'PS5', service: 'trophy2', groups: [{ groupId: 'default', name: 'Base' }], trophies: [{ groupId: 'default', trophyId: 2, name: 'Exact', grade: 'gold', hidden: true, earned: true, earnedDateTime: '2024-02-03T04:05:06.789Z', progress: 100, definitionHash: null }] }] });
const saved = repository.save(parsed, { kind: 'provider-fetch', importedAt: 1_800_000_000_000, requestCount: 4 });
assert.equal(saved.snapshot.titles[0].platform, 'PS5');
assert.equal(saved.snapshot.titles[0].trophies[0].earnedDateTime, '2024-02-03T04:05:06.789Z');
assert.equal(repository.get(saved.id).canonicalSha256, saved.canonicalSha256);
assert.throws(() => database.runMutatingSqlWithParams('UPDATE trophy_psn_snapshots SET online_id=@id', { id: 'Changed' }), /immutable/);
});