feat: enhance README and improve product data handling in cache, llm, reader, and writer modules
This commit is contained in:
@@ -2,17 +2,25 @@ import * as XLSX from "xlsx";
|
||||
import type { AnalysisResult } from "./types.ts";
|
||||
|
||||
function buildRow(r: AnalysisResult) {
|
||||
const price = r.product.keepa?.currentPrice ?? r.product.spApi.estimatedSalePrice;
|
||||
const price =
|
||||
r.product.keepa?.currentPrice ??
|
||||
r.product.record.sellingPriceFromSheet ??
|
||||
r.product.spApi.estimatedSalePrice;
|
||||
const rank = r.product.keepa?.salesRank ?? r.product.record.amazonRank;
|
||||
|
||||
return {
|
||||
ASIN: r.product.record.asin,
|
||||
Name: r.product.record.name,
|
||||
Brand: r.product.record.brand ?? "",
|
||||
Category: r.product.record.category ?? r.product.keepa?.categoryTree?.join(" > ") ?? "",
|
||||
Category:
|
||||
r.product.record.category ??
|
||||
r.product.keepa?.categoryTree?.join(" > ") ??
|
||||
"",
|
||||
"Unit Cost": r.product.record.unitCost,
|
||||
"Current Price": price ?? "",
|
||||
"Avg Price 90d": r.product.keepa?.avgPrice90 ?? "",
|
||||
"Avg Price 90d (sheet)": r.product.record.avgPrice90FromSheet ?? "",
|
||||
"Selling Price (sheet)": r.product.record.sellingPriceFromSheet ?? "",
|
||||
"Sales Rank": rank ?? "",
|
||||
"Rank Avg 90d": r.product.keepa?.salesRankAvg90 ?? "",
|
||||
Sellers: r.product.keepa?.sellerCount ?? "",
|
||||
@@ -22,9 +30,17 @@ function buildRow(r: AnalysisResult) {
|
||||
"FBA Net (sheet)": r.product.record.fbaNet ?? "",
|
||||
"Gross Profit $": r.product.record.grossProfit ?? "",
|
||||
"Gross Profit %": r.product.record.grossProfitPct ?? "",
|
||||
"Net Profit (sheet)": r.product.record.netProfitFromSheet ?? "",
|
||||
"ROI (sheet)": r.product.record.roiFromSheet ?? "",
|
||||
MOQ: r.product.record.moq ?? "",
|
||||
"MOQ Cost": r.product.record.moqCost ?? "",
|
||||
"Qty Available": r.product.record.totalQtyAvail ?? "",
|
||||
Supplier: r.product.record.supplier ?? "",
|
||||
"Source URL": r.product.record.sourceUrl ?? "",
|
||||
"ASIN Link": r.product.record.asinLink ?? "",
|
||||
"Promo/Coupon Code": r.product.record.promoCouponCode ?? "",
|
||||
Notes: r.product.record.notes ?? "",
|
||||
"Lead Date": r.product.record.leadDate ?? "",
|
||||
"FBA Fee": r.product.spApi.fbaFee,
|
||||
"FBM Fee": r.product.spApi.fbmFee,
|
||||
"Referral %": r.product.spApi.referralFeePercent,
|
||||
@@ -53,10 +69,15 @@ export function printResults(results: AnalysisResult[]): void {
|
||||
FBM: results.filter((r) => r.verdict.verdict === "FBM").length,
|
||||
SKIP: results.filter((r) => r.verdict.verdict === "SKIP").length,
|
||||
};
|
||||
console.log(`\nSummary: ${summary.FBA} FBA | ${summary.FBM} FBM | ${summary.SKIP} SKIP out of ${results.length} products\n`);
|
||||
console.log(
|
||||
`\nSummary: ${summary.FBA} FBA | ${summary.FBM} FBM | ${summary.SKIP} SKIP out of ${results.length} products\n`,
|
||||
);
|
||||
}
|
||||
|
||||
export function writeResultsCsv(results: AnalysisResult[], outputPath: string): void {
|
||||
export function writeResultsCsv(
|
||||
results: AnalysisResult[],
|
||||
outputPath: string,
|
||||
): void {
|
||||
const rows = results.map(buildRow);
|
||||
|
||||
const ws = XLSX.utils.json_to_sheet(rows);
|
||||
|
||||
Reference in New Issue
Block a user