Skip to content

Refactor/herbatica implement storefront data changes - #436

Merged
KaiUweCZE merged 9 commits into
masterfrom
refactor/herbatica-implement-storefront-data-changes
Jun 10, 2026
Merged

Refactor/herbatica implement storefront data changes#436
KaiUweCZE merged 9 commits into
masterfrom
refactor/herbatica-implement-storefront-data-changes

Conversation

@KaiUweCZE

@KaiUweCZE KaiUweCZE commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Full product-list support: favourites and custom lists, manage items (quantity, notes, metadata) and create carts from a list
    • Consistent loading UX: unified skeleton for product-list item loading
  • Refactor

    • Product-list logic centralised into the shared storefront-data layer for consistent behaviour and query caching
  • Tests

    • Added extensive tests covering product-list hooks, services, queries and cart creation

@semanticdiff-com

semanticdiff-com Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  apps/herbatika/src/lib/storefront/product-lists.ts  22% smaller
  libs/storefront-data/package.json  10% smaller
  apps/herbatika/src/components/product-lists/product-list-tabs.tsx  7% smaller
  apps/herbatika/src/components/product-lists/use-account-product-lists.ts  0% smaller
  apps/herbatika/src/lib/storefront/product-lists.client.ts  0% smaller
  apps/herbatika/src/lib/storefront/product-lists.types.ts  0% smaller
  apps/herbatika/src/lib/storefront/storefront-config.ts  0% smaller
  apps/herbatika/src/lib/storefront/storefront-core-definition.ts  0% smaller
  apps/herbatika/src/lib/storefront/storefront-server.ts  0% smaller
  apps/herbatika/src/lib/storefront/storefront.ts  0% smaller
  libs/storefront-data/AGENTS.md Unsupported file format
  libs/storefront-data/README.md Unsupported file format
  libs/storefront-data/skills/audit-storefront-before-release/SKILL.md Unsupported file format
  libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/SKILL.md Unsupported file format
  libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/references/prefetch-and-pagination.md Unsupported file format
  libs/storefront-data/skills/decide-app-specific-overrides-vs-shared-platform/SKILL.md Unsupported file format
  libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/SKILL.md Unsupported file format
  libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/references/extension-recipe.md Unsupported file format
  libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md Unsupported file format
  libs/storefront-data/skills/implement-cart-and-checkout-platform-flows/SKILL.md Unsupported file format
  libs/storefront-data/skills/implement-ssr-prefetch-and-query-client-boundaries/SKILL.md Unsupported file format
  libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md Unsupported file format
  libs/storefront-data/skills/setup-storefront-platform-in-next-app/SKILL.md Unsupported file format
  libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md Unsupported file format
  libs/storefront-data/skills/use-storefront-data-skills/SKILL.md Unsupported file format
  libs/storefront-data/src/medusa/foundation.ts  0% smaller
  libs/storefront-data/src/medusa/preset.ts  0% smaller
  libs/storefront-data/src/medusa/server-read.ts  0% smaller
  libs/storefront-data/src/product-lists/hooks.ts  0% smaller
  libs/storefront-data/src/product-lists/input-utils.ts  0% smaller
  libs/storefront-data/src/product-lists/medusa-service.ts  0% smaller
  libs/storefront-data/src/product-lists/query-keys.ts  0% smaller
  libs/storefront-data/src/product-lists/query-options.ts  0% smaller
  libs/storefront-data/src/product-lists/types.ts  0% smaller
  libs/storefront-data/src/product-lists/utils.ts  0% smaller
  libs/storefront-data/src/shared/object-utils.ts  0% smaller
  libs/storefront-data/tests/medusa.preset.test.tsx  0% smaller
  libs/storefront-data/tests/medusa.server-read.test.ts  0% smaller
  libs/storefront-data/tests/product-lists.hooks.test.tsx  0% smaller
  libs/storefront-data/tests/product-lists.medusa-service.test.ts  0% smaller
  libs/storefront-data/tests/product-lists.utils.test.ts  0% smaller
  libs/storefront-data/tests/regression.catalog-customers-exports.test.tsx  0% smaller
  pnpm-lock.yaml  0% smaller

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
new-engine-ui-storybook Ready Ready Preview, Comment Jun 10, 2026 3:30pm

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds a full product-lists domain to @techsio/storefront-data (types, Medusa service, query-keys/options, React Query hooks, utils), integrates it into the Medusa preset/server-read and Herbatika storefront, removes the app-local product-lists client/types, and adds tests and docs.

Changes

Product Lists Domain & Integration

Layer / File(s) Summary
Product lists types and utility contracts
libs/storefront-data/src/product-lists/types.ts, libs/storefront-data/src/product-lists/utils.ts, libs/storefront-data/src/shared/object-utils.ts
ProductListType (favorite/custom) and ProductListAccessType (private/public) unions; ProductListItemBase and ProductListBase; generic response/result wrappers; CRUD input shapes; ProductListService/hook contracts. Utilities for items, counts, favourite detection, ID extraction, quantity normalisation, and selection matching.
Medusa service and response normalisation
libs/storefront-data/src/product-lists/medusa-service.ts
createMedusaProductListService SDK wrapper with quantity normalisation, list/detail CRUD, item add/update/change/increment/delete, and cart creation. Response helpers normalise alternative backend field names.
Query keys and query options factories
libs/storefront-data/src/product-lists/query-keys.ts, libs/storefront-data/src/product-lists/query-options.ts
createProductListQueryKeys (all/list/detail) with enabled-omission; createProductListQueryOptionsFactory builds TanStack query options with pagination, cache strategy, customer scoping, and runtime detail-id validation.
React Query hooks factory
libs/storefront-data/src/product-lists/hooks.ts
createProductListHooks exposes query-option builders, list/detail (non-suspense and suspense) hooks, multi-detail via useQueries, prefetch helpers, and mutation hooks. Cart mutation supports cache sync and optional cart-storage persistence; mutations invalidate product-list queries on success.
Input helpers
libs/storefront-data/src/product-lists/input-utils.ts
stripListInput, stripDetailInput, createDefaultListParams, and withCustomerScope for normalising params used by query-options and services.
Medusa foundation and preset integration
libs/storefront-data/src/medusa/foundation.ts, libs/storefront-data/src/medusa/preset.ts
Extend MedusaStorefrontQueryKeys with productLists; preset config gains optional productLists section (service/serviceConfig/hooks/queryKeys); runtime wiring creates services via createMedusaProductListService and hooks via createProductListHooks; auth invalidation includes queryKeys.productLists.all().
Server-read preset configuration
libs/storefront-data/src/medusa/server-read.ts
CreateMedusaStorefrontServerReadPresetConfig and server-read preset extended to accept productLists (service/serviceConfig/hooks/queryKeys) and create SSR query-options for product-lists.
Package exports and documentation
libs/storefront-data/package.json, libs/storefront-data/README.md, libs/storefront-data/AGENTS.md
Add ./product-lists/* subpath exports (hooks, medusa-service, query-keys, query-options, types, utils); update README/AGENTS; include skills in published files; bump dev deps @medusajs/js-sdk/@medusajs/types.
Herbatika storefront configuration wiring
apps/herbatika/src/lib/storefront/storefront-config.ts, apps/herbatika/src/lib/storefront/storefront-core-definition.ts, apps/herbatika/src/lib/storefront/storefront-server.ts, apps/herbatika/src/lib/storefront/storefront.ts
Register and wire productLists query-keys into storefront config, core definition, server preset, and the exported storefront preset.
Herbatika storefront product-lists hooks
apps/herbatika/src/lib/storefront/product-lists.ts
Replace local React Query implementations and client functions with delegators to storefront.hooks.productLists; re-export shared types; add small selector helpers delegating to shared utils; implement Slovak getProductListTitle and normalise hook errors; expose preset mutation hooks as direct aliases.
App UI/hook small changes
apps/herbatika/src/components/product-lists/*
Add ProductListItemsSkeleton and expose activeProductsAreLoading in useAccountProductLists for consistent loading UI.
Tests
libs/storefront-data/tests/*, apps/herbatika/tests/*
Add tests covering Medusa service behaviour (pagination, payload mapping, quantity normalisation, delta validation), utils, hooks, preset wiring, SSR prefetch, and package export regression checks.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • TechsioCZ/new-engine#378: Also updates @medusajs/js-sdk / @medusajs/types dependency versions in package.json.
  • TechsioCZ/new-engine#360: Foundation for the server-read preset/query-options composition extended here to add product-lists.
  • TechsioCZ/new-engine#290: Prior work migrating Herbatika product-lists to use shared storefront-data hooks; related to this cutover.

Suggested labels

released

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/herbatica-implement-storefront-data-changes
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch refactor/herbatica-implement-storefront-data-changes

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR moves the product-list data-fetching layer out of apps/herbatika and into the shared @techsio/storefront-data library, following the same factory pattern used for products, orders, and customers. The app-level product-lists.client.ts (~370 lines) and product-lists.types.ts are removed; the app's product-lists.ts becomes a thin adapter that re-exports from the library.

  • New library surface (libs/storefront-data/src/product-lists/): createProductListHooks factory (865 lines), createMedusaProductListService, createProductListQueryOptionsFactory, shared types, utility functions, and query-key factory — all wired into the preset in medusa/preset.ts and medusa/server-read.ts.
  • Auth integration: Product-list query keys are added to the preset's presetAuthInvalidateKeys and presetAuthRemoveOnLogoutKeys, so lists are invalidated on login and purged on logout, matching the behavior for orders and customers.
  • Tests: Four new test suites cover the Medusa service, utility helpers, preset integration (auth invalidation, cart sync), and server-read query-key generation.

Confidence Score: 5/5

Safe to merge — the refactoring faithfully replicates existing app behaviour through the shared library, the app adapter remains a thin wrapper, and the new code is covered by four test suites including an end-to-end cart-sync test.

The PR removes ~370 lines of hand-rolled app-level code and replaces it with a well-structured generic factory that matches every other domain in the library. Auth invalidation, cart synchronisation, and query-key consistency are all tested. The only findings are a type-inference gap in a helper that has no runtime impact.

No files require special attention beyond the withCustomerScope return-type annotation in hooks.ts and query-options.ts.

Important Files Changed

Filename Overview
libs/storefront-data/src/product-lists/hooks.ts New createProductListHooks factory implementing all read and mutation hooks; withCustomerScope loses TParams type information via as object spread, requiring unchecked casts at call sites.
libs/storefront-data/src/product-lists/medusa-service.ts New Medusa service implementation; re-exports all utils from ./utils (previously flagged). Quantity normalization and response resolution logic look correct.
libs/storefront-data/src/product-lists/query-options.ts Server-read query options factory; same withCustomerScope type-inference issue as hooks.ts. Supports configurable cacheStrategy override per call, which hooks.ts does not.
libs/storefront-data/src/product-lists/types.ts Clean type definitions for the product-list domain; response types cover snake_case, camelCase, and short-form field names for API flexibility.
libs/storefront-data/src/product-lists/utils.ts Utility helpers extracted and made generic; logic is correct and all covered by the new utils test suite.
libs/storefront-data/src/medusa/preset.ts Product-list hooks wired into the full preset with correct cart-sync options; auth invalidation/removal keys correctly extended.
libs/storefront-data/src/medusa/server-read.ts Product-list query options factory correctly added to the server-read preset; shares the same query keys as the client preset for consistent SSR hydration.
apps/herbatika/src/lib/storefront/product-lists.ts App-level adapter now delegates to the shared library; useProductLists and useProductList correctly re-map errors to Slovak-language messages while spreading remaining result fields.
libs/storefront-data/package.json Six new product-list export paths added; @medusajs/js-sdk and @medusajs/types removed from devDependencies — likely safe in a pnpm workspace where they're available transitively, but worth confirming.
libs/storefront-data/tests/product-lists.medusa-service.test.ts New service tests cover pagination, quantity normalization, zero-delta rejection, and cart creation; all critical paths exercised.
libs/storefront-data/tests/medusa.preset.test.tsx Preset tests extended with auth-invalidation coverage for product lists and a full cart-from-list sync end-to-end test.

Sequence Diagram

sequenceDiagram
    participant App as herbatika App
    participant Hooks as createProductListHooks
    participant Service as createMedusaProductListService
    participant Medusa as Medusa SDK / Backend

    App->>Hooks: useProductLists(input)
    Hooks->>Service: listProductLists(params, signal)
    Service->>Medusa: fetch GET /store/product-lists?...
    Medusa-->>Service: ProductListListResponse
    Service-->>Hooks: ProductListListResult
    Hooks-->>App: productLists, count, limit, offset

    App->>Hooks: useCreateProductListCart(input)
    Hooks->>Service: createProductListCart(input)
    Service->>Medusa: POST /store/product-lists/:id/cart
    Medusa-->>Service: ProductListCartResponse
    Service-->>Hooks: TCart
    Hooks->>Hooks: syncCartCaches + invalidateQueries
    Hooks->>Hooks: cartStorage.set(cart.id)
    Hooks-->>App: mutation result

    App->>Hooks: useAddFavoriteProductListItem(input)
    Hooks->>Service: addFavoriteProductListItem(input)
    Service->>Medusa: POST /store/product-lists/favorites/items
    Medusa-->>Service: ProductListItemResponse
    Service-->>Hooks: TProductListItem or null
    Hooks->>Hooks: invalidateProductLists(queryClient)
    Hooks-->>App: mutation result
Loading

Fix All in Codex

Reviews (2): Last reviewed commit: "fix: prevent false unavailable state in ..." | Re-trigger Greptile

Comment thread libs/storefront-data/src/product-lists/hooks.ts Outdated
Comment thread libs/storefront-data/src/product-lists/medusa-service.ts Outdated
Comment thread libs/storefront-data/src/product-lists/hooks.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
libs/storefront-data/src/product-lists/query-options.ts (1)

1-223: 🧹 Nitpick | 🔵 Trivial | ⚖️ Poor tradeoff

File exceeds 200-line soft limit guideline.

This file contains 223 lines, exceeding the approximate 200-line soft limit. Consider extracting helper functions (stripListInput, stripDetailInput, createDefaultListParams, withCustomerScope) into a separate utilities file to reduce the size of this module.

🤖 Prompt for 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.

In `@libs/storefront-data/src/product-lists/query-options.ts` around lines 1 -
223, This file is over the 200-line guideline; extract the helper functions
stripListInput, stripDetailInput, createDefaultListParams, and withCustomerScope
into a new utils module (e.g., product-list-utils) and update
createProductListQueryOptionsFactory to import them; ensure the new module
exports those four functions with the same signatures so buildList
(createDefaultListParams), buildDetail (stripDetailInput), and the default
buildListKey/buildDetailKey (withCustomerScope) continue to work unchanged, then
remove the local definitions from this file and run type checks to confirm no
breaking changes.

Source: Coding guidelines

libs/storefront-data/src/product-lists/medusa-service.ts (1)

1-413: 🧹 Nitpick | 🔵 Trivial | ⚖️ Poor tradeoff

File exceeds 200-line soft limit guideline.

This file contains 413 lines, significantly exceeding the approximate 200-line soft limit. Consider splitting the service implementation into:

  • Core service factory and config (main file)
  • Response normalisation helpers (separate file)
  • Quantity normalisation helpers (separate file)

This would improve maintainability and make the structure clearer.

🤖 Prompt for 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.

In `@libs/storefront-data/src/product-lists/medusa-service.ts` around lines 1 -
413, The file is too large and should be split: extract the response
normalization helpers (normalizeProductListsResponse,
resolveProductListFromResponse, resolveProductListItemFromResponse,
resolveProductListCartFromResponse) into a new "response-normalizers" module and
the quantity helpers (normalizeQuantity, normalizeQuantityDelta) into a new
"quantity-utils" module; export those functions from the new modules and update
createMedusaProductListService to import them instead of declaring inline,
keeping the factory (createMedusaProductListService), its config types
(MedusaProductListServiceConfig), and mapping helpers
(mapList/mapItem/resolveListQuery/resolveItemFromResponse) in the main file;
ensure all exported types used across modules remain exported and update any
relative imports (e.g., references to ProductList* types and compactRecord) so
existing callers keep the same public API.

Source: Coding guidelines

libs/storefront-data/src/product-lists/types.ts (1)

1-264: 🧹 Nitpick | 🔵 Trivial | ⚖️ Poor tradeoff

File exceeds 200-line soft limit guideline.

This file contains 264 lines, exceeding the approximate 200-line soft limit specified in the coding guidelines. Whilst type definition files often grow large, consider whether this module could benefit from splitting into logical groupings (e.g., base types, input types, service contracts, hook result types) to improve maintainability and navigability.

🤖 Prompt for 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.

In `@libs/storefront-data/src/product-lists/types.ts` around lines 1 - 264, The
file is too long—split the large types file into smaller logical modules:
extract core model types (e.g., ProductListItemBase, ProductListBase,
ProductListType, ProductListAccessType) into a product-list-models.ts, move
input/response types (e.g., CreateCustomProductListInput,
AddProductListItemInput, ProductListResponse, ProductListListResponse) into
product-list-io.ts, and put service/query/hook contracts (e.g.,
ProductListService, ProductListQueryKeys, UseProductListsResult,
UseProductListResult) into product-list-service.ts (or similar); update existing
imports/exports so each symbol (ProductListItemBase, ProductListBase,
ProductListService, ProductListQueryKeys, UseProductListsResult, etc.) is
exported from the new modules and re-exported from the original barrel if needed
to preserve external API.

Source: Coding guidelines

libs/storefront-data/src/product-lists/hooks.ts (1)

1-866: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift

File significantly exceeds 200-line soft limit guideline.

This file contains 866 lines, more than four times the approximate 200-line soft limit. Consider splitting into multiple files:

  • Query hooks (useProductLists, useProductList, etc.)
  • Mutation hooks (useCreate*, useUpdate*, useDelete*, useAdd*)
  • Query option builders (getListQueryOptions, getDetailQueryOptions)
  • Helper functions (stripInputs, createDefaultParams, etc.)

This would significantly improve maintainability and make the code easier to navigate.

🤖 Prompt for 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.

In `@libs/storefront-data/src/product-lists/hooks.ts` around lines 1 - 866, The
file is too large; split createProductListHooks into smaller modules: move
helper utilities (stripListInput, stripDetailInput, createDefaultListParams,
withCustomerScope, resolve defaults and types) into a new helpers module and
export them for use; move query option builders (getListQueryOptions,
getDetailQueryOptions) into a query-options module that imports service,
resolvedQueryKeys and resolvedCacheConfig from the factory or accepts them as
arguments; move query hooks (useProductLists, useSuspenseProductLists,
useProductList, useSuspenseProductList, useProductListDetails) into a queries
module that imports the query-option builders; move mutation hooks
(useCreateFavoriteProductList, useCreateCustomProductList, useUpdateProductList,
useDeleteProductList, useAddProductListItem, useAddFavoriteProductListItem,
useCreateProductListCart, useUpdateProductListItem,
useChangeProductListItemQuantity, useIncrementProductListItem,
useDeleteProductListItem) into a mutations module that accepts service and
invalidateProductLists/queryClient helpers; keep createProductListHooks as the
small factory that composes these modules (wiring service,
buildList/buildDetail/build*Key, resolvedQueryKeys, resolvedCacheConfig,
defaultPageSize, cartQueryKeys/cartStorage/isActiveCartQueryKey) and re-exports
the same API surface so existing imports remain unchanged.

Source: Coding guidelines

🤖 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/src/product-lists/query-options.ts`:
- Around line 78-135: The four helpers stripListInput, stripDetailInput,
createDefaultListParams, and withCustomerScope are duplicated; extract them into
a single shared module (e.g., product-lists/query-input-utils.ts), export each
function (preserve their generic signatures and behavior, including use of
resolvePagination and compactRecord inside createDefaultListParams), then
replace the local definitions in query-options.ts and hooks.ts with imports from
that new module; update both files to import the exported functions and ensure
types (ProductListListInputBase, ProductListDetailInputBase) remain referenced
or re-exported so existing call sites (createDefaultListParams, stripListInput,
stripDetailInput, withCustomerScope) compile.

In `@libs/storefront-data/src/product-lists/types.ts`:
- Around line 29-43: ProductListBase currently exposes both items_count and
item_count which is ambiguous for consumers; update the data model and mapping
layer so consumers see a single canonical count field (e.g., itemCount) and
ensure the service/utility that normalizes API responses (where ProductListBase
is constructed) maps either incoming items_count or item_count into that
canonical field and removes the duplicate; update any constructors, mappers, or
factory functions that produce ProductListBase objects to prefer one source
(document the precedence) and populate only the canonical property.

---

Outside diff comments:
In `@libs/storefront-data/src/product-lists/hooks.ts`:
- Around line 1-866: The file is too large; split createProductListHooks into
smaller modules: move helper utilities (stripListInput, stripDetailInput,
createDefaultListParams, withCustomerScope, resolve defaults and types) into a
new helpers module and export them for use; move query option builders
(getListQueryOptions, getDetailQueryOptions) into a query-options module that
imports service, resolvedQueryKeys and resolvedCacheConfig from the factory or
accepts them as arguments; move query hooks (useProductLists,
useSuspenseProductLists, useProductList, useSuspenseProductList,
useProductListDetails) into a queries module that imports the query-option
builders; move mutation hooks (useCreateFavoriteProductList,
useCreateCustomProductList, useUpdateProductList, useDeleteProductList,
useAddProductListItem, useAddFavoriteProductListItem, useCreateProductListCart,
useUpdateProductListItem, useChangeProductListItemQuantity,
useIncrementProductListItem, useDeleteProductListItem) into a mutations module
that accepts service and invalidateProductLists/queryClient helpers; keep
createProductListHooks as the small factory that composes these modules (wiring
service, buildList/buildDetail/build*Key, resolvedQueryKeys,
resolvedCacheConfig, defaultPageSize,
cartQueryKeys/cartStorage/isActiveCartQueryKey) and re-exports the same API
surface so existing imports remain unchanged.

In `@libs/storefront-data/src/product-lists/medusa-service.ts`:
- Around line 1-413: The file is too large and should be split: extract the
response normalization helpers (normalizeProductListsResponse,
resolveProductListFromResponse, resolveProductListItemFromResponse,
resolveProductListCartFromResponse) into a new "response-normalizers" module and
the quantity helpers (normalizeQuantity, normalizeQuantityDelta) into a new
"quantity-utils" module; export those functions from the new modules and update
createMedusaProductListService to import them instead of declaring inline,
keeping the factory (createMedusaProductListService), its config types
(MedusaProductListServiceConfig), and mapping helpers
(mapList/mapItem/resolveListQuery/resolveItemFromResponse) in the main file;
ensure all exported types used across modules remain exported and update any
relative imports (e.g., references to ProductList* types and compactRecord) so
existing callers keep the same public API.

In `@libs/storefront-data/src/product-lists/query-options.ts`:
- Around line 1-223: This file is over the 200-line guideline; extract the
helper functions stripListInput, stripDetailInput, createDefaultListParams, and
withCustomerScope into a new utils module (e.g., product-list-utils) and update
createProductListQueryOptionsFactory to import them; ensure the new module
exports those four functions with the same signatures so buildList
(createDefaultListParams), buildDetail (stripDetailInput), and the default
buildListKey/buildDetailKey (withCustomerScope) continue to work unchanged, then
remove the local definitions from this file and run type checks to confirm no
breaking changes.

In `@libs/storefront-data/src/product-lists/types.ts`:
- Around line 1-264: The file is too long—split the large types file into
smaller logical modules: extract core model types (e.g., ProductListItemBase,
ProductListBase, ProductListType, ProductListAccessType) into a
product-list-models.ts, move input/response types (e.g.,
CreateCustomProductListInput, AddProductListItemInput, ProductListResponse,
ProductListListResponse) into product-list-io.ts, and put service/query/hook
contracts (e.g., ProductListService, ProductListQueryKeys,
UseProductListsResult, UseProductListResult) into product-list-service.ts (or
similar); update existing imports/exports so each symbol (ProductListItemBase,
ProductListBase, ProductListService, ProductListQueryKeys,
UseProductListsResult, etc.) is exported from the new modules and re-exported
from the original barrel if needed to preserve external API.
🪄 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: a9ff5b67-b41e-4095-87ed-fe8dd6cdf9c6

📥 Commits

Reviewing files that changed from the base of the PR and between 8c80ca0 and 4585a6c.

📒 Files selected for processing (25)
  • apps/herbatika/src/lib/storefront/product-lists.client.ts
  • apps/herbatika/src/lib/storefront/product-lists.ts
  • apps/herbatika/src/lib/storefront/product-lists.types.ts
  • apps/herbatika/src/lib/storefront/storefront-config.ts
  • apps/herbatika/src/lib/storefront/storefront-core-definition.ts
  • apps/herbatika/src/lib/storefront/storefront-server.ts
  • apps/herbatika/src/lib/storefront/storefront.ts
  • libs/storefront-data/AGENTS.md
  • libs/storefront-data/README.md
  • libs/storefront-data/package.json
  • libs/storefront-data/src/medusa/foundation.ts
  • libs/storefront-data/src/medusa/preset.ts
  • libs/storefront-data/src/medusa/server-read.ts
  • libs/storefront-data/src/product-lists/hooks.ts
  • libs/storefront-data/src/product-lists/medusa-service.ts
  • libs/storefront-data/src/product-lists/query-keys.ts
  • libs/storefront-data/src/product-lists/query-options.ts
  • libs/storefront-data/src/product-lists/types.ts
  • libs/storefront-data/src/product-lists/utils.ts
  • libs/storefront-data/src/shared/object-utils.ts
  • libs/storefront-data/tests/medusa.preset.test.tsx
  • libs/storefront-data/tests/medusa.server-read.test.ts
  • libs/storefront-data/tests/product-lists.medusa-service.test.ts
  • libs/storefront-data/tests/product-lists.utils.test.ts
  • libs/storefront-data/tests/regression.catalog-customers-exports.test.tsx
💤 Files with no reviewable changes (2)
  • apps/herbatika/src/lib/storefront/product-lists.types.ts
  • apps/herbatika/src/lib/storefront/product-lists.client.ts
📜 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). (3)
  • GitHub Check: main
  • GitHub Check: Greptile Review
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (6)
libs/storefront-data/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)

libs/storefront-data/**/*.{ts,tsx,js,jsx}: Do not import from ./dist/ paths - use source files instead
Keep the "use client" directive only in client components

Files:

  • libs/storefront-data/src/shared/object-utils.ts
  • libs/storefront-data/src/product-lists/query-keys.ts
  • libs/storefront-data/tests/product-lists.utils.test.ts
  • libs/storefront-data/tests/regression.catalog-customers-exports.test.tsx
  • libs/storefront-data/tests/medusa.server-read.test.ts
  • libs/storefront-data/tests/product-lists.medusa-service.test.ts
  • libs/storefront-data/src/medusa/foundation.ts
  • libs/storefront-data/src/product-lists/utils.ts
  • libs/storefront-data/src/product-lists/query-options.ts
  • libs/storefront-data/tests/medusa.preset.test.tsx
  • libs/storefront-data/src/product-lists/medusa-service.ts
  • libs/storefront-data/src/product-lists/types.ts
  • libs/storefront-data/src/medusa/server-read.ts
  • libs/storefront-data/src/medusa/preset.ts
  • libs/storefront-data/src/product-lists/hooks.ts
libs/storefront-data/**/*.{ts,tsx}

📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)

libs/storefront-data/**/*.{ts,tsx}: Do not use any type - use proper generics instead
Do not hardcode query keys - use createQueryKey() utility instead
Do not mix server/client code in the same file
Always use the factory pattern for creating hooks (e.g., createProductHooks, createCollectionHooks)
Always type service interfaces with generics
Always use cache strategies from CacheConfig (static, semiStatic, realtime, userData)
Use getServerQueryClient from server/get-query-client for Server Components in the storefront-data library

Files:

  • libs/storefront-data/src/shared/object-utils.ts
  • libs/storefront-data/src/product-lists/query-keys.ts
  • libs/storefront-data/tests/product-lists.utils.test.ts
  • libs/storefront-data/tests/regression.catalog-customers-exports.test.tsx
  • libs/storefront-data/tests/medusa.server-read.test.ts
  • libs/storefront-data/tests/product-lists.medusa-service.test.ts
  • libs/storefront-data/src/medusa/foundation.ts
  • libs/storefront-data/src/product-lists/utils.ts
  • libs/storefront-data/src/product-lists/query-options.ts
  • libs/storefront-data/tests/medusa.preset.test.tsx
  • libs/storefront-data/src/product-lists/medusa-service.ts
  • libs/storefront-data/src/product-lists/types.ts
  • libs/storefront-data/src/medusa/server-read.ts
  • libs/storefront-data/src/medusa/preset.ts
  • libs/storefront-data/src/product-lists/hooks.ts
apps/herbatika/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/herbatika/AGENTS.md)

apps/herbatika/src/**/*.{ts,tsx}: Use internal UI primitives/components from @techsio/ui-kit instead of native HTML controls in app code; avoid raw <button>, <input>, <select>, <textarea>, <img>, and inline SVG icons unless documented exceptions exist
Use token-based utility classes instead of raw Tailwind palette/spacing values; prefer p-200 mt-300 gap-150 text-success bg-danger over p-4 mt-8 gap-4 bg-red-600 text-green-300
Soft limit of approximately 200 lines per source file; exceeding this should trigger refactor consideration as a red flag
Use kebab-case for file names and PascalCase for React component names

Files:

  • apps/herbatika/src/lib/storefront/storefront-server.ts
  • apps/herbatika/src/lib/storefront/storefront-core-definition.ts
  • apps/herbatika/src/lib/storefront/storefront-config.ts
  • apps/herbatika/src/lib/storefront/storefront.ts
  • apps/herbatika/src/lib/storefront/product-lists.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/{AGENTS,CLAUDE}.md

📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)

Edit only libs/storefront-data/AGENTS.md as the canonical source of truth - CLAUDE.md is a symlink

Files:

  • libs/storefront-data/AGENTS.md
**/package.json

📄 CodeRabbit inference engine (CLAUDE.md)

Use pnpm CLI to add dependencies; never edit package.json directly

Files:

  • libs/storefront-data/package.json
🧠 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.tsx
  • libs/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
🔇 Additional comments (37)
libs/storefront-data/tests/product-lists.medusa-service.test.ts (1)

1-128: LGTM!

libs/storefront-data/tests/product-lists.utils.test.ts (1)

1-63: LGTM!

libs/storefront-data/tests/medusa.preset.test.tsx (1)

32-36: LGTM!

Also applies to: 76-83, 232-247, 249-288, 387-495, 497-568

libs/storefront-data/tests/medusa.server-read.test.ts (1)

6-10: LGTM!

Also applies to: 35-48, 87-90, 104-136, 152-166

libs/storefront-data/tests/regression.catalog-customers-exports.test.tsx (1)

291-294: LGTM!

libs/storefront-data/src/product-lists/types.ts (5)

14-27: LGTM!


45-74: LGTM!


76-168: LGTM!


175-233: LGTM!


235-263: LGTM!

libs/storefront-data/src/product-lists/utils.ts (4)

3-8: LGTM!

Also applies to: 10-29, 31-41


50-76: LGTM!


78-100: LGTM!


43-48: Revisit zero/invalid handling in resolveProductListItemQuantity (libs/storefront-data/src/product-lists/utils.ts:43-48)
resolveProductListItemQuantity floors positive numbers and returns 1 for 0, negatives, null/undefined, and NaN. If 0 is a meaningful quantity in product list items, this silently turns it into 1; handle 0 explicitly or document the intended semantics.

libs/storefront-data/src/shared/object-utils.ts (1)

16-19: LGTM!

libs/storefront-data/src/product-lists/medusa-service.ts (4)

51-63: 💤 Low value

Verify error message clarity for quantity delta validation.

normalizeQuantityDelta throws an error when the quantity delta is zero. Whilst this validation is correct, the error message "Quantity change must be a non-zero integer" might be unclear to consumers who pass floating-point numbers. Consider whether the message should also mention that the value will be truncated to an integer.


335-356: 💤 Low value

Verify cart creation error handling is sufficient.

createProductListCart throws a generic error if the cart is missing from the response (line 352). Whilst this is correct, the error doesn't include contextual information like the listId that was used, which could aid debugging. Consider enriching the error message.

💡 Proposed enhancement
       if (!cart) {
-        throw new Error("Product list cart response did not include a cart.")
+        throw new Error(`Product list cart response did not include a cart for list ${input.listId}.`)
       }

43-49: LGTM!

Also applies to: 110-143, 165-191, 200-238, 240-293, 295-333, 358-410


389-400: Clarify Medusa /items/:itemId/increment quantity semantics in incrementProductListItem.
In libs/storefront-data/src/product-lists/medusa-service.ts (lines 389-400), the code posts { quantity: normalizeQuantity(input.quantity) ?? 1 } to /items/${input.itemId}/increment. Confirm whether Medusa treats this quantity as an absolute target or a delta; if it’s a target value, the method naming/normalisation are potentially misleading and may need renaming or request-shape adjustment.

libs/storefront-data/src/product-lists/query-keys.ts (1)

5-28: LGTM!

libs/storefront-data/src/product-lists/query-options.ts (2)

210-216: ⚡ Quick win

Verify error handling approach in queryFn.

getDetailQueryOptions throws an error inside the queryFn (lines 211-212) when input.id is missing. Whilst this prevents invalid queries, React Query will treat this as a query error, which triggers error boundaries and retry logic.

Consider whether this should instead:

  1. Return null immediately (current service behaviour for missing IDs)
  2. Throw before creating the query options
  3. Be handled by the enabled flag in calling hooks

The current implementation is functional but may result in unnecessary error logging and retry attempts.


23-76: LGTM!

Also applies to: 78-97, 99-123, 125-135, 137-201

libs/storefront-data/src/product-lists/hooks.ts (3)

418-424: ⚡ Quick win

Error handling in getDetailQueryOptions throws inside queryFn.

Similar to query-options.ts, getDetailQueryOptions throws an error inside the queryFn when input.id is missing (lines 419-421). This will be treated as a query error by React Query, potentially triggering error boundaries and retry logic.

The calling hooks (useProductList at line 497 and useProductListDetails at line 557) already handle the enabled flag based on input.id, which prevents the query from running when the ID is missing. However, useSuspenseProductList throws immediately at line 520-522, which is a cleaner approach.

Consider aligning the error handling strategy across all hooks for consistency.


370-390: LGTM!

Also applies to: 430-461, 463-489, 491-512, 543-560, 562-664, 666-843, 845-864


718-739: fix(storefront-data): verify cart cache synchronisation and invalidation side effects
useCreateProductListCart syncs cart caches and stores cart.id after mutation success; ensure the implementation aligns with the expected syncCartCaches cart shape, that isActiveCartQueryKey only matches the intended active-cart queries, and that invalidateQueries({ queryKey: cartQueryKeys.all() }) won’t cause redundant refetches or conflict with other cart flows. Also ensure cartStorage?.set(cart.id) failure (or an unset storage) can’t leave caches inconsistent; add appropriate guarding/error handling if needed.

apps/herbatika/src/lib/storefront/storefront-config.ts (1)

32-36: LGTM!

Also applies to: 167-170

apps/herbatika/src/lib/storefront/storefront-core-definition.ts (1)

38-40: LGTM!

apps/herbatika/src/lib/storefront/storefront-server.ts (1)

56-58: LGTM!

apps/herbatika/src/lib/storefront/storefront.ts (1)

36-38: LGTM!

apps/herbatika/src/lib/storefront/product-lists.ts (1)

4-37: LGTM!

Also applies to: 41-58, 75-109, 111-184

libs/storefront-data/src/medusa/foundation.ts (1)

19-20: LGTM!

Also applies to: 41-44, 59-62, 93-96

libs/storefront-data/src/medusa/preset.ts (1)

126-145: LGTM!

Also applies to: 247-262, 280-286, 435-447, 532-532, 605-611, 762-763, 788-793, 831-831, 856-856, 861-861, 944-963

libs/storefront-data/src/medusa/server-read.ts (1)

56-76: LGTM!

Also applies to: 140-159, 219-222, 242-248, 272-284, 344-344, 382-386, 469-470, 490-495, 531-537

libs/storefront-data/package.json (2)

232-255: LGTM!


309-310: Confirm Medusa deps were updated via pnpm CLI (and lockfile updated)

@medusajs/js-sdk and @medusajs/types in libs/storefront-data/package.json were changed to ^2.15.2, but the diff doesn’t include/reflect pnpm-lock.yaml. Please confirm these were applied using pnpm add -D @medusajs/js-sdk@^2.15.2 @medusajs/types@^2.15.2 (or equivalent) and that pnpm-lock.yaml now contains the corresponding 2.15.x resolutions for both packages.

libs/storefront-data/AGENTS.md (1)

35-35: LGTM!

libs/storefront-data/README.md (1)

174-174: LGTM!

Also applies to: 177-178, 189-189

Comment thread libs/storefront-data/src/product-lists/query-options.ts Outdated
Comment thread libs/storefront-data/src/product-lists/types.ts
@kilo-code-bot

kilo-code-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code Review Summary

Status: Issues Found | Recommendation: Review suggested changes

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
libs/storefront-data/src/product-lists/medusa-service.ts 383 Body payload uses direct object literal without compactRecord, inconsistent with other mutation methods in this file
libs/storefront-data/src/product-lists/medusa-service.ts 396 Body payload uses direct object literal without compactRecord, inconsistent with other mutation methods in this file
Other Observations (not in diff)

No additional issues found in unchanged code.

Files Reviewed (4 files)
  • libs/storefront-data/src/product-lists/hooks.ts - 0 issues (new file)
  • libs/storefront-data/src/product-lists/medusa-service.ts - 2 issues (new file)
  • libs/storefront-data/src/product-lists/query-keys.ts - 0 issues (new file)
  • libs/storefront-data/src/product-lists/query-options.ts - 0 issues (new file)
  • libs/storefront-data/src/product-lists/types.ts - 0 issues (new file)
  • libs/storefront-data/src/product-lists/utils.ts - 0 issues (new file)

Fix these issues in Kilo Cloud

@kilo-code-bot

kilo-code-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 2 Suggestions | Recommendation: Consider addressing for consistency

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
libs/storefront-data/src/product-lists/medusa-service.ts 383 Body payload for changeProductListItemQuantity uses direct object literal without compactRecord, inconsistent with other mutation methods
libs/storefront-data/src/product-lists/medusa-service.ts 396 Body payload for incrementProductListItem uses direct object literal without compactRecord, inconsistent with other mutation methods
Files Reviewed (6 files)
  • libs/storefront-data/src/product-lists/hooks.ts - No issues (new file, follows established patterns)
  • libs/storefront-data/src/product-lists/medusa-service.ts - 2 suggestions (inconsistent body handling)
  • libs/storefront-data/src/product-lists/query-keys.ts - No issues (new file)
  • libs/storefront-data/src/product-lists/query-options.ts - No issues (new file)
  • libs/storefront-data/src/product-lists/types.ts - No issues (new file)
  • libs/storefront-data/src/product-lists/utils.ts - No issues (new file)

Fix these issues in Kilo Cloud

@kilo-code-bot

kilo-code-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

SUGGESTION: changeProductListItemQuantity body payload (line 383)

Body payload uses direct object literal without compactRecord, inconsistent with other mutation methods in this file. All other mutation methods (addProductListItem, updateProductListItem, etc.) use compactRecord({}) to filter undefined values. While this case only has a quantity field, using compactRecord maintains consistency and provides resilience against future modifications.

@kilo-code-bot

kilo-code-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

SUGGESTION: incrementProductListItem body payload (line 396)

Body payload uses direct object literal without compactRecord, inconsistent with other mutation methods in this file. All other mutation methods (addProductListItem, updateProductListItem, etc.) use compactRecord({}) to filter undefined values. Using a consistent pattern improves maintainability.

@kilo-code-bot

kilo-code-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 2 Suggestions | Recommendation: Consider addressing for consistency

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
libs/storefront-data/src/product-lists/medusa-service.ts 383 Body payload for changeProductListItemQuantity uses direct object literal without compactRecord, inconsistent with other mutation methods
libs/storefront-data/src/product-lists/medusa-service.ts 396 Body payload for incrementProductListItem uses direct object literal without compactRecord, inconsistent with other mutation methods
Other Observations (not in diff)

No additional issues found in unchanged code.

Files Reviewed (6 files)
  • libs/storefront-data/src/product-lists/hooks.ts - No issues (new file, follows established patterns)
  • libs/storefront-data/src/product-lists/medusa-service.ts - 2 suggestions (inconsistent body handling)
  • libs/storefront-data/src/product-lists/query-keys.ts - No issues (new file)
  • libs/storefront-data/src/product-lists/query-options.ts - No issues (new file)
  • libs/storefront-data/src/product-lists/types.ts - No issues (new file)
  • libs/storefront-data/src/product-lists/utils.ts - No issues (new file)

Fix these issues in Kilo Cloud


Reviewed by laguna-m.1-20260312:free · 71,910 tokens

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md (1)

234-234: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Add trailing newline at end of file.

Text files should end with a newline character as per POSIX standards and common Markdown conventions.

📝 Proposed fix
 See also: `decide-app-specific-overrides-vs-shared-platform` for thin wrapper rules.
+
🤖 Prompt for 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.

In
`@libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md`
at line 234, The file SKILL.md is missing a trailing newline at EOF; open
SKILL.md and add a single newline character at the end of the file so the file
terminates with a newline (ensure your editor saves the file with a trailing
newline to satisfy POSIX/Markdown conventions).
libs/storefront-data/skills/implement-cart-and-checkout-platform-flows/SKILL.md (1)

243-243: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Add trailing newline at end of file.

Text files should end with a newline character as per POSIX standards and common Markdown conventions.

📝 Proposed fix
 See also: `configure-pagination-prefetch-and-cache-policy` for shared query-key behavior and cache semantics.
+
🤖 Prompt for 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.

In
`@libs/storefront-data/skills/implement-cart-and-checkout-platform-flows/SKILL.md`
at line 243, The file SKILL.md is missing a trailing newline; open SKILL.md and
add a single newline character at the end of the file so the file ends with a
newline (POSIX/Markdown convention), then save and commit the change.
libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md (1)

193-193: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Add trailing newline at end of file.

Text files should end with a newline character as per POSIX standards and common Markdown conventions.

📝 Proposed fix
 See also: `decide-app-specific-overrides-vs-shared-platform` for promotion rules.
+
🤖 Prompt for 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.

In `@libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md`
at line 193, Add a trailing newline to the end of SKILL.md so the file ends with
a newline character (POSIX/Markdown convention); open
libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md and
ensure the final line is terminated with a newline before committing.
libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md (1)

238-238: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Add trailing newline at end of file.

Text files should end with a newline character as per POSIX standards and common Markdown conventions.

📝 Proposed fix
 See also: `configure-pagination-prefetch-and-cache-policy` for prefetch behavior and normalized query-key rules.
+
🤖 Prompt for 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.

In `@libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md` at
line 238, The file SKILL.md is missing a trailing newline at EOF; open SKILL.md
and add a single newline character at the end of the file (ensure the final line
ends with '\n') then save and commit the change so the file conforms to
POSIX/Markdown newline conventions.
libs/storefront-data/skills/implement-ssr-prefetch-and-query-client-boundaries/SKILL.md (1)

225-225: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Add trailing newline at end of file.

Text files should end with a newline character as per POSIX standards and common Markdown conventions.

📝 Proposed fix
 See also: `configure-pagination-prefetch-and-cache-policy` for skip modes, page planning, and normalized query inputs.
+
🤖 Prompt for 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.

In
`@libs/storefront-data/skills/implement-ssr-prefetch-and-query-client-boundaries/SKILL.md`
at line 225, Add a single trailing newline character to the end of SKILL.md so
the file ends with a newline (POSIX/Markdown convention); open SKILL.md, move to
the file end and insert a newline, then save to ensure the file ends with
exactly one newline character.
🤖 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/skills/implement-cart-and-checkout-platform-flows/SKILL.md`:
- Around line 183-199: Update the example to include the missing import for
resolveSelectedPaymentProviderId and replace the incorrect direct-access
snippet; specifically, import resolveSelectedPaymentProviderId from
"`@techsio/storefront-data/shared/checkout-flow-utils`" and use
resolveSelectedPaymentProviderId(cart) instead of accessing
cart.payment_collection?.payment_sessions?.[0]?.provider_id so the example shows
the correct selected-payment-session semantics (reference the
resolveSelectedPaymentProviderId symbol in the example).

---

Outside diff comments:
In
`@libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md`:
- Line 234: The file SKILL.md is missing a trailing newline at EOF; open
SKILL.md and add a single newline character at the end of the file so the file
terminates with a newline (ensure your editor saves the file with a trailing
newline to satisfy POSIX/Markdown conventions).

In
`@libs/storefront-data/skills/implement-cart-and-checkout-platform-flows/SKILL.md`:
- Line 243: The file SKILL.md is missing a trailing newline; open SKILL.md and
add a single newline character at the end of the file so the file ends with a
newline (POSIX/Markdown convention), then save and commit the change.

In
`@libs/storefront-data/skills/implement-ssr-prefetch-and-query-client-boundaries/SKILL.md`:
- Line 225: Add a single trailing newline character to the end of SKILL.md so
the file ends with a newline (POSIX/Markdown convention); open SKILL.md, move to
the file end and insert a newline, then save to ensure the file ends with
exactly one newline character.

In
`@libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md`:
- Line 193: Add a trailing newline to the end of SKILL.md so the file ends with
a newline character (POSIX/Markdown convention); open
libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md and
ensure the final line is terminated with a newline before committing.

In `@libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md`:
- Line 238: The file SKILL.md is missing a trailing newline at EOF; open
SKILL.md and add a single newline character at the end of the file (ensure the
final line ends with '\n') then save and commit the change so the file conforms
to POSIX/Markdown newline conventions.
🪄 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: 319a96fd-1734-4181-807e-fc3211fa83d2

📥 Commits

Reviewing files that changed from the base of the PR and between 4585a6c and bf677bf.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (24)
  • apps/herbatika/src/components/product-lists/product-list-tabs.tsx
  • apps/herbatika/src/components/product-lists/use-account-product-lists.ts
  • libs/storefront-data/package.json
  • libs/storefront-data/skills/audit-storefront-before-release/SKILL.md
  • libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/SKILL.md
  • libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/references/prefetch-and-pagination.md
  • libs/storefront-data/skills/decide-app-specific-overrides-vs-shared-platform/SKILL.md
  • libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/SKILL.md
  • libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/references/extension-recipe.md
  • libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md
  • libs/storefront-data/skills/implement-cart-and-checkout-platform-flows/SKILL.md
  • libs/storefront-data/skills/implement-ssr-prefetch-and-query-client-boundaries/SKILL.md
  • libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md
  • libs/storefront-data/skills/setup-storefront-platform-in-next-app/SKILL.md
  • libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md
  • libs/storefront-data/skills/use-storefront-data-skills/SKILL.md
  • libs/storefront-data/src/product-lists/hooks.ts
  • libs/storefront-data/src/product-lists/input-utils.ts
  • libs/storefront-data/src/product-lists/medusa-service.ts
  • libs/storefront-data/src/product-lists/query-options.ts
  • libs/storefront-data/src/product-lists/utils.ts
  • libs/storefront-data/tests/product-lists.hooks.test.tsx
  • libs/storefront-data/tests/product-lists.medusa-service.test.ts
  • libs/storefront-data/tests/product-lists.utils.test.ts
📜 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: main
🧰 Additional context used
📓 Path-based instructions (4)
apps/herbatika/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/herbatika/AGENTS.md)

apps/herbatika/src/**/*.{ts,tsx}: Use internal UI primitives/components from @techsio/ui-kit instead of native HTML controls in app code; avoid raw <button>, <input>, <select>, <textarea>, <img>, and inline SVG icons unless documented exceptions exist
Use token-based utility classes instead of raw Tailwind palette/spacing values; prefer p-200 mt-300 gap-150 text-success bg-danger over p-4 mt-8 gap-4 bg-red-600 text-green-300
Soft limit of approximately 200 lines per source file; exceeding this should trigger refactor consideration as a red flag
Use kebab-case for file names and PascalCase for React component names

Files:

  • apps/herbatika/src/components/product-lists/use-account-product-lists.ts
  • apps/herbatika/src/components/product-lists/product-list-tabs.tsx
libs/storefront-data/**/*.{ts,tsx}

📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)

libs/storefront-data/**/*.{ts,tsx}: Never import from ./dist/ paths - use source files instead
Never use any type - use proper generics instead
Never hardcode query keys - use createQueryKey() utility instead
Never mix server and client code in the same file

Files:

  • libs/storefront-data/tests/product-lists.hooks.test.tsx
  • libs/storefront-data/tests/product-lists.utils.test.ts
  • libs/storefront-data/src/product-lists/input-utils.ts
  • libs/storefront-data/tests/product-lists.medusa-service.test.ts
  • libs/storefront-data/src/product-lists/utils.ts
  • libs/storefront-data/src/product-lists/hooks.ts
  • libs/storefront-data/src/product-lists/medusa-service.ts
  • libs/storefront-data/src/product-lists/query-options.ts
libs/storefront-data/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (libs/storefront-data/AGENTS.md)

libs/storefront-data/src/**/*.{ts,tsx}: Always use factory pattern for creating hooks (createProductHooks, createCollectionHooks, createCategoryHooks, createRegionHooks, createAuthHooks, createCartHooks, createCheckoutHooks, createOrderHooks, createCustomerHooks, createProductListHooks)
Always type service interfaces with generics in the storefront-data library
Always use cache strategies from CacheConfig (static, semiStatic, realtime, userData) for query configuration

Files:

  • libs/storefront-data/src/product-lists/input-utils.ts
  • libs/storefront-data/src/product-lists/utils.ts
  • libs/storefront-data/src/product-lists/hooks.ts
  • libs/storefront-data/src/product-lists/medusa-service.ts
  • libs/storefront-data/src/product-lists/query-options.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
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: TechsioCZ/new-engine

Timestamp: 2026-06-10T15:27:40.970Z
Learning: On Windows, enable Developer Mode and set `git config core.symlinks true` so symlinks work properly
Learnt from: CR
Repo: TechsioCZ/new-engine

Timestamp: 2026-06-10T15:27:40.970Z
Learning: For TanStack Query implementation, check official docs before implementing SSR/prefetch patterns in the storefront-data library
Learnt from: CR
Repo: TechsioCZ/new-engine

Timestamp: 2026-06-10T15:27:40.970Z
Learning: For Medusa SDK implementation, reference official SDK documentation for API response types and SDK methods
📚 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/product-lists.hooks.test.tsx
  • apps/herbatika/src/components/product-lists/product-list-tabs.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
🪛 LanguageTool
libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/references/extension-recipe.md

[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... helpers through createQueryKey(). 4. Add the Medusa service and forward `AbortSi...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~9-~9: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...a service and forward AbortSignal. 5. Add hooks or helper functions that match ex...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md

[uncategorized] ~161-~161: Possible missing comma found.
Context: ...already exist. During routing or region bootstrap they throw instead of waiting. Source:...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~208-~208: Possible missing comma found.
Context: ...alize region-aware inputs. Missing them fragments payload shape and cache identity across...

(AI_HYDRA_LEO_MISSING_COMMA)

libs/storefront-data/skills/implement-cart-and-checkout-platform-flows/SKILL.md

[misspelling] ~238-~238: This word is normally spelled as one.
Context: ...tching is now shared platform behavior. Hand-written heuristics drift from the tested cache ...

(EN_COMPOUNDS_HAND_WRITTEN)

libs/storefront-data/skills/audit-storefront-before-release/SKILL.md

[misspelling] ~78-~78: This word is normally spelled as one.
Context: ...tQueryDataorinvalidateQueries` with hand-written cart keys. Fix: reuse the shared cart-c...

(EN_COMPOUNDS_HAND_WRITTEN)

libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/references/prefetch-and-pagination.md

[uncategorized] ~5-~5: Loose punctuation mark.
Context: ...ference ## Cache strategies - static: very slow-changing data such as regions...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~10-~10: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...defaults. Keep the strategy names intact so the rest of the package still reasons a...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~14-~14: Loose punctuation mark.
Context: ... ## Skip modes - skipIfCached: false: always prefetch - skipIfCached: true ...

(UNLIKELY_OPENING_PUNCTUATION)

libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md

[misspelling] ~152-~152: This word is normally spelled as one.
Context: ...c/auth/hooks.ts` ### CRITICAL Assuming multi-step auth is already supported Wrong: ```t...

(EN_COMPOUNDS_MULTI_STEP)


[misspelling] ~169-~169: This word is normally spelled as one.
Context: ...The current Medusa auth adapter rejects multi-step flows. The obvious generic-provider sha...

(EN_COMPOUNDS_MULTI_STEP)

libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/SKILL.md

[uncategorized] ~140-~140: Use a comma before ‘or’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...participate in normalized key generation or they drift from invalidation and cache-...

(COMMA_COMPOUND_SENTENCE)


[duplication] ~169-~169: Possible typo: you repeated a word.
Context: ...src/orders/medusa-service.ts`, TanStack Query query cancellation docs ### HIGH Shared beha...

(ENGLISH_WORD_REPEAT_RULE)

libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/SKILL.md

[misspelling] ~30-~30: This word is normally spelled as one.
Context: ...h helpers instead of app-local loops or hand-written query keys. ```ts // src/lib/storefron...

(EN_COMPOUNDS_HAND_WRITTEN)

🪛 markdownlint-cli2 (0.22.1)
libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md

[warning] 25-25: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

libs/storefront-data/skills/implement-cart-and-checkout-platform-flows/SKILL.md

[warning] 26-26: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

libs/storefront-data/skills/audit-storefront-before-release/SKILL.md

[warning] 23-23: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

libs/storefront-data/skills/implement-ssr-prefetch-and-query-client-boundaries/SKILL.md

[warning] 24-24: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md

[warning] 22-22: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md

[warning] 21-21: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/SKILL.md

[warning] 23-23: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

🔇 Additional comments (29)
libs/storefront-data/package.json (2)

5-9: LGTM!

Also applies to: 283-284, 329-331


237-260: Lockfile matches the dependency changes
pnpm-lock.yaml contains entries for the bumped Medusa SDK/types and the added TanStack intent: @medusajs/js-sdk 2.15.2 (specifier ^2.15.2 / 2.15.2), @medusajs/types 2.15.2 (specifier ^2.15.2 / 2.15.2), and @tanstack/intent 0.0.42 (specifier ^0.0.42).

apps/herbatika/src/components/product-lists/use-account-product-lists.ts (1)

115-120: LGTM!

Also applies to: 442-442

apps/herbatika/src/components/product-lists/product-list-tabs.tsx (1)

30-67: LGTM!

Also applies to: 120-120, 127-129

libs/storefront-data/tests/product-lists.medusa-service.test.ts (1)

1-176: LGTM!

libs/storefront-data/tests/product-lists.utils.test.ts (1)

1-71: LGTM!

libs/storefront-data/tests/product-lists.hooks.test.tsx (1)

1-210: LGTM!

libs/storefront-data/src/product-lists/input-utils.ts (1)

1-68: LGTM!

libs/storefront-data/src/product-lists/utils.ts (1)

20-21: LGTM!

libs/storefront-data/src/product-lists/medusa-service.ts (1)

372-374: LGTM!

Also applies to: 387-389

libs/storefront-data/src/product-lists/query-options.ts (1)

11-15: LGTM!

libs/storefront-data/src/product-lists/hooks.ts (6)

74-87: LGTM!


11-35: LGTM!


424-470: LGTM!


604-668: LGTM!


670-738: LGTM!


1023-1045: LGTM!

libs/storefront-data/skills/audit-storefront-before-release/SKILL.md (1)

1-192: LGTM!

libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/SKILL.md (1)

1-236: LGTM!

libs/storefront-data/skills/configure-pagination-prefetch-and-cache-policy/references/prefetch-and-pagination.md (1)

1-46: LGTM!

libs/storefront-data/skills/setup-storefront-platform-in-next-app/SKILL.md (1)

1-210: LGTM!

libs/storefront-data/skills/use-storefront-data-skills/SKILL.md (1)

1-82: LGTM!

libs/storefront-data/skills/decide-app-specific-overrides-vs-shared-platform/SKILL.md (1)

1-195: LGTM!

libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/SKILL.md (1)

1-192: LGTM!

libs/storefront-data/skills/extend-storefront-data-for-new-backend-use-cases/references/extension-recipe.md (1)

1-21: LGTM!

libs/storefront-data/skills/implement-auth-and-customer-session-flows/SKILL.md (1)

1-234: LGTM!

libs/storefront-data/skills/implement-ssr-prefetch-and-query-client-boundaries/SKILL.md (1)

1-224: LGTM!

libs/storefront-data/skills/migrate-custom-hooks-to-storefront-data/SKILL.md (1)

1-192: LGTM!

libs/storefront-data/skills/use-catalog-and-product-read-flows/SKILL.md (1)

1-237: LGTM!

@KaiUweCZE
KaiUweCZE merged commit 3268fae into master Jun 10, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant