← back to Flock Fix Viewer

archive-flock-residual.mjs

46 lines

// TK-11122 — archive the 5 residual active-but-UNBUYABLE flock listings.
// Steve approved 2026-09-03 (AskUserQuestion): Retro Velvet 8003/8004 = archive both;
// Monkey Madness 876555/6/7 = archive all 3. Each is sample-only, no sellable roll,
// no recoverable mfr# (8004 excepted — it now carries W5725-04 but still no roll).
// Reversible: snapshots each product's current status, ledgers undo (status->active).
// DRY default; --apply writes. Live Shopify write => run via Steve's `!` paste.
import fs from 'fs'; import os from 'os'; import path from 'path';
const SHOP='designer-laboratory-sandbox.myshopify.com';
const TOKEN=fs.readFileSync(new URL('./.token',import.meta.url),'utf8').trim();
const LEDGER=path.join(os.homedir(),'.claude/yolo-queue/executed-reversible/ledger.jsonl');
const SNAP=new URL('./archive-flock-residual-snapshot.json',import.meta.url);
const DRY=!process.argv.includes('--apply');
const API=`https://${SHOP}/admin/api/2024-10`;
const H={'X-Shopify-Access-Token':TOKEN,'Content-Type':'application/json'};

const TARGETS=[
  {id:1494878158960, sku:'FLOCK-8003',   note:'Retro Velvet paisley (mfr# unknown)'},
  {id:1494878388336, sku:'FLOCK-8004',   note:'Retro Velvet hot pink (O&L W5725-04, no roll)'},
  {id:1499354464368, sku:'Flock-876555', note:'Monkey Madness Ebony & Cream'},
  {id:1499355807856, sku:'Flock-876556', note:'Monkey Madness Ivory & Bone'},
  {id:1499355676784, sku:'Flock-876557', note:'Monkey Madness Natural & Beige'},
];

console.log(`Archive ${TARGETS.length} residual flock listings  APPLY=${!DRY}\n`);
const snap=[];
for(const t of TARGETS){
  const r=await (await fetch(`${API}/products/${t.id}.json?fields=id,status,title`,{headers:H})).json();
  const p=r.product;
  console.log(`  ${t.sku.padEnd(14)} ${t.id}  status: "${p.status}" -> "archived"   (${t.note})`);
  snap.push({id:t.id,sku:t.sku,oldStatus:p.status});
}
if(DRY){console.log('\nDRY RUN — nothing written. Re-run with --apply.');process.exit(0);}

for(const t of TARGETS){
  const res=await (await fetch(`${API}/products/${t.id}.json`,{method:'PUT',headers:H,
    body:JSON.stringify({product:{id:t.id,status:'archived'}})})).json();
  const ok=res?.product?.status==='archived';
  console.log(`  ${ok?'✓':'FAIL'} ${t.sku} -> ${res?.product?.status||JSON.stringify(res).slice(0,120)}`);
}
fs.writeFileSync(SNAP,JSON.stringify(snap,null,1));
fs.appendFileSync(LEDGER,JSON.stringify({ts:new Date().toISOString(),agent:'vp-dw-commerce',ticket:'TK-11122',
  action:`archived 5 residual active-but-unbuyable flock listings (8003/8004 + Monkey Madness 876555/6/7)`,
  blast_radius:5,undo_cmd:`restore archive-flock-residual-snapshot.json: PUT each product id status back to oldStatus (active)`,
  verify:'GET each product .json -> status==archived'})+'\n');
console.log('\nDONE — snapshot: archive-flock-residual-snapshot.json, ledgered.');