Commit Graph

307 Commits

Author SHA1 Message Date
Carlos R. L. Rodrigues
e413cfefc2 feat(utils): define file config (#13283)
** What
 - Allow auto-loaded Medusa files to export a config object.
 - Currently supports isDisabled to control loading.
 - new instance `FeatureFlag` exported by `@medusajs/framework/utils`
 - `feature-flags` is now a supported folder for medusa projects, modules, providers and plugins. They will be loaded and added to `FeatureFlag`

** Why
 - Enables conditional loading of routes, migrations, jobs, subscribers, workflows, and other files based on feature flags.

```ts
// /src/feature-flags

import { FlagSettings } from "@medusajs/framework/feature-flags"

const CustomFeatureFlag: FlagSettings = {
  key: "custom_feature",
  default_val: false,
  env_key: "FF_MY_CUSTOM_FEATURE",
  description: "Enable xyz",
}

export default CustomFeatureFlag
```

```ts
// /src/modules/my-custom-module/migration/Migration20250822135845.ts

import { FeatureFlag } from "@medusajs/framework/utils"

export class Migration20250822135845 extends Migration {
  override async up(){ }
  override async down(){ }
}

defineFileConfig({
  isDisabled: () => !FeatureFlag.isFeatureEnabled("custom_feature")
})
```
2025-08-26 12:22:30 +00:00
Adrien de Peretti
6264a6262b fix: Cart operation should calculate item prices accounting for quantity (#13251)
* fix(): Cart operation should calculate item prices accounting for quantity

* fix(): Cart operation should calculate item prices accounting for quantity

* fix(): Cart operation should calculate item prices accounting for quantity

* fix when call warning

* fix tests and remove unnecessary object copy

* Create warm-dancers-allow.md

* fix update line item in cart workflow

* fix changeset

* update order flows

* fix cart spec integration tests

* improve create order workflow

* fixes and tests adjustments/improvements

* configurable useQueryGraphStep return type

* revert nullable take

* cleanup useQueryGraphStep
2025-08-25 09:38:58 +02:00
Adrien de Peretti
06ef9197f8 chore(pricing): Fix excessive db queries during price sets update (#13258)
* chore(pricing): Fix excessive db queries during price sets update

* chore(pricing): Fix excessive db queries during price sets update

* finalize upsert with replace of the rules

* fix limit

* Create quiet-pumpkins-hang.md

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-08-22 10:51:50 +02:00
Frane Polić
492e018957 feat(dashboard, core-flows, js-sdk, types, medusa): listing order's shipping options (#13242)
* feat(dashboard, core-flows,js-sdk,types,medusa): listing order's shipping option

* fix: typo

* chore: migrate claim form

* fix: cleanup rule logic

* feat: add test case, rm params

* fix: expand location name
2025-08-21 13:01:27 +02:00
William Bouchard
6602e893b8 chore(medusa): fetch shipping related attributes (#13244)
* chore(medusa): fet shipping related attributes

* some tests

* changeset

* small refactor

* typing

* adapt attribute value

* test

* test again
2025-08-20 13:03:27 -04:00
Oli Juhl
b152210554 feat(core-flows): Refresh adjustments when editing orders (#13189)
* wip

* add tests

* add more tests

* fixes buy-get promotion

* Create empty-pillows-promise.md

* chore: use query graph

* Update packages/core/core-flows/src/order/workflows/order-edit/refresh-order-edit-adjustments.ts

Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>

---------

Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
2025-08-20 15:04:27 +02:00
Frane Polić
2f594291ad fix(core-flows, dashboard, types): improve allocation flows on Admin (#12572)
**What**
- handle single inventory items with `required_quantity > 1` correctly in the allocate UI flow
- display correct availability amount in the create fulullment form for inventory kit items
- fix check in the create fulfillment flow that would allow negative reservation because `required_quantity` wasn't included in the check
- show the most recent reservations first in the reservations table
- display an error in the allocation form if a reservation is not created for some inventory items 
- display inventory kit in the order summary if the product has multiple same inventory items

---

CLOSES SUP-1655
2025-08-19 18:48:24 +00:00
William Bouchard
67d3660abf feat(dashboard, core-flows): associate shipping option to type (#13226)
* feat(dashboard, core-flows): allow associating shipping option type to a shipping option

* edit as well

* fix translation schema

* fix some tests

* changeset

* add new test to update shipping option type

* add new test to create shipping option with shipping option type

* pr comments

* pr comments

* rename variable

* make zod great again
2025-08-19 11:02:36 -04:00
Riqwan Thamir
3cc512ef39 fix(utils): fix promotion case of each allocation not applying its total amount (#13199)
* fix(utils): fix promotion case of each allocation not applying its amount

* chore: fixed tests

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-08-17 19:11:16 +02:00
Sebastian Rindom
d2cb9523e0 feat: add column introspection api (#13183)
This is part of a set of stacked PRs to add support for view configurations, which will allow users to customize the columns shown in admin tables.

The functionality in this PR is behind the view_configuration feature flag.

**What**
- Adds an API to introspect the remote query schema and extract columns that users can add to their table views.

**Notes**
- This is a brute forced approach to get the functionality in place and I expect it to evolve to something more elegant over time. Some ideas for things we might want to consider:
  - Compute the entity columns during build time and store as static data the API can serve quickly.
  - Offer developers more control over how their data can be exposed in this API with additional decorators in the DML.
2025-08-15 15:35:01 +00:00
Sebastian Rindom
12a38bcd2b feat(api): add view configuration API routes (#13177)
* feat: add view_configurations feature flag

  - Add feature flag provider and hooks to admin dashboard
  - Add backend API endpoint for feature flags
  - Create view_configurations feature flag (disabled by default)
  - Update order list table to use legacy version when flag is disabled
  - Can be enabled with MEDUSA_FF_VIEW_CONFIGURATIONS=true env var

* fix: naming

* fix: feature flags unauthenticated

* fix: add test

* feat: add settings module

* fix: deps

* fix: cleanup

* fix: add more tetsts

* fix: rm changelog

* fix: deps

* fix: add settings module to default modules list

* feat(api): add view configuration API routes

- Add CRUD endpoints for view configurations
- Add active view configuration management endpoints
- Add feature flag middleware for view config routes
- Add comprehensive integration tests
- Add HTTP types for view configuration payloads and responses
- Support system defaults and user-specific configurations
- Enable setting views as active during create/update operations

* fix: test

* fix: test

* fix: test

* fix: change view configuration path

* fix: tests

* fix: remove manual settings module config from integration tests

* fix: container typing

* fix: workflows
2025-08-15 13:17:52 +02:00
Sebastian Rindom
ab795bb0a2 feat: view config feature flag (#13171)
* feat: add view_configurations feature flag

  - Add feature flag provider and hooks to admin dashboard
  - Add backend API endpoint for feature flags
  - Create view_configurations feature flag (disabled by default)
  - Update order list table to use legacy version when flag is disabled
  - Can be enabled with MEDUSA_FF_VIEW_CONFIGURATIONS=true env var

* fix: naming

* fix: feature flags unauthenticated

* fix: add test
2025-08-15 08:56:40 +02:00
William Bouchard
4b3c43fe92 feat(dashboard, js-sdk): shipping option type mngmt dashboard (#13208)
* chore(types, api): support shipping option type api endpoints

* core flows

* api

* typos

* compiler errors

* integration tests

* remove metadata

* changeset

* modify test

* upsert

* change remote query

* minor to patch

* description optional

* chore(dashboard, js-sdk): shipping option type management on admin dashboard

* description optional

* woops my bad

* my bad again

* create and edit

* prettier

* build code from label

* remove metadata route

* remove some translation text that is not used

* remove unsued files

* changeset

* adapt test

* fix test

* suggestion

---------

Co-authored-by: william bouchard <williambouchard@williams-MacBook-Pro.local>
2025-08-14 15:21:33 -04:00
William Bouchard
34c3c14e0a chore(types, api): support shipping option type api endpoints (#13191)
* chore(types, api): support shipping option type api endpoints

* core flows

* api

* typos

* compiler errors

* integration tests

* remove metadata

* changeset

* modify test

* upsert

* change remote query

* minor to patch

* description optional

* description optional

* woops my bad

* my bad again

---------

Co-authored-by: william bouchard <williambouchard@williams-MacBook-Pro.local>
2025-08-14 10:15:51 -04:00
Oli Juhl
f4ae615a3e fix(tax): Use correct rule reference for shipping (#13195)
* fix(tax): Use correct rule reference

* fix tests
2025-08-13 21:06:19 +02:00
Riqwan Thamir
224eaedf5c fix(dashboard,promotion): percentage promotions + set currency code on percentage promotions (#13161) 2025-08-07 13:07:41 +02:00
William Bouchard
acf6bbc2ec chore(core-flows): throw error on invalid promo code (#13140)
* chore(core-flows): throw error on invalid promo code

* add changelog

* better error handling in test

---------

Co-authored-by: william bouchard <williambouchard@williams-MacBook-Pro.local>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-08-05 09:01:41 -04:00
scherddel
51d4751d95 fix(utils): Fix on precision for high quantities for items when promotion is applied (#13131)
* Fix on precision for high quantities for items when promotion is applied

* Fix on precision for high quantities for items when promotion is applied
2025-08-03 19:16:16 +02:00
scherddel
9766570827 fix(types,utils,promotion): Move from total to original_total to resolve edge case for adjustments calculation (#13106)
* Move from total to original_total to resolve edge case in adjustment calculation

* Added changeset

* Added test case for correction

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-08-01 12:52:04 +02:00
tehaulp
881c8a4969 feat: added pacific franc currency (#13086) 2025-08-01 09:32:50 +02:00
scherddel
1bdf602f1c This fixes the discount_ calculation logic and promotion tax inclusiveness calculation (#12960)
* This fixes the discount_ calculation logic

* This fixes the adjustment to be handled as a subtotal value in every calculation and applies the tax inclusive logic on the promotion value itself

* Added some testcases and revoked some changes to improve testing output

* Fixed a test case based on feedback

* Corrected promotion/admin test cases

* Corrected cart/store test case

* Improved cart/store test cases for more robust promotion testing considering tax inclusion flags

* Remove unnessary changes as adjustments now automatically are subtotals and therefore the tax inclusive flag does not need to be applied again

* Remove adjustments->is_tax_inclusive usage everywhere

* Migration script to remove is_tax_inclusive in cart line item adjustment

* Forgot to adjust one more testcase

* Corrections based on fPolic feedback

* Refactored PR to consider feedback from oliver

* Added more testcases for promotion in cart

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-07-31 13:27:43 +02:00
Riqwan Thamir
75320e744f fix(promotion): check currency when computing actions for promotions (#13084)
* fix(promotion): check currency when computing actions for promotions

* chore: fix tests

* chore: fix more specs
2025-07-31 11:41:07 +02:00
Frane Polić
439c711845 fix(dashboard, product): product attributes update with a relation update (#13019)
* fix(dashboard, product): product attributes update with a relation update

* fix: rm log

* chore: refactor
2025-07-23 21:01:50 +02:00
Frane Polić
40625c82d6 fix(core-flows): properly delete variant inventory item (#12958)
* fix(core-flows): properly delete variant inventory item

* fix: rm unused code
2025-07-16 21:16:29 +02:00
Christopher Seven Phiri
1797f0298b feat: Added Malawi kwacha to currency list (#12440)
* Add Malawi kwacha currency

* fix failing currency tests

---------

Co-authored-by: Stevche Radevski <sradevski@live.com>
2025-07-16 10:26:28 +02:00
Frane Polić
a28226af80 fix(core-flows): updating tax lines when draft order shipping is removed (#12919)
**What**
- don't call `updateOrderTaxLinesWorkflow` when a shipping method is removed from a draft order (tax lines will be cascade deleted with the method)
2025-07-14 13:35:44 +00:00
Riqwan Thamir
8c4228fc42 fix(link-modules,core-flows): Carry over cart promotions to order promotions (#12920)
what:

- Carry over cart promotions to order promotions
2025-07-11 08:05:20 +00:00
Oli Juhl
42be9a88d6 fix(medusa, core-flows): Update TIP on promotions (#12885)
* fix: Update TIP on promotions

* Create warm-rings-look.md

* only show for fixed discounts

* fix: handle type change

---------

Co-authored-by: fPolic <mainacc.polic@gmail.com>
Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
2025-07-08 19:20:29 +02:00
Oli Juhl
a7700f116f fix(order, core-flows): Tax inclusive order line item adjustments (#12875)
* fix(order, core-flows): Tax inclusive order line item adjustments

* fix test
2025-07-06 22:32:17 +02:00
Oli Juhl
46bf7ae7ae fix(core-flows): Locations levels check in draft order and order edit flows (#12881)
* fix: Inventory check

* mend

* centralise fields

* Create few-owls-push.md
2025-07-03 17:31:04 +02:00
Adrien de Peretti
95d282e8ef fix: test utils events + workflow storage (#12834)
* feat(test-utils): Make event subscriber waiter robust and concurrent

* feat(test-utils): Make event subscriber waiter robust and concurrent

* fix workflows storage

* remove timeout

* Create gentle-teachers-doubt.md

* revert timestamp

* update changeset

* fix execution loop

* exit if no steps to await

* typo

* check next

* check next

* changeset

* skip when async steps

* wait workflow executions utils

* wait workflow executions utils

* wait workflow executions utils

* increase timeout

* break loop

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-06-30 13:34:08 +02:00
Adrien de Peretti
d517dbd66a feat(): Add support for jwt asymetric keys (#12813)
* feat(): Add support for jwt asymetric keys

* Create early-chefs-chew.md

* fix unit tests

* Add verify options support

* feedback

* fix unit tests
2025-06-25 10:29:32 +02:00
Adrien de Peretti
a833c3c98c fix(utils): build query withDeleted remove auto detection (#12788)
**What**
Currently, filtering data providing a `deleted_at` value will automatically apply the `withDeleted` flag which in turns remove the default constraint apply to all queries `deleted_at: null`. The problem is that it does not account for the value assign to `deleted_at` leading to inconsistent behaviour depending on the value. e.g filtering with `deleted_at: { $eq: null }` where the expectation is to only filter the non deleted record will end up returning deleted record as well by applying the `withDeleted` filters.

This pr revert this auto detection if favor of the user providing `withDeleted` explicitly, as it is already supported , plus the filters.

Further more, some integration tests demonstrate how to filter deleted records (e.g product) from the api. While the api did not properly support it, this pr adds support to pass with_deleted flags to the query and being handled accordingly to our api support. Validators have been updated and product list end point benefit from it. Also, the list config type was already accepting such value which I have translated to the remote query config.

Also, since the previous pr was adjusting the product types, I ve adjusted them to match the expectation
2025-06-25 07:51:37 +00:00
Ante Primorac
6ca755ede7 feat: Enable filtering admin products by variant EAN, UPC, and barcode (#12815)
* Add filters for variant ean, upc, and barcode in product queries and validators

* fix: Omit 'q' field from variants in product list and validation parameters

* Add tests for admin products filtering by variants ean, upc, and barcode

* Add changeset for filter admin products api by variant ean, upc, and barcode

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-06-25 09:17:01 +02:00
juanzgc
fbf33885f5 feat: Search by billing_address and shipping_address on Order model (#12814)
* feat: Search by billing_address and shipping_address on Order model

**What**
Added `.searchable()` method to the `shipping_address` and `billing_address` relationships in the `Order` model, enabling search functionality.

**Why**
Previously searching via `shipping_address` and `billing_address` was not supported, limiting the ability to find orders based on shipping or billing address information.

Resolves SUP-1838

* Update integration tests to include billing_address and non-existing addresses.
2025-06-25 09:16:40 +02:00
juanzgc
3826bde591 fix(medusa): Query Config update Order By filter (#12781)
**What**
Fixed a bug in the prepareListQuery function where nested field ordering was not properly building the expected nested object structure. The function was returning flat objects like { "employee.first_name": "ASC" } instead of the correct nested structure { "employee": { "first_name": "ASC" } }.

**Why**
The buildOrder function is designed to create nested objects from dot-notation field paths, which is essential for proper query building in the Medusa framework. When this functionality was broken, it prevented correct ordering of related fields and caused queries to fail or return unexpected results.

**How**
- Root cause: The `prepareListQuery` function was not properly utilizing the `buildOrder` utility function to transform dot-notation field paths into nested objects
- Before: order = "employee.first_name" → { "employee.first_name": "ASC" }
- After: order = "employee.first_name" → { "employee": { "first_name": "ASC" } }
- Added comprehensive tests: Created detailed unit tests for the prepareListQuery function focusing on buildOrder functionality, covering various scenarios including:
  - Simple ascending/descending order
  - Nested field ordering (e.g., product.title)
  - Deeply nested ordering (e.g., product.variants.prices.amount)
  - Multiple nesting levels (up to 5 levels deep)
- Added integration tests: Created integration tests in `product.spec.ts` to verify the full end-to-end functionality of nested ordering with variant titles

The fix ensures that the buildOrder function properly transforms dot-notation field paths into the expected nested object structure, enabling correct query building for related field ordering throughout the Medusa framework.

Resolves SUP-1868
2025-06-24 15:45:54 +00:00
Oli Juhl
b79215dd5c fix(utils): Typecasting non-text fields in FTS (#12729) 2025-06-13 13:18:50 +02:00
Frane Polić
2621f00bb0 feat(promotion, dashboard, core-flows, cart, types, utils, medusa): tax inclusive promotions (#12412)
* feat: tax inclusive promotions

* feat: add a totals test case

* feat: add integration test

* chore: changeset

* fix: typo

* chore: refactor

* fix: tests

* fix: rest of buyget action tests

* fix: cart spec

* chore: expand integration test with item level totals

* feat: add a few more test cases

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-06-12 15:07:11 +02:00
Frane Polić
bd6d9777c5 fix(promotion, types): non discountable items check (#12644)
* fix(promotions): check if item is discountable

* fix: return earl yonly if non discountable

* fix: update test

* chore: add integration test
2025-06-12 10:23:06 +02:00
Harminder Virk
f2cb528a56 feat: wire up direct uploads with local file provider (#12643) 2025-06-10 15:07:54 +05:30
Frane Polić
9866baa852 feat(core-flows,js-sdk,medusa,types): draft order delete (#12172) 2025-05-28 14:37:00 +02:00
Frane Polić
c4dd290461 fix(core-flows): reservation management on order edit and draft order confirm (#12546) 2025-05-28 09:52:01 +02:00
Frane Polić
c5a6573e26 fix(product, utils): handle metadata key deletion on product update (#12478) 2025-05-21 21:32:12 +02:00
Harminder Virk
fca5ad77b4 feat: process import from pre-processed chunks (#12527)
Fixes: FRMW-2968

In this PR we have done two major things.

- First, we remove storing CSV contents within the workflow storage and neither store the JSON payloads to be created/updated in workflows. Earlier, they all were workflow inputs, hence were stored in the workflow
- Introduce a naive concept of chunks and process chunks one by one. The next PR making chunking a bit more robust while using streams, adding ability to resume from the failed chunk and so on.

> [!IMPORTANT]  
> The new endpoint `/admin/product/imports` is not in use yet. But it will be after the next (final) PR.

## Old context in workflow storage

![CleanShot 2025-05-19 at 17 11 08@2x](https://github.com/user-attachments/assets/798bdcc9-a368-4c1f-afdd-2a77f5ce43e0)

## New context in workflow storage

![CleanShot 2025-05-19 at 17 15 08@2x](https://github.com/user-attachments/assets/0463d035-403f-4600-a9cd-5af24d5fee7c)
2025-05-20 12:33:18 +00:00
Harminder Virk
5cd4ff6fe7 test: remove snapshots usage (#12516)
* test: remove snapshots usage

* test: remove unneeded assertions

* Create plenty-poems-reply.md

* update tests

* update tests

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
2025-05-16 16:11:01 +02:00
Frane Polić
9f4d32b220 fix(core-flows): fulfilment cancelation with shared inventory kit item (#12503)
* fix(core-flows): fulfilment cancelation with shared inventory kit item

* fix: typos, check if iitem exists

* chore: typo
2025-05-16 10:50:10 +02:00
Harminder Virk
e149a99886 feat: define validators and use normalize-products step (#12473)
Fixes: FRMW-2965

In this PR we replace/remove the existing step to normalize a CSV file with the newly written CSV normalizer and also we validate the file contents further using a Zod schema.

I have duplicated the schema for now. But it is makes sense to re-use the schema for CSV validating and `/admin/products/batch`, then I can keep one source of truth under utils and re-export it. WDYT?

**Screenshots of some errors after validating the file strictly**

![CleanShot 2025-05-15 at 16 36 46@2x](https://github.com/user-attachments/assets/c7fa424f-b947-4898-9b94-47c48617c129)

![CleanShot 2025-05-15 at 16 36 34@2x](https://github.com/user-attachments/assets/0fefef79-148b-4eeb-8ef0-3077e8063ea8)
2025-05-16 08:37:25 +00:00
Pedro Guzman
2affc0d7d9 fix: fix weight/length/height/width types in updates (#12500) 2025-05-16 10:16:43 +02:00
Pedro Guzman
142a1f0a5b fix(product): returned updates order in upsertWithReplace (#12486)
* add failing test for upsertWithReplace order

* reproduce prices update shuffling issue

* fix: fix order of returned updates in updateMany

* fix: fix order of returned updates in ProductService

* fix: reset test count to 1

* Create tame-insects-marry.md

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-05-15 09:22:24 +02:00
Frane Polić
39e5eadefc fix(core-flows, dashboard): reservation recreation on fulfilment cancel + allocation button display (#12447)
**What**
- fix recreation of reservations on fulfilment cancel
- fix allocate items button display

---

CLOSES CMRC-1018
2025-05-12 17:09:23 +00:00