Repository navigation
feat(catalog): add WooCommerce connector (#1275) - #1789
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
@gkhngyk The latest PR head (aa536fa) is now fully green in GitHub Actions: server lint/format/tests, web format/lint/typecheck/Vitest/production build, schema consistency, and migration guard all passed. The branch includes current upstream main and GitHub reports it mergeable. Could you please review when you have a chance? The PR description includes the local WooCommerce acceptance counts and the security checklist. |
|
@gkhngyk Final validation update for the current PR head b2edc53: GitHub Actions is fully green — server lint/format/tests, web Prettier/ESLint/typecheck/Vitest/Next.js production build, schema consistency, and migration guard all passed. Vercel is also successful, and GitHub reports the branch mergeable with no conflicts. The only remaining merge gate shown by branch protection is one approving maintainer review. The PR description has the final merged-tree test counts and the local WooCommerce acceptance/security details. |
…ing and drop a store's orders with it - Rename 00407_catalog_orders.sql to 00384 (00400-00449 is the Chat block) and rebuild schema.sql. - Remove a store's orders when the store is removed (catalog_sources_forget). - Ask WooCommerce to compare the cursor with GMT modified times (dates_are_gmt). - Read at most 100 order pages a sync and move the cursor to the last change read, so a large store catches up instead of rereading the same pages. - Keep only normalized orders past each page. - Send the whole row in the completing upsert (placed_at is NOT NULL), write an order listed twice once, and read back only the orders being written. - An order read that fails leaves the catalog's outcome and the cursor as they were.
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks for the connector. Approving with one commit on top (63a0ec1), pushed to this branch, covering the points from the last review:
- The migration is numbered 00384 (00400–00449 is reserved), and
schema.sqlis rebuilt. catalog_sources_forgetalso deletes a removed store's orders; their lines go by cascade.- The order cursor sends
dates_are_gmt: true, the order read is capped, and the cursor moves to the last change read. - The completing upsert sends the whole row, an order listed twice in one read is written once, existing orders are read back only for the ids being written, and only normalized orders are kept between pages.
- A failed order read is logged, leaves the cursor as it was and keeps the source's outcome for the products it saved.
Each change has a test that fails without it. We'll merge after a manual check against a real store.
…ts failure The order sync reused the catalog read's client, whose single deadline started before the products were read, so a large store's order read ran out of time after the products and the cursor never moved. The orders now get a fresh deadline, and a failed order read keeps its reason (and whether it timed out) in the source's order counts next to the warning log.
…riations The product listing sent no status, so WooCommerce's default (any) also returned draft, pending and private products, and switched-off variations came back as private: all saved as live products with pages shoppers can't open. The listing now asks for status=publish, and a product or variation whose status isn't publish is skipped, so one taken off the store is marked removed by the next sync.
gkhngyk
left a comment
There was a problem hiding this comment.
Approving again with c421b19: two fixes on top, described below.
-
Only published products and enabled variations (
server/src/connectors/woocommerce/index.js). The product listing didn't send astatus, and WooCommerce's default isany, so draft, pending and private products came back too. Switched-off variations come back asprivate. All of them were saved as live products, with links shoppers can't open. The listing now asks forstatus=publish, and any product or variation whose status isn'tpublishis skipped. Rows with no status at all are still kept. A product taken off the store now drops out of the snapshot, so the next sync marks it removed. Test:keeps only published products and enabled variations. -
The order read gets its own deadline (
server/src/lib/catalog/sources.js). The order sync reused the catalog read's client, and that client's singleSTORE_READ_MSdeadline started before the products were read. On a large store, the products could use up the whole budget, so the order read timed out every run, the cursor never moved, and the only trace was a warning. The orders now get a fresh deadline (withDeadline). A failed order read still leaves the catalog'sokoutcome and the cursor alone, as before. It now also keeps a plain-wordserror(andtimedOut: truewhen time ran out) incounts.orders, next to the existing warning log. Tests: two newsyncSourcestore cases (an order read that only fits with its own budget, and an order read that times out). The existing WooCommerce order-failure test now expects theerrorfield.
Thanks again for the careful work on this connector!
Summary
Related issue
Closes #1275
Verification on the merged tree
npm run lint— passed.npm run format:check— passed.npm test— 330 test files passed; 4,484 tests passed, 3 skipped.bash supabase/build-schema.sh— regenerated from 320 migration files.The local acceptance run used a disposable wp-env WordPress/WooCommerce instance, a self-signed local certificate and test-only credentials. The isolated test process accepted that certificate only to reach localhost; no production TLS validation or transport code was weakened, and no merchant credentials were used.
Security review checklist
Webhooks
Webhook support is optional in #1275. The connector validates the raw-body HMAC-SHA256 signature and normalizes supported order/product event metadata; the shared HTTP receiver/dispatch route is not part of this change, so scheduled and on-demand sync remain the source of truth.
Upstream merge
Merged current upstream
main, including the plan-row boundary fix from #1796 that resolves the web production-build failure. Kept the order-sync cursor alongside upstream's demo-brand source exclusion. The new order tables are explicitly excluded from synthetic demo data: the demo catalog is built from a product feed and must not invent merchant purchase history.