Refactor SP-API test script and improve type definitions
- Updated `sp-test.ts` to enhance argument parsing and error handling for sellability checks. - Refactored `types.ts` to maintain consistent formatting and improve readability. - Improved `writer.ts` for better result handling and CSV writing, ensuring clarity in output. - Adjusted `tsconfig.json` formatting for consistency and readability.
This commit is contained in:
150
src/types.ts
150
src/types.ts
@@ -1,75 +1,75 @@
|
||||
export interface ProductRecord {
|
||||
asin: string;
|
||||
name: string;
|
||||
unitCost: number;
|
||||
brand?: string;
|
||||
category?: string;
|
||||
amazonRank?: number;
|
||||
avgPrice90FromSheet?: number;
|
||||
sellingPriceFromSheet?: number;
|
||||
fbaNet?: number;
|
||||
grossProfit?: number;
|
||||
grossProfitPct?: number;
|
||||
netProfitFromSheet?: number;
|
||||
roiFromSheet?: number;
|
||||
moq?: number;
|
||||
moqCost?: number;
|
||||
totalQtyAvail?: number;
|
||||
|
||||
link?: string;
|
||||
asinLink?: string;
|
||||
sourceUrl?: string;
|
||||
supplier?: string;
|
||||
promoCouponCode?: string;
|
||||
notes?: string;
|
||||
leadDate?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface KeepaData {
|
||||
currentPrice: number | null;
|
||||
avgPrice90: number | null;
|
||||
minPrice90: number | null;
|
||||
maxPrice90: number | null;
|
||||
salesRank: number | null;
|
||||
salesRankAvg90: number | null;
|
||||
salesRankDrops30: number | null;
|
||||
salesRankDrops90: number | null;
|
||||
sellerCount: number | null;
|
||||
buyBoxSeller: string | null;
|
||||
buyBoxPrice: number | null;
|
||||
monthlySold: number | null;
|
||||
categoryTree: string[];
|
||||
}
|
||||
|
||||
export type SellabilityInfo = {
|
||||
canSell: boolean | null;
|
||||
sellabilityStatus: "available" | "restricted" | "not_available" | "unknown";
|
||||
sellabilityReason?: string;
|
||||
};
|
||||
|
||||
export interface SpApiData extends SellabilityInfo {
|
||||
fbaFee: number;
|
||||
fbmFee: number;
|
||||
referralFeePercent: number;
|
||||
estimatedSalePrice: number;
|
||||
}
|
||||
|
||||
export interface EnrichedProduct {
|
||||
record: ProductRecord;
|
||||
keepa: KeepaData | null;
|
||||
spApi: SpApiData;
|
||||
fetchedAt: string;
|
||||
}
|
||||
|
||||
export interface LlmVerdict {
|
||||
asin: string;
|
||||
verdict: "FBA" | "FBM" | "SKIP";
|
||||
confidence: number;
|
||||
reasoning: string;
|
||||
}
|
||||
|
||||
export interface AnalysisResult {
|
||||
product: EnrichedProduct;
|
||||
verdict: LlmVerdict;
|
||||
}
|
||||
export interface ProductRecord {
|
||||
asin: string;
|
||||
name: string;
|
||||
unitCost: number;
|
||||
brand?: string;
|
||||
category?: string;
|
||||
amazonRank?: number;
|
||||
avgPrice90FromSheet?: number;
|
||||
sellingPriceFromSheet?: number;
|
||||
fbaNet?: number;
|
||||
grossProfit?: number;
|
||||
grossProfitPct?: number;
|
||||
netProfitFromSheet?: number;
|
||||
roiFromSheet?: number;
|
||||
moq?: number;
|
||||
moqCost?: number;
|
||||
totalQtyAvail?: number;
|
||||
|
||||
link?: string;
|
||||
asinLink?: string;
|
||||
sourceUrl?: string;
|
||||
supplier?: string;
|
||||
promoCouponCode?: string;
|
||||
notes?: string;
|
||||
leadDate?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface KeepaData {
|
||||
currentPrice: number | null;
|
||||
avgPrice90: number | null;
|
||||
minPrice90: number | null;
|
||||
maxPrice90: number | null;
|
||||
salesRank: number | null;
|
||||
salesRankAvg90: number | null;
|
||||
salesRankDrops30: number | null;
|
||||
salesRankDrops90: number | null;
|
||||
sellerCount: number | null;
|
||||
buyBoxSeller: string | null;
|
||||
buyBoxPrice: number | null;
|
||||
monthlySold: number | null;
|
||||
categoryTree: string[];
|
||||
}
|
||||
|
||||
export type SellabilityInfo = {
|
||||
canSell: boolean | null;
|
||||
sellabilityStatus: "available" | "restricted" | "not_available" | "unknown";
|
||||
sellabilityReason?: string;
|
||||
};
|
||||
|
||||
export interface SpApiData extends SellabilityInfo {
|
||||
fbaFee: number;
|
||||
fbmFee: number;
|
||||
referralFeePercent: number;
|
||||
estimatedSalePrice: number;
|
||||
}
|
||||
|
||||
export interface EnrichedProduct {
|
||||
record: ProductRecord;
|
||||
keepa: KeepaData | null;
|
||||
spApi: SpApiData;
|
||||
fetchedAt: string;
|
||||
}
|
||||
|
||||
export interface LlmVerdict {
|
||||
asin: string;
|
||||
verdict: "FBA" | "FBM" | "SKIP";
|
||||
confidence: number;
|
||||
reasoning: string;
|
||||
}
|
||||
|
||||
export interface AnalysisResult {
|
||||
product: EnrichedProduct;
|
||||
verdict: LlmVerdict;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user