← back to Dw Signup Fulfillment
verification/tk10836/verify-rate-sources.js
33 lines
#!/usr/bin/env node
// TK-10836 Option D (2/n): where do "Free Shipping (No Tracking)" / "Priority Sample Only" come from?
const fs=require('fs'),os=require('os');
for (const line of fs.readFileSync(os.homedir()+'/Projects/secrets-manager/.env','utf8').split('\n')) {
const m=line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)$/); if(!m) continue;
let v=m[2].trim().replace(/^['"]|['"]$/g,''); if(!process.env[m[1]]) process.env[m[1]]=v;
}
const STORE=process.env.SHOPIFY_STORE_DOMAIN||'designer-laboratory-sandbox.myshopify.com';
const TOKEN=process.env.SHOPIFY_FULL_ACCESS_TOKEN, API='2024-10';
async function gql(query,variables={}){
const r=await fetch(`https://${STORE}/admin/api/${API}/graphql.json`,{method:'POST',
headers:{'X-Shopify-Access-Token':TOKEN,'Content-Type':'application/json'},
body:JSON.stringify({query,variables})});
const j=await r.json(); if(j.errors)console.error('ERR',JSON.stringify(j.errors));
return j.data;
}
(async()=>{
console.log('### CARRIER SERVICES (REST) ###');
const r=await fetch(`https://${STORE}/admin/api/${API}/carrier_services.json`,{headers:{'X-Shopify-Access-Token':TOKEN}});
const cs=await r.json();
for(const c of (cs.carrier_services||[])) console.log(` - ${c.name} | active=${c.active} | type=${c.carrier_service_type} | svcDiscovery=${c.service_discovery} | url=${c.callback_url}`);
console.log('\n### DELIVERY CUSTOMIZATIONS (functions that hide/rename/reorder rates) ###');
const d=await gql(`query { deliveryCustomizations(first: 25) { nodes { id title enabled functionId } } }`);
const dc=d?.deliveryCustomizations?.nodes||[];
if(!dc.length) console.log(' (none)');
for(const n of dc) console.log(` - ${n.title} | enabled=${n.enabled} | fn=${n.functionId}`);
console.log('\n### SHOPIFY FUNCTIONS INSTALLED ###');
const f=await gql(`query { shopifyFunctions(first: 30) { nodes { id title apiType app { title } } } }`);
for(const n of (f?.shopifyFunctions?.nodes||[])) console.log(` - [${n.apiType}] ${n.title} | app=${n.app?.title} | ${n.id}`);
})();