const admin = require('firebase-admin') const path = require('path') const SA = 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() function shallow(v){ if(typeof v==='string') return v.length>40?`str(${v.length})`:v; if(Array.isArray(v)) return `[${v.length}]`; if(v&&typeof v==='object') return '{'+Object.keys(v).join(',')+'}'; return v } ;(async () => { const c = await db.collection('couples').doc(COUPLE).get() const cd = c.data() || {} console.log('=== couple top-level keys ===') for (const k of Object.keys(cd)) console.log(` ${k} = ${shallow(cd[k])}`) // find uid-like values const uids = new Set() for (const [k,v] of Object.entries(cd)) { if (typeof v==='string' && /^[A-Za-z0-9]{20,}$/.test(v)) uids.add(v) if (Array.isArray(v)) v.forEach(x=>{ if(typeof x==='string'&&/^[A-Za-z0-9]{20,}$/.test(x)) uids.add(x) }) if (v&&typeof v==='object'&&!Array.isArray(v)) Object.keys(v).forEach(x=>{ if(/^[A-Za-z0-9]{20,}$/.test(x)) uids.add(x) }) } console.log('=== candidate member uids ===', [...uids].map(u=>u.slice(0,10)+'…')) for (const uid of uids) { const ent = await db.collection('users').doc(uid).collection('entitlements').doc('premium').get() console.log(` ${uid.slice(0,10)}… entitlements/premium:`, ent.exists?JSON.stringify(ent.data()):'MISSING(free)') } process.exit(0) })().catch(e=>{console.error('FATAL',e.message);process.exit(1)})