import fs from "node:fs";
import { BASELINE_HAR } from "./lib/paths";
import { countAxelQuoteTiers, extractAxelQuoteContract } from "./lib/axel-quote-contract";

const har = JSON.parse(fs.readFileSync(BASELINE_HAR, "utf8")) as {
  log?: { entries?: Array<{ request: { url: string }; response: { content?: { text?: string } } }> };
};
const entry = har.log?.entries?.find((e) => e.request.url.includes("axel/quote"));
if (!entry?.response.content?.text) {
  console.log("no axel/quote");
  process.exit(1);
}
const body = JSON.parse(entry.response.content.text) as unknown;
const contract = extractAxelQuoteContract(body);
console.log(JSON.stringify(contract, null, 2));
