← back to York Reprice 2026 08
build-sample-payload.mjs
39 lines
import fs from 'node:fs';
const [hdr,row]=fs.readFileSync('data/one-new-item.csv','utf8').trim().split('\n');
const H=hdr.split(','); const C=row.match(/(".*?"|[^,]*)(,|$)/g).map(x=>x.replace(/,$/,'').replace(/^"|"$/g,''));
const r=Object.fromEntries(H.map((k,i)=>[k,C[i]]));
const SKU='DWJS-91508'; // next available
const title=`${r.pattern_name}${r.colorway?' '+r.colorway:''} | Jeffrey Stevens`;
const handle=(`${r.pattern_name}-${r.colorway}-wallpaper-${r.export_sku}`).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'');
const price=(+r.new_price).toFixed(2);
const payload={
title, handle, vendor:'Jeffrey Stevens', productType:'Wallcovering', status:'DRAFT',
descriptionHtml:r.dynamic_description||'',
options:[{name:'Size', values:['Sample','Sold Per Single Roll']}],
variants:[
{sku:`${SKU}-Sample`, price:'4.25', option:'Sample', inventoryPolicy:'CONTINUE'},
{sku:SKU, price, option:'Sold Per Single Roll', inventoryPolicy:'CONTINUE'}
],
image:r.image_url,
metafields_deterministic:{
'custom.manufacturer_sku':r.export_sku,'dwc.manufacturer_sku':r.export_sku,
'custom.pattern_name':r.pattern_name,'custom.collection_name':r.book_name,
'custom.brand_name':r.brand,'custom.parent_brand':r.parent_brand,
'custom.us_msrp':r.us_msrp,'custom.wholesale_price':r.wholesale,
'global.width':`${r.width_inches}" x ${r.length_feet} ft`,'custom.width':r.width_inches,
'global.length':`${r.length_feet} ft`,'global.repeat':r.pattern_repeat,'custom.pattern_repeat':r.pattern_repeat,
'global.MATCH':r.match_type,'custom.match_type':r.match_type,
'custom.backing':r.backing,'specs.coverage':r.coverage,'specs.style':r.marketing_style,'specs.pattern':r.marketing_pattern,
'custom.color_family':r.color_family,'global.unit_of_measure':'Priced Per Single Roll',
'global.v_prods_quantity_order_min':'2','global.v_prods_quantity_order_units':'2','global.packaged':'Shipped in Doubles'
},
ENRICHMENT_GAPS:{
color_hex_metafields:'NEEDS local PIL median-cut on image (custom.color_1_hex/pct, color_details json, color_hex, background_color) — $0 local, enrich-color-details-local pattern',
collections:'NEEDS routing logic → color/style/pattern/vendor collections (blue-wallpaper, modern, jeffrey-stevens, etc.) from color_family+marketing_style+pattern',
tags:'NEEDS derivation from color/style/material/pattern (exemplar had ~30 tags)',
settlement:'MUST run full settlement skill pre-publish (this item passed keyword pre-screen only)'
}
};
fs.writeFileSync('data/sample-create-payload.json',JSON.stringify(payload,null,2));
console.log(JSON.stringify(payload,null,2));