Repository navigation
feat(importer): read-only Item migration inventory report (#1148) - #1168
Conversation
Runs the M0 checks of the Item / variant / listing design (section 7.3) over the anon-readable tables, and runs today's ProductNormalizer on each seed, master name and listing title to find key drift, which SQL cannot. SELECTs only, with the anon key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NULL brand or category is not an Item conflict, as in SQL count(DISTINCT). TB and suffixed variant keys count as sized. Slug checks now also flag an Item whose masters strip to different slugs and a slug still sized after stripping. Listings with no stated size get their own drift bucket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #1148
What
apps/importer/src/shopee/jobs/item-inventory-report.ts: the M0 inventory of the Item / variant / listing design (#1129,Docs/Proposals/2026-10-27-item-variant-listing-model.mdsection 7.3), as a re-runnable, read-only report. It is meant to be run again after M2 and M3.categories,master_productsandproductswith the anon key (SUPABASE_URL+SUPABASE_ANON_KEY, or theNEXT_PUBLIC_pair). It does SELECTs only, has no write path and never reads the secret key.khc:,unknownand status counts, Item brand/category conflicts, sized earbuds, and listings without a master.ProductNormalizeron every seed, master name and listing title. That is how seed key drift shows up, which SQL cannot do. Listing drift is bucketed asitem,variantorsize_not_stated.The run results and the data-fix list are posted on #1148 and #1150.
Tests
src/shopee/__tests__/item-inventory-report.test.ts, wired into the importertestscript. It covers every report section, the NULL-brand and TB cases, and thesplit_partkey semantics.pnpm typecheck, eslint and prettier pass on the changed files.Review gate
🤖 Generated with Claude Code
📌 TL;DR
This PR introduces a read-only inventory audit tool (
item-inventory-report) to validate data integrity for the Item/Variant migration (#1148), checking for key shape violations, slug collisions, and normalization drift. It also adds a comprehensive test suite to verify the report generation logic against edge cases.🎯 Type of Change
🔍 Changes Walkthrough
apps/importer/package.jsontestscript to include the newitem-inventory-report.test.tsin the test execution chain.apps/importer/src/shopee/jobs/item-inventory-report.tsbuildInventoryReportwhich analyzes categories, masters, and listings for conflicts, drift, and shape errors. Includes a CLI entry point to fetch data from Supabase (read-only) and output a JSON report.apps/importer/src/shopee/__tests__/item-inventory-report.test.tsitemKeyOf,itemSlugOf, etc.) and asserts the correctness of the report output for complex scenarios involving legacy keys, slug collisions, storage mismatches, and normalization drift.📊 Architectural Flow
flowchart TD subgraph CLI_Entry A[Direct Execution Check] --> B[Load Env Vars] B --> C[Create Supabase Client<br/>Anon Key Only] end subgraph Data_Fetch C --> D[loadInventory] D --> E[Fetch Categories] D --> F[Fetch Master Products] D --> G[Fetch Listings] end subgraph Analysis E & F & G --> H[buildInventoryReport] H --> I[Normalize Keys/Slugs] H --> J[Check Shape & Legacy] H --> K[Detect Conflicts & Drift] H --> L[Identify Slug Collisions] end subgraph Output I & J & K & L --> M[Generate JSON Report] M --> N[Write to stdout] end