Commit Graph

364 Commits

Author SHA1 Message Date
Frane Polić
4757281677 feat(core-flows,product,types): scoped variant images (#13623)
* wip(product): variant images

* fix: return type

* wip: repo and list approach

* fix: redo repo method, make test pass

* fix: change getVariantImages impl

* feat: update test

* feat: API and core flows layer

* wip: integration spec

* fix: deterministic test

* chore: refactor and simplify, cleanup, remove repo method

* wip: batch add all images to all vairants

* fix: remove, expand testing

* refactor: pass variants instead of refetch

* chore: expand integration test

* feat: test multi assign route

* fix: remove `/admin/products/:id/variants/images` route

* feat: batch images to variant endpoint

* fix: length assertion

* feat: variant thumbnail

* fix: send variant thumbnail by default

* fix: product export test assertion

* fix: test

* feat: variant thumbnail on line item

* fix: add missing list and count method, update types

* feat: optimise variant images lookups

* feat: thumbnail management in core flows

* fix: typos, type, build

* feat: cascade delete to pivot table, rm unused unused fields

* feat(dashboard): variant images management UI (#13670)

* wip(dashboard): setup variant media form

* wip: cleanup table and images, wip check handler

* feat: proper sidebar functionallity

* fefat: add js-sdk and hooks

* feat: allow only one selection

* wip: lazy load variants in the table

* feat: new variants management for images on product details

* chore: refactor

* wip: variant details page work

* fix: cleanup media section, fix issues and types

* feat: correct scoped images, cleanup in edit modal

* feat: js sdk and hooks, filter out product images on variant details, labels, add API call and wrap UI

* chore: cleanup

* refacto: rename route

* feat: thumbnail functionallity

* fix: refresh checked after revalidation load

* fix: rm unused, refactor type

* Create thirty-clocks-refuse.md

* feat: new add remove variant media layout

* feat: new image add UX

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* fix: table name in migration

* chore: update changesets

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-10-26 15:15:40 +01:00
Adrien de Peretti
516f5a3896 fix: workflow async concurrency (#13769)
* executeAsync

* || 1

* wip

* stepId

* stepId

* wip

* wip

* continue versioning management changes

* fix and improve concurrency

* update in memory engine

* remove duplicated test

* fix script

* Create weak-drinks-confess.md

* fixes

* fix

* fix

* continuation

* centralize merge checkepoint

* centralize merge checkpoint

* fix locking

* rm only

* Continue improvements and fixes

* fixes

* fixes

* hasAwaiting will be recomputed

* fix orchestrator engine

* bump version on async parallel steps only

* mark as delivered fix

* changeset

* check partitions

* avoid saving when having parent step

* cart test

---------

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>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-10-20 15:29:19 +02:00
Adrien de Peretti
c54c5ed6de chore(): improve cart operations + Mikro orm 6.4.16 (#13712)
* chore(): Mikro orm 6.4.16

* Create small-ghosts-draw.md

* update config

* update config

* fix delete

* update config

* update workflows

* order improvements

* test pricing quuery

* test pricing quuery

* configurable connection options

* configurable connection options

* configurable connection options

* Update packages/modules/pricing/src/models/price.ts

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-10-10 08:58:19 +02:00
William Bouchard
924564bee5 fix(core-flows): customer id filter not working in getOrderDetails (#13695)
As discussed, fixed the get order detail and also changed the remotequery to graph a bunch of workflows
2025-10-09 12:13:12 +00:00
Adrien de Peretti
b43b285125 fix(): Workflow save to db + index integration instability (#13707)
**What**
- Fix index integration tests instability
- Fix workflow engine storage save to db
2025-10-08 08:45:15 +00:00
Leonardo Benini
9c957e1da0 chore(core-flows): only allow published products in addToCartWorkflow (#13182)
Closes #13163 

I have a few questions about expected behaviour, since this currently breaks some tests:

- Many tests use the productModule to create products, with default status == "draft", and use the addToCart workflow which now throws. Should I change all breaking tests to specify status == "published" whne creating the product? The alternative would be to check the status in the store API route before the workflow but 1. it would be an extra query and 2. the addToCart workflow is only used in the store currently, and even if it was to be used admin-side, it still doesn't make sense to add a draft product to cart

- After this PR an unpublished product would give the same error as a variant that doesn't exist. While imho this is correct, the thrown error (for both) is "Items  do not have a price" which doesn't make much sense(i believe the workflows goes through with an empty variants list and then errors at the price check point). Should I throw a different error when a variant doesn't exists/isn't published?


---

> [!NOTE]
> Enforces that only variants from published products can be added to carts, adds status fetching, refines errors, and updates tests to use ProductStatus.PUBLISHED.
> 
> - **Core Flows**:
>   - addToCart: Validate variants exist and belong to `product.status = PUBLISHED`; throw clear `INVALID_DATA` when not found/unpublished.
>   - Data fetching: Include `product.status` in `cart` and `order` variant field selections.
> - **Tests/Fixtures**:
>   - Update integration tests to set `status: ProductStatus.PUBLISHED` when creating products and import `ProductStatus` where needed.
>   - Add cases for unpublished products and non-existent variants producing the new error message.
> 
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ca72532e957964d2d8e6bcecbb0905054c677ded. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
2025-10-02 12:31:53 +00:00
Adrien de Peretti
5ea32aaa44 fix(): Cart workflow price calculation for different items but same variant (#13511)
RESOLVES CORE-1204

**What**
- Fix wrong price tier when multiple items are targetting the same variant
- fix type import from the wrong package

**Notes**
If you are struggling navigating the changes, you can focus on the following files:
```
integration-tests/http/__tests__/cart/store/cart.spec.ts
integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts
packages/core/core-flows/src/cart/steps/get-promotion-codes-to-apply.ts
packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts
packages/core/core-flows/src/cart/workflows/add-to-cart.ts
packages/core/core-flows/src/cart/workflows/create-carts.ts
packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts
packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts
packages/core/core-flows/src/order/workflows/add-line-items.ts
packages/core/core-flows/src/order/workflows/create-order.ts
```
2025-09-26 07:19:46 +00:00
Adrien de Peretti
12a96a7c70 chore(): Move peer deps into a single package and re export from framework (#13439)
* chore(): Move peer deps into a single package and re export from framework

* WIP

* update core packages

* update cli and deps

* update medusa

* update exports path

* remove analyze

* update modules deps

* finalise changes

* fix yarn

* fix import

* Refactor peer dependencies into a single package

Consolidate peer dependencies into one package and re-export from the framework.

* update changeset

* Update .changeset/brown-cows-sleep.md

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* rm deps

* fix deps

* increase timeout

* upgrade version

* update versions

* update versions

* fixes

* update lock

* fix missing import

* fix missing import

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-09-22 18:36:22 +02:00
Adrien de Peretti
4c1c1dd4c0 chore(): Further improve promotions computation (#13556)
* chore(): Further improve promotions

* chore(): Further improve promotions

* chore(): Further improve promotions

* chore(): Further improve promotions

* chore(): Further improve promotions

* Create lazy-lemons-occur.md

* chore(): Further improve promotions

* WIP

* fix

* improve:

* fix attribute tests

* fix tests

* union
2025-09-19 21:34:35 +02:00
Carlos R. L. Rodrigues
9563ee446f fix(utils,core-flows): subtotal calculation and returns location (#13497)
* fix(utils,core-flows): subtotal calculation and returns location

* changeset

* fix test

* var

* rm extra field from test

* fix original total

* fix partial refunds and pending difference

* fix test

* fix test

* test

* extract to util

* original total and update payment when receive return

* original_subtotal

* default fields

* test

* calculate pending difference

* revert claims test

* pending difference

* creadit line fix

* if
2025-09-18 17:50:40 +02:00
William Bouchard
1071296236 feat(core-flows): hook to set shipping opt context when listing (#13468)
* feat(core-flows): add hook to set shipping option context when listing them

* changeset

* add integration test

* add it to other workflow

* missing hook in workflow response

* rework workflow

* rework workflow

* typing issue

* comment from oli

* cursor the goat

* tests

* save lines

* move code around

* missing additional params in many places

* smal fix

* smal fix
2025-09-17 19:20:02 +02:00
Frane Polić
8565dcfc46 fix(core-flows, medusa): don't allow negative line item quantity (#13508)
* fix(core-flows,medusa): don't allow negative line item quantity

* fix: greater than 0

* feat: add test

* wip: update update item flow to remove item when qty is 0

* fix: paralelize

* fix: when argument

* fix: emit event
2025-09-16 11:54:20 +02:00
Adrien de Peretti
25634b0382 test(): test dynamic max workers and improve CI (#13516)
* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* test(): test dynamic max workers

* Clarify test description and improve CI
2025-09-16 11:11:03 +02:00
Adrien de Peretti
ebf33bea43 fix(): pipeline missing suites (#13457)
* fix(): pipeline missing suites

* fix tax integration tests

* fix tax integration tests

* fix pipeline

* fix link integration tests

* remove old tests and move current one

* fix workflow execution integration tests

* fix tests and orchestrator

* Fix missing suites in pipeline

Remove integration-tests-modules from patch list.
2025-09-15 12:54:57 +02:00
William Bouchard
4fded2602b fix(medusa,product): fix ordering product categories (#13487)
CLOSES CORE-1191

cc @SteelRazor47
2025-09-11 21:18:40 +00:00
Adrien de Peretti
de9a21a9da chore(): Improve link indexes (#13459)
RESOLVE CORE-1183

**What**
Update link indexes to include deleted_at index constraint
2025-09-11 07:44:13 +00:00
William Bouchard
e0943f3c90 fix(medusa): stop loading entry points in exec command (#13438) 2025-09-09 18:10:56 +00:00
Carlos R. L. Rodrigues
71d8a0031f fix(index): index enum fields (#13428)
https://github.com/medusajs/medusa/issues/13372

What:
 - It handles enum fields corretly when added to filterable fields
2025-09-07 13:39:58 +00:00
Carlos R. L. Rodrigues
bd571aca82 chore(orchestration): remote joiner query planner (#13364)
What:
 - Added query planning to the Remote Joiner, enabling phased and parallel execution of data aggregation.
- Replaced object deletes with non-enumerable property hiding to improve performance.
2025-09-04 14:18:02 +00:00
William Bouchard
faae150a58 fix(utils): big bumber should give numeric value of 0 for small numbers (#13394)
* fix(utils): big bumber should give numeric value of 0 for small numbers

* circular dep

* fix imports

* fix infinite loop

* fix test

* changeset
2025-09-03 13:45:41 -04:00
Carlos R. L. Rodrigues
9412669e65 chore: idempotent cart operations (#13236)
* chore(core-flows): idempotent cart operations

* changeset

* add tests

* revert

* revert route

* promo test

* skip bugs

* fix test

* tests

* avoid workflow name conflict

* prevent nested workflow from being deleted until the top level parent finishes

* remove unused setTimeout

* update changeset

* rm comments

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
2025-08-28 15:04:00 +02:00
Carlos R. L. Rodrigues
f764b3a364 feat(index): $nin and $not operators (#13289)
* feat(index): add $not and $nin operators

* logical operator

* test

* test

* types

* logical

* schema ID

* types and $ilike fix

* index type
2025-08-28 11:56:17 +02:00
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
fc49253273 feat(core, event-bus): Compensate emit event step utility (#13281)
* feat(core, event-bus): Compensate emit event step utility

* tests

* Update changeset to remove integration-tests-modules

Removed integration-tests-modules from changeset.

* revert test script
2025-08-25 15:08:09 +02: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
Carlos R. L. Rodrigues
fd4e791428 fix(utils): auto generated update method return (#13225)
* fix(utils): auto generated update method return

* tests

* cleanup

* rm unused function

* Update .changeset/young-mangos-suffer.md

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-08-18 13:26:36 +02:00
Jan Biardzki
257e71f988 fix(core-flows): fix update tax lines to apply tax rule by product type (#13202)
* test(draft-order): add draft order creation test with tax application by product type

* fix: add `product_type.id` and `items.product_type_id` fields to order utilities

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-08-14 20:07:43 +02:00
Carlos R. L. Rodrigues
9725bff25d fix(index): logical operators (#13137) 2025-08-07 07:34:50 -03: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ć
9fb5baa912 fix(core-flows): guest customer updates email to another guest account (#13037)
* fix(core-flows); guest customer updates email to another guest account

* wip: refactor test

* fix: refactor step, add testing

* fix: update test

* fix: string assertion in a test
2025-07-25 12:49:06 +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
Carlos R. L. Rodrigues
fa76f85bba fix(index): merge filterable fields schema (#12888) 2025-07-04 09:41:40 -03:00
Riqwan Thamir
9a62f359f1 fix(core-flows,workflows-sdk): compensate account holders only when its created (#12825)
* fix(core-flows,workflows-sdk): compensate account holders only when its created

* chore: remove only
2025-06-26 12:30:08 +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
Carlos R. L. Rodrigues
490bd7647f fix(core-flows): complete cart improvements (#12646)
* fix(core-flows): use cartId as transactionId and acquire lock to complete cart

* fix cart update compensation
2025-05-30 14:15:08 +01:00
Frane Polić
9866baa852 feat(core-flows,js-sdk,medusa,types): draft order delete (#12172) 2025-05-28 14:37:00 +02:00
Carlos R. L. Rodrigues
ebe5cc7acd chore(index): return ids only (#12543) 2025-05-20 11:16:02 -03:00
Carlos R. L. Rodrigues
c661e06488 fix(index): query builder handle json array (#12480)
* fix(index): query builder handle json array

* fix sales channel event names
2025-05-14 18:43:01 +02:00
Oli Juhl
92af52d133 fix(tax): Make system provider registration backward compatible (#12441)
* fix(tax): Make provider registration backward compatible

* add tests
2025-05-12 17:06:43 +02:00
Frane Polić
5fe0e8250d fix(core-flows): Refund and recreate payment session on cart complete failure (#12263) 2025-05-11 19:53:49 +02:00
Frane Polić
47700899ed fix(core-flows): use product title for line item title (#12397)
* fix(core-flows): use prduct title for line item title

* fix: module tests

* fix: http tests

* fix: display item subtitle instead of prod title as secondary text in line item

* fix: claim/exchange items
2025-05-11 17:05:46 +02:00
Adrien de Peretti
091041f2da test(core-flows): Ensure productVariantUpdated failure compensate the workflow (#12381) 2025-05-09 13:03:22 +02:00
Adrien de Peretti
221c73f4a8 test(workflow-engine): Ensure failed subscriber does not compensate workflows (#12427)
* test(workflow-engine): Ensure failed subscriber does not compensate workflows

* test(workflow-engine): Ensure failed subscriber does not compensate workflows
2025-05-09 13:02:35 +02:00
Frane Polić
9cedeb182d feat(dashboard, js-sdk, medusa, tax, types): custom tax providers (#12297)
* wip: setup loaders, add endpoints, module work, types, js sdk

* fix: tax module provider loader

* feat: select provider on region create, fix enpoint middleware registration

* feat: edit form

* fix: rename param

* chore: changeset

* fix: don't default to system provider

* fix: admin fixes, dispalt tax provider

* fix: some tests and types

* fix: remove provider from province regions in test

* fix: more tests, optional provider for sublevel regions, fix few types

* fix: OE test

* feat: edit tax region admin, update tax region core flow changes

* feat: migrate script

* fix: refactor

* chore: use query graph

* feat: provider section
2025-05-06 19:26:33 +02:00
Carlos R. L. Rodrigues
b868a4ef4d feat(index): add filterable fields to link definition (#11898)
* feat(index): add filterable fields to link definition

* rm comment

* break recursion

* validate read only links

* validate filterable

* gql schema array

* link parents

* isInverse

* push id when not present

* Fix ciruclar relationships and add tests to ensure proper behaviour (part 1)

* log and fallback to entity.alias

* cleanup and fixes

* cleanup and fixes

* cleanup and fixes

* fix get attributes

* gql type

* unit test

* array inference

* rm only

* package.json

* pacvkage.json

* fix link retrieval on duplicated entity type and aliases + tests

* link parents as array

* Match only parent entity

* rm comment

* remove hard coded schema

* extend types

* unit test

* test

* types

* pagination type

* type

* fix integration tests

* Improve performance of in selection

* use @@ to filter property

* escape jsonPath

* add Event Bus by default

* changeset

* rm postgres analyze

* estimate count

* new query

* parent aliases

* inner query w/ filter and sort relations

* address comments

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-04-29 12:10:31 +02:00
Adrien de Peretti
2f6963a5fb fix(): Event group id propagation and event managements (#12157) 2025-04-14 15:57:52 -03:00
Carlos R. L. Rodrigues
31abba8cde fix(orchestrator): save checkpoint before async step (#12138) 2025-04-10 15:36:36 +00:00
Pedro Guzman
8804ca2f9c fix: allow backorder variants to be added to cart even if no locations (#12083)
* fix: allow backorder variants to be added to cart even if no locations

* document and unit test prepareConfirmInventoryInput
2025-04-09 19:15:42 +02:00
Carlos R. L. Rodrigues
f615ebb7e8 chore: retry util on tests (#12126) 2025-04-09 16:07:05 +00:00
Adrien de Peretti
13e159d8ad fix(workflow-engine-*): Prevent passing shared context reference (#11873)
* fix(workflow-engine-*): Prevent passing shared context reference

* fix(workflow-engine-*): Prevent passing shared context reference

* prevent tests from hanging

* fix event handling

* add integration tests

* use interval for scheduled in tests

* skip tests for now

* Create silent-glasses-enjoy.md

* fix cancel

* changeset

* push multiple aliases

* test multiple field alias

* increase wait time to index on test

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
2025-04-09 10:39:29 +02:00