Feat/storefront data prodcut lists - #435
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis pull request introduces comprehensive product-lists domain support to the storefront-data library. It adds domain types, service implementations, React hooks, query infrastructure, and full integration into the Medusa storefront preset system, along with documentation and package manifest updates. ChangesProduct-lists domain implementation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: dependency version conflict. Check your lock file or package.json. 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 |
Greptile SummaryThis PR adds a complete
Confidence Score: 5/5Safe to merge; all previously flagged blocking issues (conflict markers, missing type exports) are resolved in the current HEAD, and the new product-lists domain follows the established factory patterns correctly. The product-lists domain is a clean additive feature that mirrors the existing hook factory structure throughout the library. The core read/mutation/prefetch hooks, Medusa service, query-options factory, and type system are all internally consistent. Previously unresolved issues (merge conflicts in foundation.ts/preset.ts/medusa.preset.test.tsx, missing Key types in medusa-service.ts) have been addressed. One minor inconsistency in null handling for quantity in updateProductListItem is the only new finding and does not affect correctness of the primary flows. libs/storefront-data/src/product-lists/medusa-service.ts — the null-quantity handling in updateProductListItem differs from the other nullable fields in the same body. Important Files Changed
Sequence DiagramsequenceDiagram
participant App as App / Preset
participant Factory as createProductListHooks()
participant SVC as ProductListService
participant RQ as TanStack Query
participant BE as Backend /store/product-lists
App->>Factory: "createProductListHooks({ service, queryKeys, cacheConfig, ... })"
Factory-->>App: "{ useProductLists, useProductList, useSuspenseProductList, usePrefetchProductLists, useCreateFavoriteProductList, useAddProductListItem, useCreateProductListCart, ... }"
Note over App,BE: Read flow (useProductLists)
App->>RQ: "useQuery({ queryKey: keys.list({...customerId}), queryFn, ...userData })"
RQ->>SVC: listProductLists(params, signal)
SVC->>BE: "GET /store/product-lists?limit=20&offset=0"
BE-->>SVC: "{ product_lists: [...], count, limit, offset }"
SVC-->>RQ: normalizeProductListsResponse(response)
RQ-->>App: "{ productLists, count, limit, offset }"
Note over App,BE: Mutation flow (useAddProductListItem)
App->>RQ: "mutate({ listId, productId, variantId, quantity })"
RQ->>SVC: addProductListItem(input)
SVC->>BE: "POST /store/product-lists/{listId}/items"
BE-->>SVC: "{ product_list_item: {...} }"
SVC-->>RQ: resolveProductListItemFromResponse(response)
RQ->>RQ: invalidateQueries(keys.all())
RQ-->>App: "{ data: item }"
Note over App,BE: Cart creation (useCreateProductListCart)
App->>RQ: "mutate({ listId, regionId })"
RQ->>SVC: createProductListCart(input)
SVC->>BE: "POST /store/product-lists/{listId}/cart"
BE-->>SVC: "{ cart: {...} }"
SVC-->>RQ: transformCart(cart)
RQ->>RQ: syncCartCaches + invalidate cartQueryKeys.all()
RQ->>RQ: cartStorage.set(cart.id)
RQ-->>App: cart
Reviews (5): Last reviewed commit: "refactor: clean up product list storefro..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 10
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@libs/storefront-data/package.json`:
- Around line 244-250: The package.json contains unresolved Git merge conflict
markers (<<<<<<<, =======, >>>>>>>) that break JSON parsing; remove the conflict
markers and restore a valid JSON object, keeping the
"./product-lists/query-options" export entry (with its "types" and "import"
fields) as expected by regression.catalog-customers-exports.test.tsx; update the
exports map in package.json to a well-formed JSON entry for
"./product-lists/query-options" and ensure there are no leftover conflict tokens
elsewhere in the file.
- Around line 232-258: Remove the leftover merge conflict markers (<<<<<<<,
=======, >>>>>>>) around the product-lists exports and add a proper export entry
for "./product-lists/query-options" matching the other product-lists entries:
set "types" to "./dist/src/product-lists/query-options.d.ts" and "import" to
"./dist/product-lists/query-options.js", ensure JSON punctuation (commas/braces)
stays valid and the shape aligns with other domains like catalog/orders.
In `@libs/storefront-data/src/medusa/foundation.ts`:
- Around line 42-49: Remove the unresolved git merge conflict markers and keep
the "Stashed changes" variant of the imports and generics (use
MedusaProductListDetailKeyInput and MedusaProductListListKeyInput) wherever the
conflict blocks appear (including the blocks around the current import lines and
the other two conflict regions around lines indicated in the review); delete the
<<<<<<<, =======, and >>>>>>> markers and any duplicated old imports
(MedusaProductListDetailInput/MedusaProductListListInput) so the file
consistently imports and uses MedusaProductListDetailKeyInput and
MedusaProductListListKeyInput to match server-read.ts.
In `@libs/storefront-data/src/medusa/preset.ts`:
- Around line 126-147: The file contains unresolved git conflict markers; remove
all conflict markers (<<<<<<<, =======, >>>>>>>) and choose the imports and
types consistent with server-read.ts: keep createMedusaProductListService plus
the detailed type set including MedusaProductListListKeyInput,
MedusaProductListDetailKeyInput, MedusaProductListListHookInput,
MedusaProductListDetailHookInput and MedusaProductListServiceConfig from
product-lists/medusa-service, while retaining createProductListHooks,
CreateProductListHooksConfig, and ProductListHooks from product-lists/hooks;
apply the same resolution for all other conflicted blocks (lines noted in the
review) so usages of createMedusaProductListService, createProductListHooks,
ProductListHooks, CreateProductListHooksConfig and the MedusaProductList* types
compile correctly.
In `@libs/storefront-data/src/product-lists/hooks.ts`:
- Around line 516-539: The useSuspenseProductList hook calls
getDetailQueryOptions without ensuring input.id, which can cause the suspense
query to throw; update useSuspenseProductList to validate that input.id is
present before creating the query (mirror useProductList’s enabled guard) or
tighten the SuspenseDetailInput type to require id (e.g., make id: string) so
the runtime cannot pass a falsy id; adjust getDetailQueryOptions usage in
useSuspenseProductList accordingly to avoid constructing a suspense query when
id is missing.
In `@libs/storefront-data/src/product-lists/medusa-service.ts`:
- Around line 55-67: normalizeQuantityDelta currently returns 1 for
invalid/non-finite input while normalizeQuantity returns undefined; make them
consistent by having normalizeQuantityDelta return undefined for non-number or
non-finite inputs (replace the early return of 1 with undefined) and adjust all
call sites that use normalizeQuantityDelta to handle an undefined result (apply
the desired default or validation there). Locate the function
normalizeQuantityDelta and the other normalizer normalizeQuantity and update
callers to either coalesce the undefined value to a default or explicitly
validate/throw before using the value.
In `@libs/storefront-data/tests/medusa.preset.test.tsx`:
- Around line 416-431: Resolve the merge conflict in the
customProductListQueryKeys declaration by removing the conflict markers and
selecting the correct key types; update the ProductListQueryKeys generic to use
the consistent key input types used elsewhere (either
MedusaProductListListKeyInput and MedusaProductListDetailKeyInput or
MedusaProductListListInput & { customerId?: string | null } and
MedusaProductListDetailInput & { customerId?: string | null }), then delete the
<<<<<<<, =======, and >>>>>>> lines so customProductListNamespace and
customProductListQueryKeys compile cleanly and match the rest of the codebase.
- Around line 33-40: There are unresolved Git merge conflict markers in the
import list — remove the conflict markers and pick one consistent pair of types
(either MedusaProductListDetailInput & MedusaProductListListInput or
MedusaProductListDetailKeyInput & MedusaProductListListKeyInput) that matches
the actual exported types from ../src/product-lists/medusa-service; update the
import to only include the chosen identifiers and then update any usages in this
test (medusa.preset.test.tsx) to use the selected symbol names (e.g.,
MedusaProductListDetailInput or MedusaProductListDetailKeyInput and
MedusaProductListListInput or MedusaProductListListKeyInput) so the code
compiles without conflict markers.
In `@libs/storefront-data/tests/regression.catalog-customers-exports.test.tsx`:
- Around line 291-294: The test fails because package.json contains unresolved
merge conflict markers that prevent the "./product-lists/query-options" export
from being present; open package.json, remove the conflict markers and merge the
competing sections so that packageJson.exports includes the
"./product-lists/query-options" key with { types:
"./dist/src/product-lists/query-options.d.ts", import:
"./dist/product-lists/query-options.js" } (or the correct consolidated paths),
save the clean JSON and re-run tests to verify the assertion in the test
referencing packageJson.exports["./product-lists/query-options"] passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 925324e4-66fb-4a8e-9cef-5a51c01e79c5
📒 Files selected for processing (17)
libs/storefront-data/AGENTS.mdlibs/storefront-data/README.mdlibs/storefront-data/package.jsonlibs/storefront-data/src/medusa/foundation.tslibs/storefront-data/src/medusa/preset.tslibs/storefront-data/src/medusa/server-read.tslibs/storefront-data/src/product-lists/hooks.tslibs/storefront-data/src/product-lists/medusa-service.tslibs/storefront-data/src/product-lists/query-keys.tslibs/storefront-data/src/product-lists/query-options.tslibs/storefront-data/src/product-lists/types.tslibs/storefront-data/src/product-lists/utils.tslibs/storefront-data/tests/medusa.preset.test.tsxlibs/storefront-data/tests/medusa.server-read.test.tslibs/storefront-data/tests/product-lists.medusa-service.test.tslibs/storefront-data/tests/product-lists.utils.test.tslibs/storefront-data/tests/regression.catalog-customers-exports.test.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Greptile Review
- GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (7)
libs/storefront-data/*.md
📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)
Edit only
libs/storefront-data/AGENTS.mdfor documentation -CLAUDE.mdis a symlink and should not be edited directly
Files:
libs/storefront-data/README.mdlibs/storefront-data/AGENTS.md
libs/storefront-data/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)
Never import from
./dist/paths - use source imports insteadNever mix server/client code in the same file - keep server and client code separated
Files:
libs/storefront-data/src/product-lists/query-keys.tslibs/storefront-data/tests/product-lists.utils.test.tslibs/storefront-data/tests/product-lists.medusa-service.test.tslibs/storefront-data/tests/regression.catalog-customers-exports.test.tsxlibs/storefront-data/src/product-lists/utils.tslibs/storefront-data/tests/medusa.server-read.test.tslibs/storefront-data/src/product-lists/types.tslibs/storefront-data/src/medusa/foundation.tslibs/storefront-data/src/product-lists/medusa-service.tslibs/storefront-data/src/medusa/preset.tslibs/storefront-data/src/product-lists/hooks.tslibs/storefront-data/src/medusa/server-read.tslibs/storefront-data/tests/medusa.preset.test.tsxlibs/storefront-data/src/product-lists/query-options.ts
libs/storefront-data/**/*.{ts,tsx}
📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)
Never use
anytype - use proper generics insteadNever hardcode query keys - use
createQueryKey()utility insteadUse TanStack Query 5+ for all data fetching, caching, and SSR hydration
Files:
libs/storefront-data/src/product-lists/query-keys.tslibs/storefront-data/tests/product-lists.utils.test.tslibs/storefront-data/tests/product-lists.medusa-service.test.tslibs/storefront-data/tests/regression.catalog-customers-exports.test.tsxlibs/storefront-data/src/product-lists/utils.tslibs/storefront-data/tests/medusa.server-read.test.tslibs/storefront-data/src/product-lists/types.tslibs/storefront-data/src/medusa/foundation.tslibs/storefront-data/src/product-lists/medusa-service.tslibs/storefront-data/src/medusa/preset.tslibs/storefront-data/src/product-lists/hooks.tslibs/storefront-data/src/medusa/server-read.tslibs/storefront-data/tests/medusa.preset.test.tsxlibs/storefront-data/src/product-lists/query-options.ts
libs/storefront-data/**/AGENTS.md
📄 CodeRabbit inference engine (libs/storefront-data/CLAUDE.md)
libs/storefront-data/**/AGENTS.md: Document agent definitions and configurations in AGENTS.md
Maintain an up-to-date AGENTS.md file documenting all agents in the system
Files:
libs/storefront-data/AGENTS.md
libs/storefront-data/src/**/types.{ts,tsx}
📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)
Always type service interfaces with generics for product/collection/category/region/auth/cart/checkout/order/customer/product-list services
Files:
libs/storefront-data/src/product-lists/types.ts
**/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
Use pnpm CLI to add dependencies; never edit package.json directly
Files:
libs/storefront-data/package.json
libs/storefront-data/src/**/*hooks.{ts,tsx}
📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)
Always use factory pattern for creating hooks (
createProductHooks,createCollectionHooks, etc.)Always use cache strategies from
CacheConfig(static, semiStatic, realtime, userData) when configuring TanStack Query
Files:
libs/storefront-data/src/product-lists/hooks.ts
🧠 Learnings (3)
📚 Learning: 2025-12-16T19:45:17.746Z
Learnt from: BleedingDev
Repo: NMIT-WR/new-engine PR: 207
File: libs/ui/src/molecules/select.tsx:50-50
Timestamp: 2025-12-16T19:45:17.746Z
Learning: When reviewing Tailwind classes in TSX/TS files, prefer using square brackets for arbitrary CSS values and complex expressions. Specifically: - Do not use the parentheses syntax (z-(--z-index)) for anything beyond simple CSS variable references; this syntax auto-wraps in var() and cannot handle calc or complex functions. - Use the square brackets syntax (e.g., h-[calc(var(--available-height)-var(--spacing-content))]) for calc expressions, var with calc, and any complex CSS expressions. This rule applies broadly to Tailwind v4 usage in TSX code across the project.
Applied to files:
libs/storefront-data/tests/regression.catalog-customers-exports.test.tsxlibs/storefront-data/tests/medusa.preset.test.tsx
📚 Learning: 2026-02-05T14:43:17.404Z
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 324
File: apps/medusa-be/package.json:0-0
Timestamp: 2026-02-05T14:43:17.404Z
Learning: Validate and enforce React 19 compatibility across monorepo workspaces. Since Medusa UI supports React 19 via root package.json overrides and Medusa Cloud prerequisites show React 19 overrides for npm workspaces, ensure workspace root and all relevant package.json files align with React 19 (18+ requirement is satisfied). When reviewing, verify that overrides exist in the root package.json and that dependent packages in apps or packages directories declare React 19 (or compatible) in their peerDependencies or dependencies as appropriate for workspace usage.
Applied to files:
libs/storefront-data/package.json
📚 Learning: 2026-05-07T19:05:58.339Z
Learnt from: redeyecz
Repo: TechsioCZ/new-engine PR: 390
File: apps/medusa-be/package.json:78-81
Timestamp: 2026-05-07T19:05:58.339Z
Learning: When reviewing changes to `package.json`, do not automatically flag dependency additions/removals as "manually edited" or as "bypassing the pnpm lockfile" just because the `package.json` diff shows only that file changed. First verify whether `pnpm-lock.yaml` is missing the corresponding entries. Since `pnpm add` updates both `package.json` and `pnpm-lock.yaml` together, legitimate changes can appear in the `package.json` diff while still being properly tracked in the lockfile.
Applied to files:
libs/storefront-data/package.json
🪛 GitHub Actions: CI / 0_main.txt
libs/storefront-data/package.json
[error] 244-244: pnpm install --frozen-lockfile failed: ERR_PNPM_JSON_PARSE Expected double-quoted property name in JSON at position 8289 (line 244 column 1) while parsing '{ "name": "@techsio/storefront-data",'.
🪛 GitHub Actions: CI / main
libs/storefront-data/package.json
[error] 244-244: pnpm install --frozen-lockfile failed: ERR_PNPM_JSON_PARSE Expected double-quoted property name in JSON at position 8289 (line 244 column 1) while parsing '{ "name": "@techsio/storefront-data",'.
🔇 Additional comments (29)
libs/storefront-data/src/product-lists/types.ts (1)
1-264: LGTM!libs/storefront-data/src/product-lists/utils.ts (1)
1-101: LGTM!libs/storefront-data/tests/product-lists.utils.test.ts (1)
1-63: LGTM!libs/storefront-data/src/product-lists/hooks.ts (3)
1-393: LGTM!
394-515: LGTM!
540-863: LGTM!libs/storefront-data/AGENTS.md (1)
35-35: LGTM!libs/storefront-data/README.md (1)
174-179: LGTM!Also applies to: 189-189
libs/storefront-data/src/product-lists/query-keys.ts (1)
1-28: LGTM!libs/storefront-data/src/product-lists/query-options.ts (1)
1-226: LGTM!libs/storefront-data/src/medusa/server-read.ts (7)
56-76: LGTM!
140-159: LGTM!
217-248: LGTM!
272-284: LGTM!
344-344: LGTM!
382-386: LGTM!
469-470: LGTM!Also applies to: 490-495, 531-537
libs/storefront-data/src/medusa/preset.ts (3)
307-313: LGTM!
798-799: LGTM!Also applies to: 824-829
901-906: LGTM!libs/storefront-data/tests/medusa.server-read.test.ts (4)
6-10: LGTM!
35-48: LGTM!
87-131: LGTM!
135-136: LGTM!Also applies to: 152-166
libs/storefront-data/src/product-lists/medusa-service.ts (3)
186-207: LGTM!
209-223: LGTM!
320-341: LGTM!libs/storefront-data/tests/product-lists.medusa-service.test.ts (1)
1-127: LGTM!libs/storefront-data/tests/medusa.preset.test.tsx (1)
497-568: LGTM!
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Changed Files
Resolved Findings From Prior Review
Files Reviewed (2 paths)
Reviewed by step-3.7-flash-20260528 · 487,156 tokens |
Summary by CodeRabbit
Release Notes