#!/usr/bin/env tsx /** * 批量随机美国地址对报价测试(直连 axel API) */ import { fetchAxelQuote } from "@/lib/axel/client"; const CASES = [ { id: "A", origin: "3131 Western Ave, Seattle, WA 98126", dest: "123 Main St, Los Angeles, CA 90001", pallets: 2, weightLb: 500, lengthIn: 48, widthIn: 40, heightIn: 45, }, { id: "B", origin: "233 S Wacker Dr, Chicago, IL 60606", dest: "1500 Marilla St, Dallas, TX 75201", pallets: 3, weightLb: 1200, lengthIn: 48, widthIn: 40, heightIn: 48, }, { id: "C", origin: "350 5th Ave, New York, NY 10118", dest: "191 Peachtree St NE, Atlanta, GA 30303", pallets: 1, weightLb: 350, lengthIn: 40, widthIn: 48, heightIn: 40, }, { id: "D", origin: "1701 Broadway, Denver, CO 80290", dest: "200 W Washington St, Phoenix, AZ 85003", pallets: 4, weightLb: 2000, lengthIn: 48, widthIn: 40, heightIn: 50, }, { id: "E", origin: "1 Faneuil Hall Sq, Boston, MA 02109", dest: "701 Brickell Ave, Miami, FL 33131", pallets: 2, weightLb: 800, lengthIn: 48, widthIn: 40, heightIn: 45, }, { id: "F", origin: "1120 NW Couch St, Portland, OR 97209", dest: "1600 Smith St, Houston, TX 77002", pallets: 5, weightLb: 3500, lengthIn: 48, widthIn: 48, heightIn: 55, }, { id: "G", origin: "3131 Western Ave, Seattle, WA", dest: "7000 NW 52nd St, Miami, FL", pallets: 4, weightLb: 723, lengthIn: 48, widthIn: 40, heightIn: 45, }, { id: "H", origin: "5678 Industrial Blvd, Austin, TX 78744", dest: "8900 E Hampden Ave, Denver, CO 80231", pallets: 2, weightLb: 650, lengthIn: 48, widthIn: 40, heightIn: 42, }, ] as const; async function main() { const results: unknown[] = []; for (const c of CASES) { process.stderr.write(`[batch] 正在询价 ${c.id}...\n`); try { const r = await fetchAxelQuote({ origin: c.origin, dest: c.dest, pallets: c.pallets, weightLb: c.weightLb, lengthIn: c.lengthIn, widthIn: c.widthIn, heightIn: c.heightIn, }); results.push({ caseId: c.id, input: { origin: c.origin, dest: c.dest, cargo: { pallets: c.pallets, weightLb: c.weightLb, dimsIn: { l: c.lengthIn, w: c.widthIn, h: c.heightIn }, }, }, selectedOrigin: { placeId: r.origin.placeId, description: r.origin.description, }, selectedDest: { placeId: r.dest.placeId, description: r.dest.description, }, quotes: r.items.map((item) => ({ serviceLevel: item.serviceLevel, rateOption: item.rateOption, carrier: item.carrier, transitDays: item.transitDays, rawTotal: item.rawTotal, rawFreight: item.rawFreight, surcharges: item.surcharges, })), ratesSummary: r.ratesSummary, }); } catch (err) { results.push({ caseId: c.id, input: c, error: err instanceof Error ? err.message : String(err), }); } } console.log(JSON.stringify({ generatedAt: new Date().toISOString(), cases: results }, null, 2)); } main();