← back to Dw Activation Debug TK11314
scripts/probe-vision-service.js
33 lines
#!/usr/bin/env node
'use strict';
// One existing-provider review of a known held draft. No Shopify mutations,
// publication, credential writes, fallback changes or quota/billing changes.
const fs = require('node:fs');
const path = require('node:path');
const os = require('node:os');
const { SettlementGate } = require('/Users/macstudio3/Projects/dw-rotation-activator/lib/settlement-gate.js');
const output = process.argv[2];
if (!output) throw new Error('Usage: probe-vision-service.js <evidence-json>');
const id = 'gid://shopify/Product/7799066066995';
const env = fs.readFileSync(path.join(os.homedir(), 'Projects/secrets-manager/.env'), 'utf8');
const token = (env.match(/^SHOPIFY_ADMIN_TOKEN=(.*)$/m) || [])[1]?.trim().replace(/^['"]|['"]$/g, '');
async function main() {
const query = 'query($id:ID!){product(id:$id){id title vendor status images(first:1){nodes{url}}}}';
const response = await fetch('https://designer-laboratory-sandbox.myshopify.com/admin/api/2026-07/graphql.json', {
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Shopify-Access-Token': token },
body: JSON.stringify({ query, variables: { id } }), signal: AbortSignal.timeout(30000),
});
const json = await response.json();
if (!response.ok || json.errors || json.data?.product?.status !== 'DRAFT') throw new Error('Expected held draft unavailable');
const product = json.data.product;
const gate = new SettlementGate();
const result = await gate.evaluate({ shopify_id: id, dw_sku: 'DWGC-200002',
title: product.title, vendor: product.vendor, material: '', imageUrl: product.images.nodes[0]?.url });
const report = { timestamp: new Date().toISOString(), product_id: id, sku: 'DWGC-200002',
result, stats: gate.stats(), shopify_mutations: 0, credentials_or_billing_changed: false };
fs.mkdirSync(path.dirname(output), { recursive: true });
fs.writeFileSync(output, JSON.stringify(report, null, 2) + '\n');
console.log(JSON.stringify(report));
}
main().catch(error => { console.error(error.message); process.exitCode = 1; });