// D1 nested-answer probe: for game answers map, report each uid's answer value enc-status (NEVER values). const admin = require('firebase-admin') const path = require('path') const SA = process.env.SA_JSON || path.join(__dirname, '..', 'closer-app-22014-firebase-adminsdk-fbsvc-ed20bf6003.json') const COUPLE = process.env.COUPLE_ID || 'Xal3Kw3gjSdn0niERYKJ' admin.initializeApp({ credential: admin.credential.cert(require(SA)) }) const db = admin.firestore() const CIPHER = /^(enc:v1:|sealed:v1:)/ function classify(v) { if (typeof v === 'string') return CIPHER.test(v) ? `enc✓(${v.length})` : `RAW?(${v.length})` if (Array.isArray(v)) return `[${v.length}: ${v.map(classify).join(',')}]` if (v && typeof v === 'object') return '{' + Object.entries(v).map(([k, x]) => `${k}=${classify(x)}`).join(' ') + '}' return typeof v } async function probe(coll, mapField) { const c = db.collection('couples').doc(COUPLE) const s = await c.collection(coll).limit(1).get() if (s.empty) return console.log(`[${coll}] empty`) const d = s.docs[0].data() const m = d[mapField] if (!m) return console.log(`[${coll}] no ${mapField}`) for (const [uid, val] of Object.entries(m)) { console.log(`[${coll}] ${mapField}.${uid.slice(0, 6)}…: ${classify(val)}`) } } (async () => { for (const g of ['this_or_that', 'desire_sync', 'how_well', 'wheel']) await probe(g, 'answers') await probe('date_swipes', 'actions') process.exit(0) })().catch(e => { console.error('FATAL', e); process.exit(1) })