Skip to content

Fix/herbatica import - #420

Merged
redeyecz merged 12 commits into
masterfrom
fix/herbatica_import
Jun 4, 2026
Merged

Fix/herbatica import#420
redeyecz merged 12 commits into
masterfrom
fix/herbatica_import

Conversation

@redeyecz

@redeyecz redeyecz commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Herbatica seed config, multi-warehouse stock parsing, generated price lists and price-list sync step; new workflow to import Shoptet/Herbatica feeds.
  • Improvements

    • Inventory and product creation support per-location stock quantities and warehouse-aware seeding.
    • Configurable tax-rate seeding with country defaults and workflow defaults for fulfilment and shipping amounts.
    • Seed workflows reorganised for clearer composition and extensible price-list handling.
  • Tests

    • Expanded unit tests covering price-list parsing, stock/warehouse handling and tax-rate logic.

@semanticdiff-com

semanticdiff-com Bot commented May 26, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts  90% smaller
  apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts  88% smaller
  apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts  88% smaller
  apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts  88% smaller
  apps/medusa-be/src/workflows/seed/workflows/seed-database.ts  84% smaller
  apps/medusa-be/src/workflows/seed/steps/create-products.ts  50% smaller
  apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts  33% smaller
  apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts  18% smaller
  apps/medusa-be/src/workflows/seed/steps/index.ts  18% smaller
  apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts  12% smaller
  apps/medusa-be/src/scripts/herbatica-seed.ts  10% smaller
  apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts  2% smaller
  apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts  1% smaller
  apps/medusa-be/src/scripts/herbatica-seed-config.ts  0% smaller
  apps/medusa-be/src/scripts/seed-dev-data.ts  0% smaller
  apps/medusa-be/src/scripts/seed-n1.ts  0% smaller
  apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts  0% smaller
  apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts  0% smaller
  apps/medusa-be/src/workflows/seed/workflows/index.ts  0% smaller
  apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts  0% smaller
  apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts  0% smaller
  apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts  0% smaller

@vercel

vercel Bot commented May 26, 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 4, 2026 11:13am

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fdd7cbf3-c222-4048-a4dd-1708fe8707ff

📥 Commits

Reviewing files that changed from the base of the PR and between 127e3ba and e52b960.

📒 Files selected for processing (2)
  • apps/medusa-be/src/scripts/herbatica-seed.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📜 Recent 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: Greptile Review
  • GitHub Check: main
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Import UI components using the pattern import { ComponentName } from '@libs/ui/atoms/component-name' or '@libs/ui/molecules/component-name'

Files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Vitest for running tests in backend and UI library projects

Files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
apps/medusa-be/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/**/*.{ts,tsx}: Run npx tsc --noEmit for typechecking before committing
Always use braces around conditional blocks, even for single statements; Biome will expand them
Declare one variable per const/let statement, not multiple on one line
Use nullish coalescing operator (??) instead of logical OR (||) for default values
Do not use non-null assertions (!); use type guards or validation instead
Annotate type as unknown when accessing dynamic object properties before applying type guards
Use comments only to explain 'why', never 'what'; self-document code with clear naming
Extract pure functions to separate files for testability without runtime dependencies
Use Modules.* and ContainerRegistrationKeys.* constants instead of hardcoding module/key strings
Do not use non-null assertions in TypeScript code; validate or use type guards instead
Validate data before type casting; never use as Type without prior validation

Files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
apps/medusa-be/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

Run bunx biome check --write . to lint and auto-format code

Files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
apps/medusa-be/tests/unit/**/*.unit.spec.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/tests/unit/**/*.unit.spec.ts: Focus unit tests on critical paths: validation, money calculations, and core business logic
Skip unit tests for: getters, static arrays, trivial transforms, constants, and pass-through methods
Do not test mocked methods; test real behavior instead
Do not test query.graph() pass-through calls in unit tests
Do not test logging calls; they are implementation details
Use factory functions like createMockEntity(overrides) for test data generation
Use it.each() to test multiple error cases and boundary conditions
Use vi.useFakeTimers() for deterministic time-based testing; use vi.setSystemTime() for absolute time
Clear mocks with mockFn.mockReset() instead of vi.clearAllMocks() for mockResolvedValueOnce chains

Files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
apps/medusa-be/src/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/**/*.ts: Use const and explicit typing with dbService.sqlRaw<Type>() for SQL query results
Resolve logger using container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
Resolve Query using container.resolve<Query>(ContainerRegistrationKeys.QUERY)
Use Modules.LOCKING (not Modules.LOCK) to resolve locking services
Use Modules.CACHING (not Modules.CACHE) to resolve caching services
Throw MedusaError with appropriate type and message for error responses
Use MedusaError.Types.INVALID_DATA for 400 validation errors
Use MedusaError.Types.NOT_FOUND for 404 errors
Use MedusaError.Types.UNAUTHORIZED for 401 authentication errors
Use MedusaError.Types.NOT_ALLOWED for 400 permission errors
Use MedusaError.Types.DUPLICATE_ERROR for 422 duplicate entry errors
Use MedusaError.Types.CONFLICT for 409 conflict errors
Use caching module's computeKey() to generate stable cache keys from filters and pagination
Use caching module's get() with type assertion for cache retrieval
Use caching module's set() with TTL and tags for cache storage and bulk invalidation
Use caching module's clear() with tags to bulk-invalidate related cache entries
Always use Redis for caching in multi-container deployments instead of local variables
Batch operations using CHUNK_SIZE constant instead of unbounded loops

Files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
apps/medusa-be/src/scripts/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/scripts/**/*.ts: Use medusa exec ./path/to/script.ts [args] to run one-off scripts instead of creating HTTP endpoints
Use script pattern npx medusa exec ./src/scripts/startup.ts in startup hooks
Use destructive operations in medusa exec scripts, never in unprotected GET endpoints

Files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
🧠 Learnings (14)
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Focus unit tests on critical paths: validation, money calculations, and core business logic

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-21T11:46:40.903Z
Learnt from: redeyecz
Repo: TechsioCZ/new-engine PR: 323
File: apps/medusa-be/integration-tests/http/promotions-custom-rules.spec.ts:0-0
Timestamp: 2026-05-21T11:46:40.903Z
Learning: In `apps/medusa-be/integration-tests/http/promotions-custom-rules.spec.ts`, the test intentionally uses a custom `requestJson`/`createClient`/`fetch`-based HTTP harness (running against a full Docker stack) instead of `medusaIntegrationTestRunner()`. This is a deliberate decision because `medusaIntegrationTestRunner()` had issues with publishable-key resolution in the monorepo due to package-hoisting caveats. Do not flag the absence of `medusaIntegrationTestRunner()` in this file; it is marked for future refactoring when the monorepo/hoisting issue is resolved.

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Use factory functions like `createMockEntity(overrides)` for test data generation

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Skip unit tests for: getters, static arrays, trivial transforms, constants, and pass-through methods

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/jobs/**/*.spec.ts : Place job tests in `tests/unit/jobs/` not in `src/jobs/__tests__/` to avoid Medusa loading them at runtime

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Use `it.each()` to test multiple error cases and boundary conditions

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/*/__tests__/*.spec.ts : Wrap missing dependency resolution in try/catch in integration tests; Awilix throws even with nullish coalescing

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/integration-tests/http/**/*.spec.ts : Write HTTP integration tests for: business logic routes, security-critical middleware, multi-step DB ops

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Do not test mocked methods; test real behavior instead

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Do not test `query.graph()` pass-through calls in unit tests

Applied to files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Validate data before type casting; never use `as Type` without prior validation

Applied to files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Annotate type as `unknown` when accessing dynamic object properties before applying type guards

Applied to files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Do not use non-null assertions (`!`); use type guards or validation instead

Applied to files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Do not use non-null assertions in TypeScript code; validate or use type guards instead

Applied to files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
🔇 Additional comments (2)
apps/medusa-be/src/scripts/herbatica-seed.ts (1)

3301-3305: LGTM!

apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts (1)

254-287: LGTM!


Walkthrough

Adds Herbatica seed configuration and extends the Shoptet import pipeline to parse multi-warehouse stock, generate and sync override/sale price lists, seed configurable VAT/tax rules, introduce workflow defaults, and refactor workflows/steps with corresponding unit tests.

Changes

Herbatica Shoptet Import Workflow

Layer / File(s) Summary
Herbatica configuration constants
apps/medusa-be/src/scripts/herbatica-seed-config.ts
New configuration file exporting Herbatica-specific constants: environment variable names, XML paths, supported countries/currencies/regions, default stock locations, workflow defaults (fulfillment provider and shipping option pricing), shipping profiles, fulfillment sets, shipping options with multi-currency pricing, and synchronisation/tax-rate configurations.
Inventory and product type enhancements
apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts, apps/medusa-be/src/workflows/seed/steps/create-products.ts, apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
Type definitions updated to support per-stock-location inventory quantities. CreateInventoryLevelsStepInput now allows optional per-item locations with per-location quantity, CreateProductsStepInput variant types now support optional locations array, and buildInventoryItemsInput maps variants to inventory-items preferring per-location data. Inventory generation logic refactored into buildInventoryLevelsForItem.
Configurable tax-rate seeding policy
apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts, apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts
Refactored tax-rate seeding from hard-coded OSS metadata to configurable policy model. Introduced TaxRateSeedConfig/TaxRateSeedTargets types, metadata-path-based VAT extraction, template-driven code/name generation with configurable patterns, grouping of product overrides by VAT rate per country, and reconciliation logic comparing rebuilt product rule sets. Unit tests validate policy behaviour and identity generation.
Price list synchronisation step
apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts, apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
New Medusa workflow step for syncing price lists and variant prices. Defines SyncPriceListsStepConfig/SyncPriceListsStepInput, builds override and sale price lists with optional customer-group rules, ensures price lists exist or are updated, provisions customer groups, and syncs per-variant prices with create/update/skip tracking and tolerant amount comparison. Tests cover parsed price-list generation and sync wiring.
Herbatica XML parsing extensions
apps/medusa-be/src/scripts/herbatica-seed.ts, apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
Extended parser to extract multi-warehouse stock via parseStockWarehouses, resolve stock locations with name fallback and address mapping, generate base and sale price lists from variant metadata with action-window date logic, aggregate warnings, and expose priceLists/stockLocations in BuildResult. Tests expanded for price-list and stock parsing and for workflow input construction.
Seed workflow defaults infrastructure
apps/medusa-be/src/workflows/seed/workflows/seed-database.ts, apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts, apps/medusa-be/src/scripts/seed-dev-data.ts, apps/medusa-be/src/scripts/seed-n1.ts
Added workflowDefaults to workflow inputs to supply fallback fulfillmentProviderId and shippingOptionPriceAmount. Workflows now use these defaults for fulfilment linking and shipping option amounts; seed scripts updated to pass defaults.
Seed database workflow refactoring
apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
Refactored into named seedDatabaseWorkflowComposer. Integrated syncPriceListsStep after product creation, derive shipping/provider defaults from workflowDefaults, always invoke tax-rate step with enabled flag, and use buildInventoryItemsInput for inventory items.
Seed N1 workflow updates
apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
Updated to use workflowDefaults for fulfillment provider and shipping option pricing with fallback logic. Delegates inventory item construction to buildInventoryItemsInput.
Supporting step and preference updates
apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts, apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts, apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
Minor refactor/formatting: normalized ID/currency helpers formatting preserved semantics; fulfilment provider linking now normalises/deduplicates provider IDs and returns early with a warning when none provided; removed an inline comment in shipping-options type.
Workflow composition and export refactoring
apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts, apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts, apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts, apps/medusa-be/src/workflows/seed/steps/index.ts, apps/medusa-be/src/workflows/seed/workflows/index.ts
Extracted inline composers into named functions for categories and Paykit regions, added seed-shoptet-import-workflow that delegates to seedDatabaseWorkflow, and reordered barrel exports for seed steps and workflows.
Test coverage for Herbatica seeding
apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts, apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts, apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
Added and extended unit tests validating price-list override/sale parsing, warehouse stock parsing with location mapping and fallback warnings, tax-rate policy grouping and identity naming, and workflow input wiring with expected defaults and configuration pass-through.

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'Fix/herbatica import' is vague and generic, using a conventional commit prefix without describing the specific changes made to the Herbatica import workflow. Consider a more descriptive title that conveys the main changes, such as 'Add multi-warehouse stock and price-list support to Herbatica import workflow' or similar.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/herbatica_import
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/herbatica_import

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented May 26, 2026

Copy link
Copy Markdown

Greptile Summary

This PR extracts Herbatica seed configuration into a dedicated config file, adds multi-warehouse stock parsing from the Shoptet XML feed, introduces a new syncPriceListsStep for idempotent price-list management, and refactors the tax-rate step to be config-driven with explicit per-country default rates instead of deriving the default from product metadata.

  • Config extraction: All Herbatica-specific constants (currencies, countries, tax rates, shipping options) moved to herbatica-seed-config.ts; buildInventoryItemsInput de-duplicated into a shared helper.
  • Multi-warehouse inventory: create-inventory-levels step now accepts per-location quantities; herbatica-seed.ts parses <WAREHOUSES> blocks and maps them to stock locations, with a named fallback for unnamed entries.
  • Price-list sync: New syncPriceListsStep upserts override and sale price lists with customer-group rules; herbatica-seed.ts builds these from per-variant XML price-list data after SKU deduplication.
  • Tax-rate refactor: createTaxRatesStep now accepts a TaxRateSeedConfig with explicit defaultRates and optional productOverrides, replacing the previous per-product metadata scan.

Confidence Score: 4/5

Safe to merge for a one-time fresh-DB seed; if re-seeding is ever needed, the product-rule accumulation in create-tax-rates.ts should be addressed first.

The accumulation of stale product rules in createTaxRatesStep means that on any re-seed run a product whose VAT rate changed will remain in both the old and new rate's rule set, letting Medusa's priority logic silently pick the wrong rate. For the documented single-run use-case this is inert, but the step is general-purpose and called from multiple workflows, so the defect travels with any future caller that runs it more than once.

apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts — the rule-merge logic at lines 641–647.

Important Files Changed

Filename Overview
apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts Major refactor to config-driven tax-rate seeding with per-country default rates and product VAT overrides; contains a rule-accumulation bug when the step is re-run.
apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts New step for syncing Shoptet/override price lists and customer groups into Medusa; logic is well-structured with idempotent upserts.
apps/medusa-be/src/scripts/herbatica-seed-config.ts Extracts previously inline Herbatica seed constants into a dedicated config file; EUR set as default currency (confirmed intentional for SK-based store).
apps/medusa-be/src/scripts/herbatica-seed.ts Adds multi-warehouse stock parsing, price-list generation from XML feeds, and refactors seed orchestration to use the new shoptet-import workflow.
apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts New shared helper that eliminates the duplicated buildInventoryItemsInput logic from seed-database.ts and seed-n1.ts.
apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts Extended to support per-location stock quantities in addition to flat quantity; throws MedusaError on missing inventory item or stock location.
apps/medusa-be/src/workflows/seed/workflows/seed-database.ts Refactored from inline workflow function to a composer function; adds workflowDefaults, priceLists, and priceListSync inputs; replaces bare Error throws with MedusaError.
apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts Expanded unit tests covering price-list parsing, warehouse stock handling, and SKU deduplication interactions.
apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts New unit tests covering buildTaxRateSeedTargets with various country, rate, and metadata configurations.
apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts Thin new workflow that delegates to seedDatabaseWorkflow as a step; clean composition pattern.

Sequence Diagram

sequenceDiagram
    participant Script as herbatica-seed.ts
    participant SIW as seedShoptetImportWorkflow
    participant SDW as seedDatabaseWorkflow
    participant CIL as createInventoryLevelsStep
    participant CTR as createTaxRatesStep
    participant SPL as syncPriceListsStep

    Script->>Script: parseXmlFeed (products + categories)
    Script->>Script: enforceUniqueVariantSkus
    Script->>Script: buildPriceListsFromProducts
    Script->>Script: buildStockLocationsFromOffers
    Script->>SIW: run(SeedShoptetImportWorkflowInput)
    SIW->>SDW: runAsStep(input)
    SDW->>CIL: createInventoryLevelsStep(inventoryItems with per-location quantities)
    CIL-->>SDW: inventory levels created
    SDW->>CTR: createTaxRatesStep(productIds, config with defaultRates)
    CTR-->>SDW: tax rates created/updated
    SDW->>SPL: syncPriceListsStep(productIds, priceLists)
    SPL->>SPL: ensureCustomerGroups
    SPL->>SPL: ensurePriceLists (upsert)
    SPL->>SPL: syncPriceListPrices (create/update)
    SPL-->>SDW: price lists synced
    SDW-->>SIW: result
    SIW-->>Script: done
Loading

Fix All in Codex

Reviews (5): Last reviewed commit: "fix(seed): import sku deduplication orde..." | Re-trigger Greptile

Comment thread apps/medusa-be/src/scripts/herbatica-seed.ts
Comment thread apps/medusa-be/src/scripts/herbatica-seed-config.ts
Comment thread apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts Outdated
Comment thread apps/medusa-be/src/scripts/herbatica-seed.ts
Comment thread apps/medusa-be/src/workflows/seed/workflows/seed-database.ts Outdated

@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: 9

🤖 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 `@apps/medusa-be/src/scripts/herbatica-seed.ts`:
- Around line 2936-2941: The current getVariantMetadata(variant:
VariantSeedInput) simply casts variant.metadata with "as" without validation;
replace the direct cast with a type guard that checks variant.metadata is a
non-null object and not an array (e.g., typeof metadata === 'object' && metadata
!== null && !Array.isArray(metadata')) and only then return it as Record<string,
unknown>, otherwise return undefined; update the function to reference
VariantSeedInput and variant.metadata and avoid plain "as" casting.

In `@apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts`:
- Around line 37-50: buildInventoryLevelsForItem currently throws generic Error
when an inventory item or stock location is missing; change those throws to
throw new MedusaError(MedusaError.Types.NOT_FOUND, ...) so they follow the
backend error contract. Locate the two throw sites inside
buildInventoryLevelsForItem (the `if (inventoryItem.id === undefined)` and the
`if (!stockLocation)` branches) and replace the generic Error with MedusaError
using the same descriptive messages and MedusaError.Types.NOT_FOUND.

In `@apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts`:
- Around line 83-97: The two independent calls to
pricingService.listPricePreferences (for regionIds and currencyCodes) are
executed serially; change them to run in parallel using Promise.all so latency
is reduced: create two promise expressions (guarded by regionIds.length>0 and
currencyCodes.length>0) that call pricingService.listPricePreferences for
attribute "region_id" with value regionIds and attribute "currency_code" with
value currencyCodes, await Promise.all to get both results, and assign the
resolved values to existingRegionPreferences and existingCurrencyPreferences
(defaulting to [] if the corresponding input array was empty).

In
`@apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts`:
- Around line 25-33: Sanitise input.fulfillmentProviderIds before deduping to
remove empty/blank IDs: normalize the array (guarding for undefined), map each
id => id?.toString().trim(), filter out falsy/empty strings, then create
providerIds = [...new Set(sanitisedArray)]; update the subsequent length check
and return via StepResponse({ result }) as before; reference the variables
input.fulfillmentProviderIds and providerIds in
link-stock-location-fulfillment-provider.ts to locate and replace the current
dedupe logic.

In `@apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts`:
- Around line 650-656: The code casts the result of remoteQuery(...) to
VariantPriceSetLink[] directly (used to set variantPriceSetLinks) without
validation; update the logic around the remoteQuery call to validate the
returned value before the type assertion: check that the result is an array and
each item has the expected properties (variant_id and price_set_id) and correct
types, or implement and call a type guard function (e.g.,
isVariantPriceSetLinkArray) before assigning to variantPriceSetLinks; on
validation failure either log/throw a clear error or fall back to an empty array
so the rest of the workflow handling (variantPriceSetLinks, variantIds) remains
safe.

In `@apps/medusa-be/src/workflows/seed/workflows/seed-database.ts`:
- Around line 77-79: Replace raw Error throws with MedusaError: import
MedusaError from "medusa-core-utils" and change occurrences like throw new
Error("No default sales channel found") (and the other throw sites around
defaultSalesChannel and the ranges you noted) to throw new
MedusaError(MedusaError.Types.NOT_FOUND, "No default sales channel found") or
the appropriate MedusaError.Types constant for each case; ensure you use the
unique identifiers (e.g., defaultSalesChannel and the throw expressions
currently raising Error in the seed-database workflow) so every raw throw is
converted to a typed MedusaError with a clear message.
- Around line 64-65: Several inline comments in seed-database.ts are simple
"what" comments that just restate the following line (e.g., the comment
immediately before the Steps.createSalesChannelsStep call and the other listed
locations); remove those redundant comments and replace only where necessary
with intent-focused comments that explain why the step exists, any important
constraints, or rationale (for example, explain why createSalesChannelsStep is
invoked with input.salesChannels, any ordering or transactional requirements, or
edge-case assumptions). Scan for comments adjacent to
Steps.createSalesChannelsStep, other Steps.* calls, and the listed regions and
either delete them or rewrite them to capture intent/constraints rather than
restating the code.

In `@apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts`:
- Around line 43-73: The function buildInventoryItemsInput is a pure helper and
should be extracted to its own utility module to improve testability; create a
new file (e.g., a utils or helpers module) exporting buildInventoryItemsInput
with the same signature (accepting Steps.CreateProductsStepInput and returning
Steps.CreateInventoryLevelsStepInput["inventoryItems"]) and update the workflow
to import and use that exported function; ensure you move any needed type
imports (Steps...) to the new module and add unit tests for
buildInventoryItemsInput while keeping behavior identical (handling missing sku,
locations vs quantity).
- Around line 258-260: Guard access to data.createPublishableKeyResult.result[0]
in seed-n1.ts by checking that data.createPublishableKeyResult and its result
array contain an element before casting to ApiKeyDTO (mirror the null-guard
pattern used in seed-database.ts when returning publishableApiKey), and throw or
handle a clear error if missing; additionally extract the inline
buildInventoryItemsInput function (currently defined lines ~43-73) into a shared
module (e.g., export from a new utility file) and replace the inline definition
with an import and call to that exported buildInventoryItemsInput to remove
duplication and improve testability.
🪄 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: ed13ab48-7005-4178-9030-4a54a2ac35d1

📥 Commits

Reviewing files that changed from the base of the PR and between e718fca and f7653d0.

📒 Files selected for processing (20)
  • apps/medusa-be/src/scripts/herbatica-seed-config.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
  • apps/medusa-be/src/scripts/seed-dev-data.ts
  • apps/medusa-be/src/scripts/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.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 (10)
apps/medusa-be/src/workflows/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Place business logic workflows under apps/medusa-be/src/workflows

Files:

  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Import UI components using the pattern import { ComponentName } from '@libs/ui/atoms/component-name' or '@libs/ui/molecules/component-name'

Files:

  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed-config.ts
  • apps/medusa-be/src/scripts/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/scripts/seed-dev-data.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
apps/medusa-be/src/{api,modules,workflows,admin,subscribers,jobs}/**

📄 CodeRabbit inference engine (AGENTS.md)

In Medusa backend applications, organize custom code using the directory structure: api/, modules/, workflows/, admin/, subscribers/, jobs/

Files:

  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
apps/medusa-be/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/**/*.{ts,tsx}: Run npx tsc --noEmit for typechecking before committing
Always use braces around conditional blocks, even for single statements; Biome will expand them
Declare one variable per const/let statement, not multiple on one line
Use nullish coalescing operator (??) instead of logical OR (||) for default values
Do not use non-null assertions (!); use type guards or validation instead
Annotate type as unknown when accessing dynamic object properties before applying type guards
Use comments only to explain 'why', never 'what'; self-document code with clear naming
Extract pure functions to separate files for testability without runtime dependencies
Use Modules.* and ContainerRegistrationKeys.* constants instead of hardcoding module/key strings
Do not use non-null assertions in TypeScript code; validate or use type guards instead
Validate data before type casting; never use as Type without prior validation

Files:

  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed-config.ts
  • apps/medusa-be/src/scripts/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/scripts/seed-dev-data.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
apps/medusa-be/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

Run bunx biome check --write . to lint and auto-format code

Files:

  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed-config.ts
  • apps/medusa-be/src/scripts/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/scripts/seed-dev-data.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
apps/medusa-be/src/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/**/*.ts: Use const and explicit typing with dbService.sqlRaw<Type>() for SQL query results
Resolve logger using container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
Resolve Query using container.resolve<Query>(ContainerRegistrationKeys.QUERY)
Use Modules.LOCKING (not Modules.LOCK) to resolve locking services
Use Modules.CACHING (not Modules.CACHE) to resolve caching services
Throw MedusaError with appropriate type and message for error responses
Use MedusaError.Types.INVALID_DATA for 400 validation errors
Use MedusaError.Types.NOT_FOUND for 404 errors
Use MedusaError.Types.UNAUTHORIZED for 401 authentication errors
Use MedusaError.Types.NOT_ALLOWED for 400 permission errors
Use MedusaError.Types.DUPLICATE_ERROR for 422 duplicate entry errors
Use MedusaError.Types.CONFLICT for 409 conflict errors
Use caching module's computeKey() to generate stable cache keys from filters and pagination
Use caching module's get() with type assertion for cache retrieval
Use caching module's set() with TTL and tags for cache storage and bulk invalidation
Use caching module's clear() with tags to bulk-invalidate related cache entries
Always use Redis for caching in multi-container deployments instead of local variables
Batch operations using CHUNK_SIZE constant instead of unbounded loops

Files:

  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed-config.ts
  • apps/medusa-be/src/scripts/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/scripts/seed-dev-data.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
apps/medusa-be/src/workflows/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/workflows/**/*.ts: Use the second parameter { container } object to access container in workflow steps
Use createStep() to define workflow steps with input validation and response wrapping
Use createWorkflow() to define multi-step business logic with rollback support
Return new StepResponse() from workflow steps to pass data to next steps
Return new WorkflowResponse() from workflows to pass final result to caller
Use transform() in workflows for data manipulation only; cannot contain side effects
Use when().then() for conditional logic in workflows instead of if statements
Do not reassign or iterate workflow variables; variable definitions are static at definition time
Use useQueryGraphStep() for Query operations within workflows
Use acquireLockStep(), releaseLockStep() for workflow-level locking instead of manual job locking

Files:

  • apps/medusa-be/src/workflows/seed/workflows/index.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts
  • apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/create-products.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/workflows/seed/steps/index.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Vitest for running tests in backend and UI library projects

Files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
apps/medusa-be/tests/unit/**/*.unit.spec.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/tests/unit/**/*.unit.spec.ts: Focus unit tests on critical paths: validation, money calculations, and core business logic
Skip unit tests for: getters, static arrays, trivial transforms, constants, and pass-through methods
Do not test mocked methods; test real behavior instead
Do not test query.graph() pass-through calls in unit tests
Do not test logging calls; they are implementation details
Use factory functions like createMockEntity(overrides) for test data generation
Use it.each() to test multiple error cases and boundary conditions
Use vi.useFakeTimers() for deterministic time-based testing; use vi.setSystemTime() for absolute time
Clear mocks with mockFn.mockReset() instead of vi.clearAllMocks() for mockResolvedValueOnce chains

Files:

  • apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts
  • apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts
apps/medusa-be/src/scripts/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/scripts/**/*.ts: Use medusa exec ./path/to/script.ts [args] to run one-off scripts instead of creating HTTP endpoints
Use script pattern npx medusa exec ./src/scripts/startup.ts in startup hooks
Use destructive operations in medusa exec scripts, never in unprotected GET endpoints

Files:

  • apps/medusa-be/src/scripts/herbatica-seed-config.ts
  • apps/medusa-be/src/scripts/seed-n1.ts
  • apps/medusa-be/src/scripts/seed-dev-data.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
🔇 Additional comments (19)
apps/medusa-be/tests/unit/herbatica/herbatica-seed.unit.spec.ts (1)

9-18: LGTM!

Also applies to: 151-151, 155-170, 190-505, 754-802, 837-841

apps/medusa-be/tests/unit/herbatica/herbatica-tax-rates.unit.spec.ts (1)

1-155: LGTM!

apps/medusa-be/src/workflows/seed/workflows/seed-categories.ts (1)

17-44: LGTM!

apps/medusa-be/src/workflows/seed/workflows/seed-paykit-regions.ts (1)

35-102: LGTM!

apps/medusa-be/src/workflows/seed/workflows/seed-shoptet-import.ts (1)

1-27: LGTM!

apps/medusa-be/src/workflows/seed/workflows/index.ts (1)

1-3: LGTM!

apps/medusa-be/src/workflows/seed/steps/index.ts (1)

1-20: LGTM!

apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts (1)

1-713: LGTM!

apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts (1)

1-149: LGTM!

Also applies to: 158-649, 657-681

apps/medusa-be/src/scripts/herbatica-seed.ts (1)

1-2935: LGTM!

Also applies to: 2942-3545

apps/medusa-be/src/scripts/herbatica-seed-config.ts (1)

6-231: LGTM!

apps/medusa-be/src/scripts/seed-dev-data.ts (1)

26-29: LGTM!

apps/medusa-be/src/scripts/seed-n1.ts (1)

51-54: LGTM!

apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts (1)

20-24: LGTM!

Also applies to: 28-31, 61-71, 91-105

apps/medusa-be/src/workflows/seed/steps/create-products.ts (1)

74-77: LGTM!

Also applies to: 203-205

apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts (1)

26-29: LGTM!

Also applies to: 75-257, 263-305

apps/medusa-be/src/workflows/seed/steps/create-shipping-options.ts (1)

47-47: LGTM!

apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts (1)

8-8: LGTM!

apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts (1)

1-3: LGTM!

Also applies to: 23-23, 32-32, 37-37, 61-64, 98-101

Comment thread apps/medusa-be/src/scripts/herbatica-seed.ts
Comment thread apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
Comment thread apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts Outdated
Comment thread apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
Comment thread apps/medusa-be/src/workflows/seed/workflows/seed-database.ts Outdated
Comment thread apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
Comment thread apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts Outdated
Comment thread apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts Outdated
@greptile-apps

greptile-apps Bot commented May 26, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

Comment thread apps/medusa-be/src/workflows/seed/steps/sync-price-lists.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.

Caution

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

⚠️ Outside diff range comments (1)
apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts (1)

58-60: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Use MedusaError instead of raw Error for consistent error handling.

Several throw new Error(...) statements remain in this workflow (lines 59, 125-127, 154-156, 162-164), whilst the same errors in seed-database.ts now use MedusaError.Types.NOT_FOUND. This creates inconsistency between the two seed workflows.

♻️ Proposed fix for consistent error handling
       if (!defaultSalesChannel) {
-        throw new Error("No default sales channel found")
+        throw new MedusaError(
+          MedusaError.Types.NOT_FOUND,
+          "No default sales channel found"
+        )
       }

Apply the same pattern to lines 125-127, 154-156, and 162-164.

As per coding guidelines: "Throw MedusaError with appropriate type and message for error responses".

🤖 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 `@apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts` around lines 58 - 60,
Replace raw Error throws in this workflow with MedusaError for consistent
handling: import MedusaError from medusa-core-utils if not already present, then
change each throw new Error("...") (e.g., the check that throws when
defaultSalesChannel is missing and the other throw sites in this file) to throw
new MedusaError(MedusaError.Types.NOT_FOUND, "<same message>"); ensure you use
MedusaError.Types.NOT_FOUND and keep the original error messages for clarity.
🤖 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.

Outside diff comments:
In `@apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts`:
- Around line 58-60: Replace raw Error throws in this workflow with MedusaError
for consistent handling: import MedusaError from medusa-core-utils if not
already present, then change each throw new Error("...") (e.g., the check that
throws when defaultSalesChannel is missing and the other throw sites in this
file) to throw new MedusaError(MedusaError.Types.NOT_FOUND, "<same message>");
ensure you use MedusaError.Types.NOT_FOUND and keep the original error messages
for clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: be66e01d-c039-40d8-bcdc-626418ea08dc

📥 Commits

Reviewing files that changed from the base of the PR and between f7653d0 and 127e3ba.

📒 Files selected for processing (9)
  • apps/medusa-be/src/scripts/herbatica-seed.ts
  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.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: Greptile Review
  • GitHub Check: main
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (10)
apps/medusa-be/src/workflows/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Place business logic workflows under apps/medusa-be/src/workflows

Files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Import UI components using the pattern import { ComponentName } from '@libs/ui/atoms/component-name' or '@libs/ui/molecules/component-name'

Files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
apps/medusa-be/src/{api,modules,workflows,admin,subscribers,jobs}/**

📄 CodeRabbit inference engine (AGENTS.md)

In Medusa backend applications, organize custom code using the directory structure: api/, modules/, workflows/, admin/, subscribers/, jobs/

Files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
apps/medusa-be/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/**/*.{ts,tsx}: Run npx tsc --noEmit for typechecking before committing
Always use braces around conditional blocks, even for single statements; Biome will expand them
Declare one variable per const/let statement, not multiple on one line
Use nullish coalescing operator (??) instead of logical OR (||) for default values
Do not use non-null assertions (!); use type guards or validation instead
Annotate type as unknown when accessing dynamic object properties before applying type guards
Use comments only to explain 'why', never 'what'; self-document code with clear naming
Extract pure functions to separate files for testability without runtime dependencies
Use Modules.* and ContainerRegistrationKeys.* constants instead of hardcoding module/key strings
Do not use non-null assertions in TypeScript code; validate or use type guards instead
Validate data before type casting; never use as Type without prior validation

Files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
apps/medusa-be/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

Run bunx biome check --write . to lint and auto-format code

Files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
apps/medusa-be/src/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/**/*.ts: Use const and explicit typing with dbService.sqlRaw<Type>() for SQL query results
Resolve logger using container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
Resolve Query using container.resolve<Query>(ContainerRegistrationKeys.QUERY)
Use Modules.LOCKING (not Modules.LOCK) to resolve locking services
Use Modules.CACHING (not Modules.CACHE) to resolve caching services
Throw MedusaError with appropriate type and message for error responses
Use MedusaError.Types.INVALID_DATA for 400 validation errors
Use MedusaError.Types.NOT_FOUND for 404 errors
Use MedusaError.Types.UNAUTHORIZED for 401 authentication errors
Use MedusaError.Types.NOT_ALLOWED for 400 permission errors
Use MedusaError.Types.DUPLICATE_ERROR for 422 duplicate entry errors
Use MedusaError.Types.CONFLICT for 409 conflict errors
Use caching module's computeKey() to generate stable cache keys from filters and pagination
Use caching module's get() with type assertion for cache retrieval
Use caching module's set() with TTL and tags for cache storage and bulk invalidation
Use caching module's clear() with tags to bulk-invalidate related cache entries
Always use Redis for caching in multi-container deployments instead of local variables
Batch operations using CHUNK_SIZE constant instead of unbounded loops

Files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
apps/medusa-be/src/workflows/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/workflows/**/*.ts: Use the second parameter { container } object to access container in workflow steps
Use createStep() to define workflow steps with input validation and response wrapping
Use createWorkflow() to define multi-step business logic with rollback support
Return new StepResponse() from workflow steps to pass data to next steps
Return new WorkflowResponse() from workflows to pass final result to caller
Use transform() in workflows for data manipulation only; cannot contain side effects
Use when().then() for conditional logic in workflows instead of if statements
Do not reassign or iterate workflow variables; variable definitions are static at definition time
Use useQueryGraphStep() for Query operations within workflows
Use acquireLockStep(), releaseLockStep() for workflow-level locking instead of manual job locking

Files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Vitest for running tests in backend and UI library projects

Files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
apps/medusa-be/tests/unit/**/*.unit.spec.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/tests/unit/**/*.unit.spec.ts: Focus unit tests on critical paths: validation, money calculations, and core business logic
Skip unit tests for: getters, static arrays, trivial transforms, constants, and pass-through methods
Do not test mocked methods; test real behavior instead
Do not test query.graph() pass-through calls in unit tests
Do not test logging calls; they are implementation details
Use factory functions like createMockEntity(overrides) for test data generation
Use it.each() to test multiple error cases and boundary conditions
Use vi.useFakeTimers() for deterministic time-based testing; use vi.setSystemTime() for absolute time
Clear mocks with mockFn.mockReset() instead of vi.clearAllMocks() for mockResolvedValueOnce chains

Files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
apps/medusa-be/src/scripts/**/*.ts

📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)

apps/medusa-be/src/scripts/**/*.ts: Use medusa exec ./path/to/script.ts [args] to run one-off scripts instead of creating HTTP endpoints
Use script pattern npx medusa exec ./src/scripts/startup.ts in startup hooks
Use destructive operations in medusa exec scripts, never in unprotected GET endpoints

Files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
🧠 Learnings (48)
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Use `createStep()` to define workflow steps with input validation and response wrapping

Applied to files:

  • apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts
  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Use factory functions like `createMockEntity(overrides)` for test data generation

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/jobs/**/*.spec.ts : Place job tests in `tests/unit/jobs/` not in `src/jobs/__tests__/` to avoid Medusa loading them at runtime

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Skip unit tests for: getters, static arrays, trivial transforms, constants, and pass-through methods

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/*/__tests__/*.spec.ts : Mock loaders in tests using `vi.mock()` to prevent actual initialization during testing

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Focus unit tests on critical paths: validation, money calculations, and core business logic

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
📚 Learning: 2026-05-21T11:46:40.903Z
Learnt from: redeyecz
Repo: TechsioCZ/new-engine PR: 323
File: apps/medusa-be/integration-tests/http/promotions-custom-rules.spec.ts:0-0
Timestamp: 2026-05-21T11:46:40.903Z
Learning: In `apps/medusa-be/integration-tests/http/promotions-custom-rules.spec.ts`, the test intentionally uses a custom `requestJson`/`createClient`/`fetch`-based HTTP harness (running against a full Docker stack) instead of `medusaIntegrationTestRunner()`. This is a deliberate decision because `medusaIntegrationTestRunner()` had issues with publishable-key resolution in the monorepo due to package-hoisting caveats. Do not flag the absence of `medusaIntegrationTestRunner()` in this file; it is marked for future refactoring when the monorepo/hoisting issue is resolved.

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/jobs/**/*.ts : Do not place test files in `src/jobs/__tests__/` as Medusa loads all `src/jobs/` files at runtime

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Clear mocks with `mockFn.mockReset()` instead of `vi.clearAllMocks()` for `mockResolvedValueOnce` chains

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Do not test `query.graph()` pass-through calls in unit tests

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/tests/unit/**/*.unit.spec.ts : Use `vi.useFakeTimers()` for deterministic time-based testing; use `vi.setSystemTime()` for absolute time

Applied to files:

  • apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/*/provider.ts : Use container key format `fp_{identifier}_{id}` for fulfillment provider registration

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/**/models/*.ts : Use provider identifier format `{identifier}_{id}` in DB `provider_id` field (e.g., `my_shipping_default`)

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
📚 Learning: 2026-05-07T19:18:05.075Z
Learnt from: redeyecz
Repo: TechsioCZ/new-engine PR: 390
File: apps/medusa-be/src/api/admin/packeta-labels/route.ts:121-121
Timestamp: 2026-05-07T19:18:05.075Z
Learning: In `apps/medusa-be`, the hard-coded fulfillment provider ID string (e.g. `"packeta_packeta"`) is intentionally kept inline for now, consistent with the PPL implementation pattern. Extracting these into shared constants (e.g. `PACKETA_FULFILLMENT_PROVIDER_ID`) is deferred to a future refactor pass when more providers are added. Do not flag this as an issue in code reviews.

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Use `transform()` in workflows for data manipulation only; cannot contain side effects

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-04-27T14:21:32.929Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/zane-operator/AGENTS.md:0-0
Timestamp: 2026-04-27T14:21:32.929Z
Learning: Applies to apps/zane-operator/src/**/*.ts : Preserve deterministic preview DB/user naming and password derivation logic

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Use `Modules.*` and `ContainerRegistrationKeys.*` constants instead of hardcoding module/key strings

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/**/models/*.ts : Use `model.float()` for lower-precision numbers; use `model.bigNumber()` for high-precision values like money

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
📚 Learning: 2026-05-06T13:05:32.880Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/payload/.cursor/rules/access-control-advanced.md:0-0
Timestamp: 2026-05-06T13:05:32.880Z
Learning: Applies to apps/payload/**/*.{ts,tsx} : Avoid multiple sequential async calls in access control functions; instead use query constraints or cache expensive lookups in `req.context` for performance

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/*/service.ts : Use workflows for cross-module orchestration; do not use Query/Link in module service constructors

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-06T13:05:32.880Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/payload/.cursor/rules/access-control-advanced.md:0-0
Timestamp: 2026-05-06T13:05:32.880Z
Learning: Applies to apps/payload/**/*.{ts,tsx} : Avoid N+1 query problems by using query constraint filters instead of loading individual documents to check access; let the database filter at query level

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Use `createWorkflow()` to define multi-step business logic with rollback support

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Extract pure functions to separate files for testability without runtime dependencies

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Do not use non-null assertions (`!`); use type guards or validation instead

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Do not use non-null assertions in TypeScript code; validate or use type guards instead

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
📚 Learning: 2026-04-27T14:21:32.929Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/zane-operator/AGENTS.md:0-0
Timestamp: 2026-04-27T14:21:32.929Z
Learning: Applies to apps/zane-operator/{apps/zane-operator/src/**/*.ts,docker/development/postgres/*.sh} : Do not broaden privileges to 'make it work'; if broad prod access is requested, gate it behind explicit opt-in flags

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Do not reassign or iterate workflow variables; variable definitions are static at definition time

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Return `new StepResponse()` from workflow steps to pass data to next steps

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Return `new WorkflowResponse()` from workflows to pass final result to caller

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Use `useQueryGraphStep()` for Query operations within workflows

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Use the second parameter `{ container }` object to access container in workflow steps

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Use `acquireLockStep()`, `releaseLockStep()` for workflow-level locking instead of manual job locking

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Use `MedusaError.Types.NOT_FOUND` for 404 errors

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Throw `MedusaError` with appropriate type and message for error responses

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Use `MedusaError.Types.INVALID_DATA` for 400 validation errors

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Use `MedusaError.Types.DUPLICATE_ERROR` for 422 duplicate entry errors

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Use `MedusaError.Types.CONFLICT` for 409 conflict errors

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/integration-tests/http/**/*.spec.ts : Use `throwOnError: false` in workflow integration tests to capture step errors for assertion

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/*/__tests__/*.spec.ts : Wrap missing dependency resolution in try/catch in integration tests; Awilix throws even with nullish coalescing

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Use `MedusaError.Types.UNAUTHORIZED` for 401 authentication errors

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-07T19:51:42.430Z
Learnt from: redeyecz
Repo: TechsioCZ/new-engine PR: 390
File: apps/medusa-be/src/modules/packeta-client/client.ts:108-114
Timestamp: 2026-05-07T19:51:42.430Z
Learning: In `apps/medusa-be/src/modules/packeta-client/client.ts`, the `cancelPacket` method intentionally uses a broad `catch` that returns `false` for all failures (transport errors, timeouts, Packeta refusals alike). This is a known, accepted trade-off for the current implementation. A future improvement to consider is adding warning-level logging inside the catch before returning `false`, so transport/timeout failures are still surfaced in observability tooling. Do not flag this pattern as a blocking issue in future reviews of this file.

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Use `MedusaError.Types.NOT_ALLOWED` for 400 permission errors

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/**/*.ts : Resolve Query using `container.resolve<Query>(ContainerRegistrationKeys.QUERY)`

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts
  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Use comments only to explain 'why', never 'what'; self-document code with clear naming

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/workflows/**/*.ts : Use `when().then()` for conditional logic in workflows instead of if statements

Applied to files:

  • apps/medusa-be/src/workflows/seed/workflows/seed-database.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Validate data before type casting; never use `as Type` without prior validation

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
  • apps/medusa-be/src/scripts/herbatica-seed.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/src/modules/**/provider.ts : Use provider containers for extending existing modules (payment, fulfillment) with dependencies declared in `medusa-config.ts`

Applied to files:

  • apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts
📚 Learning: 2026-05-11T23:01:30.923Z
Learnt from: CR
Repo: TechsioCZ/new-engine PR: 0
File: apps/medusa-be/CLAUDE.md:0-0
Timestamp: 2026-05-11T23:01:30.923Z
Learning: Applies to apps/medusa-be/**/*.{ts,tsx} : Annotate type as `unknown` when accessing dynamic object properties before applying type guards

Applied to files:

  • apps/medusa-be/src/scripts/herbatica-seed.ts
🔇 Additional comments (10)
apps/medusa-be/src/workflows/seed/steps/link-stock-location-fulfillment-provider.ts (1)

8-8: LGTM!

Also applies to: 14-24, 38-40

apps/medusa-be/src/workflows/seed/steps/ensure-price-preferences.ts (1)

83-97: LGTM!

apps/medusa-be/src/workflows/seed/helpers/build-inventory-items-input.ts (1)

1-35: LGTM!

apps/medusa-be/src/workflows/seed/steps/create-inventory-levels.ts (1)

1-196: LGTM!

apps/medusa-be/tests/unit/src/workflows/seed/build-inventory-items-input.unit.spec.ts (1)

1-89: LGTM!

apps/medusa-be/src/workflows/seed/steps/sync-price-lists.ts (1)

1-707: LGTM!

apps/medusa-be/src/scripts/herbatica-seed.ts (1)

1-3548: LGTM!

apps/medusa-be/src/workflows/seed/workflows/seed-database.ts (1)

1-344: LGTM!

apps/medusa-be/src/workflows/seed/workflows/seed-n1.ts (2)

225-238: LGTM!


267-271: LGTM!

Comment thread apps/medusa-be/src/scripts/herbatica-seed.ts Outdated
Comment thread apps/medusa-be/src/scripts/herbatica-seed.ts
Comment thread apps/medusa-be/src/workflows/seed/steps/create-tax-rates.ts
@redeyecz
redeyecz merged commit 7cfd9d4 into master Jun 4, 2026
7 checks passed
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 0.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@coderabbitai coderabbitai Bot mentioned this pull request Jun 10, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants