← back to Mfr Review Viewer Corruption
scripts/diagnostics/probe-related-table-occurrences.mjs
22 lines
// STEP 3 (READ-ONLY): name every related table-occurrence the WALLPAPER graph exposes,
// and test which of those external files are actually reachable on the server.
import { readFileSync, writeFileSync } from 'node:fs';
import path from 'node:path'; import os from 'node:os';
const SP='/private/tmp/claude-501/-Users-macstudio3-Projects-mfr-review-viewer-corruption/a26937d9-cc11-4299-9dfb-d661aa523a33/scratchpad';
const FM_PROJECT = path.join(os.homedir(),'Projects','filemaker-mcp');
for (const line of readFileSync(path.join(FM_PROJECT,'.env'),'utf8').split('\n')) { const m=line.match(/^([A-Z_]+)=(.*)$/); if(m&&!process.env[m[1]]) process.env[m[1]]=m[2]; }
process.env.FM_READONLY='1';
const fm = await import('file://'+path.join(FM_PROJECT,'src','fm-client.js'));
const p1 = JSON.parse(readFileSync(SP+'/probe1.json','utf8'));
const tos = new Map();
for (const o of p1) {
if(!o.ok) continue;
for (const rf of (o.relatedFields||[])) { const to=rf.split('::')[0]; if(!tos.has(to)) tos.set(to,{to,via:'field',firstLayout:o.layout,example:rf}); }
for (const p of (o.portals||[])) { const to=p.split('::')[0]; if(!tos.has(to)) tos.set(to,{to,via:'portal',firstLayout:o.layout,example:p}); }
}
console.log('=== related table occurrences referenced by WALLPAPER layouts ===');
for (const t of tos.values()) console.log(` TO="${t.to}" via=${t.via} layout="${t.firstLayout}" ex="${t.example}"`);
console.log('\n=== GET-failed layouts (code + message) ===');
for (const o of p1.filter(x=>!x.ok)) console.log(` ${o.layout} :: code="${o.code}" :: ${o.msg}`);
writeFileSync(SP+'/probe3-tos.json', JSON.stringify([...tos.values()],null,1));