← back to Designerwallcoverings
scripts/ai-preamble-leak-sweep/wallpaper-reconcile.mjs
12 lines
import fs from 'fs';
const ENV=fs.readFileSync('/Users/stevestudio2/Projects/secrets-manager/.env','utf8');
const TOK=((ENV.match(/^SHOPIFY_ADMIN_TOKEN=(.+)$/m)||[])[1]||'').replace(/['"\r]/g,'').trim();
const GQL='https://designer-laboratory-sandbox.myshopify.com/admin/api/2024-10/graphql.json';
async function gql(q,v){const r=await fetch(GQL,{method:'POST',headers:{'X-Shopify-Access-Token':TOK,'Content-Type':'application/json'},body:JSON.stringify({query:q,variables:v})});return r.json();}
// independent mechanism: Shopify search query for title containing wallpaper, vs an active baseline.
async function count(q){ const j=await gql(`query($q:String){ productsCount(query:$q){ count } }`,{q}); return j.data?.productsCount?.count ?? ('ERR '+JSON.stringify(j.errors)); }
console.log("active total:", await count("status:active"));
console.log("active title:*Wallpaper*:", await count("status:active title:Wallpaper*"));
console.log("active (any-field) Wallpaper:", await count("status:active Wallpaper"));
console.log("active title:*Wallcovering*:", await count("status:active title:Wallcovering*"));