/** * score-hashes.ts — Print all regulation hashes for a score's measures. * * Usage: * npx tsx src/scripts/score-hashes.ts * * Output: JSON array of SHA1 hash strings to stdout. */ import { starry } from 'starry-omr'; import { pool, query } from '../db/client.js'; const scoreId = process.argv[2]; if (!scoreId) { console.error('Usage: npx tsx src/scripts/score-hashes.ts '); process.exit(1); } const { rows } = await query('SELECT data FROM scores WHERE id = $1', [scoreId]); if (!rows.length) { console.error(`Score not found: ${scoreId}`); process.exit(1); } const scoreData = rows[0].data; const score = starry.recoverJSON(scoreData, starry); score.assemble(); const spartito = score.makeSpartito(); const hashes = new Set(); for (const measure of spartito.measures) { const editable = new starry.EditableMeasure(measure); for (const h of editable.regulationHashes) { hashes.add(h); } } console.log(JSON.stringify(Array.from(hashes))); await pool.end(); process.exit(0);