Commit Graph

1437 Commits

Author SHA1 Message Date
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
Frane Polić
a8513019db fix(core-flows,dashboard): handling authorized payment collection on OE (#11958)
* wip: handling authorized payment collection on OE

* fix: update condition

* fix: condition for creation

* chore: remove commented code

* chore: changeset, refactor

* chore: typo, comments

* fix: add a test case

* fix: reorg workflows, partially captured

* fix: status enum type
2025-04-02 13:57:44 +02:00
Harminder Virk
d3e725a907 feat: add hasMany flag to enforce in app link uniqueness (#12039)
* feat: add createMultiple flag to enforce inApp link uniqueness

* changes

* mocks

* default

* many to many

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
2025-04-02 10:46:51 +02:00
Kasper Fabricius Kristensen
f441362f4a feat(medusa,core-flows,types,js-sdk): Draft Order workflows and API endpoints (#11805) 2025-04-02 10:23:33 +02:00
Harminder Virk
b1b3b48474 feat: Set pricing context hook (#11891) 2025-03-28 15:17:52 +05:30
Riqwan Thamir
1f8fab3636 feat(core-flows,types,order,cart): assign tax lines only to regular products (#11994)
what:

- assign tax lines only to regular products
2025-03-26 22:26:34 +00:00
Frane Polić
de8c034d1b feat(core-flows, types): calculated shipping in RMA flows (#11533)
* wip: calculated SO pricing in RMA flows

* fix: types

* chore: small refactor

* feat: caluclated shipping in return flow

* fix: module integrations

* fix: array containing

* feat: refresh shipping on update item quantity

* rm: log

* rm: log2

* feat: update interface, remove flag

* fix: revert change on OE for now

* fix: import

* feat: refactor flwos, cleanup cacluation cotext data model, wip exchanges

* feat: refreshing inbound/outbound shipping on items change

* feat: refresh exchange shipping on return item add, test

* feat: refresh shipping on exchange/return item remove

* fix: check optional

* feat: test recalculation on quantity update

* feat: calculated shipping on claims

* fix: comment

* wip: address comments

* fix: more remote query, fix build

* refactor: claim refresh workflow

* fix: remove throw option

* fix: deconstruct param

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-03-24 07:07:47 +01:00
Frane Polić
8385a5e34d feat(core-flows): revisit fulfillment flow reservations and support inventory kit (#11790)
* feat: fulfillment flow with reservations and inventory kit

* fix: account for custom line items

* chore: cleanup, changeset

* fix: revert action check

* fix: deduplicate, test item qunatities, compute line item quantity from fulfillment items

* fix:

* fix: improve types

* fix: optimize fetched fileds in cancel fulfillment workflow

* fix: add a test case

* chore: update type
2025-03-19 13:15:24 +01:00
Riqwan Thamir
9dd62d93bd feat(core-flows,types,utils): make payment optional when cart balance is 0 (#11872)
what:

- make payment optional when cart balance is 0
2025-03-17 19:03:22 +00:00
Riqwan Thamir
cb6249320e fix(types,order,medusa): Create credit lines + hooks (#11569)
what:

- api/workflows to create credit lines
- hooks to enable extending credit lines
2025-03-17 15:20:59 +00:00
Harminder Virk
cae47d9e49 feat: add check for uniqueness when creating links with isList=false (#11767) 2025-03-17 13:23:18 +05:30
Adrien de Peretti
72d2cf9207 fix(workflow-engines): race condition when retry interval is used (#11771) 2025-03-12 09:53:34 -03:00
Frane Polić
70eaaa9196 fix(core-flows): fulfillment reservation check (#11735) 2025-03-09 13:47:10 +01:00
Riqwan Thamir
f00bb8efcf fix(core-flows): conditionally create, update or delete products when input is present (#11758)
what:

- runs create / update /delete workflows for bulk workflow conditionally

FIXES https://github.com/medusajs/medusa/issues/11749
depends on https://github.com/medusajs/medusa/pull/11756
2025-03-06 13:41:20 +00:00
olivermrbl
5d74ac3cc3 chore: Version packages 2025-03-04 14:11:37 +01:00
Riqwan Thamir
51b0af193c fix(types,medusa): calculate taxes for original price (#11692) 2025-03-03 14:20:48 +01:00
Riqwan Thamir
38beeb157e fix(core-flows): support 0 as a valid unit price for custom line items (#11631) 2025-02-26 19:32:35 +01:00
Oli Juhl
54a6ef91ac chore: Move token from params to headers (#11281)
* chore: Move token from params to body

* chore: Add type

* wip

* chore: clean up

* clean ip
2025-02-26 17:41:16 +01:00
Carlos R. L. Rodrigues
fa1793e8e9 chore(core-utils): avoid overfetching to refresh cart (#11602)
What:
 * Not all Cart operations need a full refresh updating items. This PR introduces a flag to force the refresh for special ocasions, like updating the Cart's region, or transfering the Cart to another customer. For all other flows it will update only promotions, taxes and payment collection if needed.
2025-02-26 10:00:04 +00:00
Adrien de Peretti
eeebb35758 chore(product): revamp upsertWithReplace and Remove its usage from product creation (#11585)
**What**
- Move create product to use native create by structuring the data appropriately, it means no more `upsertWithReplace` being very poorly performant and got 20x better performances on staging
- Improvements in `upsertWithReplace` to still get performance boost for places that still relies on it. Mostly bulking the operations when possible

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-02-26 09:53:13 +00:00
Carlos R. L. Rodrigues
03731c7660 chore(core-flows): reserve inventory from available location (#11538) 2025-02-26 06:10:41 -03:00
Riqwan Thamir
fb2e86484a feat(core-flows,types,cart): add credit lines to cart (#11419)
* feat(core-flows,types,cart): add credit lines to cart

* chore: fix specs

* chore: credit lines hook

* chore: update types

* chore: added credit line totals

* chore: add totals fields to query config

* chore: add complete cart hook

* chore: add credit lines creation to order

* chore: pr ready for review

* chore: fix tests

* Apply suggestions from code review

* chore: fix types

* chore: adjust summary calculations with new totals
2025-02-24 14:34:36 +01:00
Kasper Fabricius Kristensen
efd66c0d59 fix(core-flows): Allow adding shipping methods through order edits (#11504)
* fix(core-flows): Allow adding shipping methods through order edits

* fix(core-flows): Allow adding shipping methods through order edits

* update test description

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-02-23 16:06:54 +01:00
Carlos R. L. Rodrigues
0c957350a6 fix(order): calculate taxes on order edit flows (#11518)
* fix(order): calcualte taxes on order edit flows

* merge summary

* tests

* fix pending difference

* comments

* claim test

* revert method
2025-02-21 15:27:40 +01:00
Adrien de Peretti
065df75e7d fix(): handle empty q filters - allow to query deleted records from graph API - staled_at fixes (#11544)
* fix(): Allow to query deleted records from graph API

* fix(): Allow to query deleted records from graph API

* handle empty q value

* update staled at sync

* rename integration tests file

* Create strong-houses-marry.md

* try to fix flacky tests

* fix pricing context

* update changeset

* update changeset

* fix import

* skip test for now

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-02-21 13:24:12 +01:00
Kasper Fabricius Kristensen
3b4997840e fix(medusa,js-sdk,types): Add basic draft order operations to js-sdk (#11514)
**What**
- Exposes `sdk.admin.draftOrder.create/update/retrieve/list` functions from the js-sdk
- Implements the necessary types in the types package.
- Adds missing endpoints to admin API.
2025-02-20 16:05:21 +00:00
Frane Polić
0c530e90c5 feat(core-flows, types): add has missing inventory flag when listing shipping options (#11493)
**What**
- add `insufficient_inventory` flag when listing shipping options for a cart
- add `enabled_in_store` flag when creating/editing pickup options
2025-02-19 08:08:25 +00:00
Adrien de Peretti
448dbcb596 feat(medusa): Rollout index engine behind feature flag (#11431)
**What**
- Add index engine feature flag
- apply it to the `store/products` end point as well as `admin/products`
- Query builder various fixes
- search capabilities on full data of every entities. The `q` search will be applied to all involved joined table for selection/where clauses

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-02-18 13:49:57 +00:00
Frane Polić
ee848bf0f4 feat(core-flows, dashboard, medusa, types): optional shipping profile (#11434)
* feat: create product flow changes

* feat: allow unsetting SP on product update

* feat: update prepare line item helper

* test: add testcase

* wip: fix tests

* fix: update module tests

* fix: cart module test
2025-02-17 19:08:59 +01:00
Adrien de Peretti
63f0774569 feat(): Backport metadata management (#11469)
FIXES FRMW-2915

**What**
Backport metadata management. all the metadata get preserved unless a specific empty string is provided for the key which in turn would remove that key from the metadata
2025-02-17 09:14:53 +00:00
Kasper Fabricius Kristensen
825b8ad260 fix(medusa): Allow filtering by handle and title as arrays (#11472)
**What**
- Allows filtering products in the Store API with an array value for both `handle` and `title`.

RESOLVES SUP-893
2025-02-14 14:10:32 +00:00
Frane Polić
bbef0da5dd fix(core-flows, types): reservation of shared inventory item (#11403)
**What**
- if a cart contains variants that share inventory items, reservation of the item would fail also causing complete cart to fail
- include `completed_at` when compensating cart update
- account for multiple reservations of the same item when creating the locking key

---

CLOSES SUP-587
2025-02-13 08:03:53 +00:00
Carlos R. L. Rodrigues
22276648ad feat: query.index (#11348)
What:
 - `query.index` helper. It queries the index module, and aggregate the rest of requested fields/relations if needed like `query.graph`.
 
Not covered in this PR:
 - Hydrate only sub entities returned by the query. Example: 1 out of 5 variants have returned, it should only hydrate the data of the single entity, currently it will merge all the variants of the product.
 - Generate types of indexed data
 
 example:
 ```ts
 const query = container.resolve(ContainerRegistrationKeys.QUERY)
        
 await query.index({
  entity: "product",
  fields: [
    "id",
    "description",
    "status",
    "variants.sku",
    "variants.barcode",
    "variants.material",
    "variants.options.value",
    "variants.prices.amount",
    "variants.prices.currency_code",
    "variants.inventory_items.inventory.sku",
    "variants.inventory_items.inventory.description",
  ],
  filters: {
    "variants.sku": { $like: "%-1" },
    "variants.prices.amount": { $gt: 30 },
  },
  pagination: {
    order: {
      "variants.prices.amount": "DESC",
    },
  },
})
```
This query return all products where at least one variant has the title ending in `-1` and at least one price bigger than `30`.
 
The Index Module only hold the data used to paginate and filter, and the returned object is:
```json
{
  "id": "prod_01JKEAM2GJZ14K64R0DHK0JE72",
  "title": null,
  "variants": [
    {
      "id": "variant_01JKEAM2HC89GWS95F6GF9C6YA",
      "sku": "extra-variant-1",
      "prices": [
        {
          "id": "price_01JKEAM2JADEWWX72F8QDP6QXT",
          "amount": 80,
          "currency_code": "USD"
        }
      ]
    }
  ]
}
```

All the rest of the fields will be hydrated from their respective modules, and the final result will be:

```json
{
  "id": "prod_01JKEAY2RJTF8TW9A23KTGY1GD",
  "description": "extra description",
  "status": "draft",
  "variants": [
    {
      "sku": "extra-variant-1",
      "barcode": null,
      "material": null,
      "id": "variant_01JKEAY2S945CRZ6X4QZJ7GVBJ",
      "options": [
        {
          "value": "Red"
        }
      ],
      "prices": [
        {
          "amount": 20,
          "currency_code": "CAD",
          "id": "price_01JKEAY2T2EEYSWZHPGG11B7W7"
        },
        {
          "amount": 80,
          "currency_code": "USD",
          "id": "price_01JKEAY2T2NJK2E5468RK84CAR"
        }
      ],
      "inventory_items": [
        {
          "variant_id": "variant_01JKEAY2S945CRZ6X4QZJ7GVBJ",
          "inventory_item_id": "iitem_01JKEAY2SNY2AWEHPZN0DDXVW6",
          "inventory": {
            "sku": "extra-variant-1",
            "description": "extra variant 1",
            "id": "iitem_01JKEAY2SNY2AWEHPZN0DDXVW6"
          }
        }
      ]
    }
  ]
}
```

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2025-02-12 12:55:09 +00:00
Carlos R. L. Rodrigues
d6c03ee542 fix(utils): custom linkable keys (#11400)
**What**
Fix linkable generation when there is no dml models and models are provided as virtual to the joiner config and therefore the linkable are inferred
2025-02-11 16:59:21 +00:00
olivermrbl
682dcf6507 chore: Version packages 2025-02-11 12:00:43 +01:00
Frane Polić
17e9673769 fix(core-flows): variants update unsets prices (#11349)
* fix: update variant flow for prices

* fix: import add test

* fix: test name
2025-02-10 09:13:47 +01:00
Stevche Radevski
702d338284 fix: Minor fixes and cleanup to the payments setup (#11356)
This PR adds a couple new statuses to the payment collection and payment webhook results. The payment collection will now be marked as "completed" once the captured amount is the full amount of the payment collection.

There are several things left to improve the payment setup, so non-happy-path cases are handled correctly.
1. Currently the payment session and payment models serve a very similar purpose. Part of the information is found on one, and the other part on the other model, without any clear reason for doing so. We can simplify the payment module and the data models simply by merging the two.
2. We need to handle failures more gracefully, such as setting the payment session status to failed when such a webhook comes in.
3. We should convert the payment collection status and the different amounts to calculated fields from the payment session, captures, and refunds, as they can easily be a source of inconsistencies.
2025-02-09 15:42:02 +00:00
Frane Polić
34e7fdafd2 fix(test): update flaky fulfillment test (#11312)
* fix: fulfillment test

* fix: missing option ids
2025-02-06 17:57:07 +01:00
Adrien de Peretti
a33aebd895 feat(index): full sync operations (#11178)
Closes: FRMW-2892, FRMW-2893

**What**
Wired up the building block that we merged previously in order to manage data synchronization. The flow is as follow
- On application start
  - Build schema object representation from configuration
  - Check configuration changes
    - if new entities configured
      - Data synchronizer initialize orchestrator and start sync
        - for each entity
          - acquire lock
          - mark existing data as staled
          - sync all data by batch
          - marked them not staled anymore
          - acknowledge each processed batch and renew lock
          - update metadata with last synced cursor for entity X
          - release lock
      - remove all remaining staled data
    - if any entities removed from last configuration
      - remove the index data and relations

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-02-05 16:49:18 +00:00
Frane Polić
742babfe3f fix(core-flows): shipping profile update (#11322)
**What**
- prevent unsetting shipping profile on product update
2025-02-05 14:37:43 +00:00
Frane Polić
462c3e8057 feat(core-flows): cart complete shipping validate (#10984)
**What**
- validate that there is a shipping method if any of the line items have requires_shipping=true
- validate that products shipping profile is supported by a shipping method on the cart
- update tests

---

CLOSES CMRC-683
2025-02-04 10:10:08 +00:00
Carlos R. L. Rodrigues
e98d3c615e chore(orchestration): validate PK when throwIfKeyNotFound (#11190)
CLOSES: FRMW-2895
2025-01-29 19:17:36 +00:00
Frane Polić
864d772e34 feat(core-flows, dashboard, link-modules,medusa, types, utils): fulfillment shipping changes (#10902)
**What**
- product <> shipping profile link
- create and update product workflows/endpoints accepts shipping profile
- pass shipping option id when creating fulfillment to allow overriding customer selected SO
- validate shipping profile delete
- dashboard
  - set shipping profile on product create
  - manage shipping profile for a product
  - **update the create fulfillment form**
- other
  - fix create product form infinite rerenders
 
---

CLOSES CMRC-831 CMRC-834 CMRC-836 CMRC-837 CMRC-838 CMRC-857 TRI-761
2025-01-27 12:00:20 +00:00
Frane Polić
d4cbc6218c feat(medusa,product,types): product type & tag store missing endpoints (#11057)
* wip: tag endpoints

* feat: types, product types

* feat: tests

* fix: update product type schema
2025-01-26 14:16:49 +01:00
Riqwan Thamir
8119d9964b fix(promotion): eval conditions for rules are made accurate (#10915)
what:

- fixes eval conditions for promotion rules

RESOLVES CMRC-851
2025-01-21 21:26:20 +00:00
Carlos R. L. Rodrigues
cc73802ab3 chore(order): dml (#10292)
* ../../core/types/src/dml/index.ts

* ../../core/types/src/dml/index.ts

* fix: relationships mapping

* handle nullable foreign keys types

* handle nullable foreign keys types

* handle nullable foreign keys types

* continue to update product category repository

* fix all product category repositories issues

* fix product category service types

* fix product module service types

* fix product module service types

* fix repository template type

* refactor: use a singleton DMLToMikroORM factory instance

Since the MikroORM MetadataStorage is global, we will also have to turn DML
to MikroORM entities conversion use a global bucket as well

* refactor: update product module to use DML in tests

* wip: tests

* WIP product linkable fixes

* continue type fixing and start test fixing

* test: fix more tests

* fix repository

* fix pivot table computaion + fix mikro orm repository

* fix many to many management and configuration

* fix many to many management and configuration

* fix many to many management and configuration

* update product tag relation configuration

* Introduce experimental dml hooks to fix some issues with categories

* more fixes

* fix product tests

* add missing id prefixes

* fix product category handle management

* test: fix more failing tests

* test: make it all green

* test: fix breaking tests

* fix: build issues

* fix: build issues

* fix: more breaking tests

* refactor: fix issues after merge

* refactor: fix issues after merge

* refactor: surpress types error

* test: fix DML failing tests

* improve many to many inference + tests

* Wip fix columns from product entity

* remove product model before create hook and manage handle validation and transformation at the service level

* test: fix breaking unit tests

* fix: product module service to not update handle on product update

* fix define link and joiner config

* test: fix joiner config test

* test: fix joiner config test

* fix joiner config primary keys

* Fix joiner config builder

* Fix joiner config builder

* test: remove only modifier from test

* refactor: remove hooks usage from product collection

* refactor: remove hooks usage from product-option

* refactor: remove hooks usage for computing category handle

* refactor: remove hooks usage from productCategory model

* refactor: remove hooks from DML

* refactor: remove cruft

* order dml

* cleanup

* re add foerign key indexes

* wip

* chore: remove unused types

* wip

* changes

* rm raw

* autoincrement

* wip

* rel

* refactor: cleanup

* migration and models configuration adjustments

* cleanup

* number searchable

* fix random ordering

* fix

* test: fix product-category tests

* test: update breaking DML tests

* test: array assertion to not care about ordering

* fix: temporarily apply id ordering for products

* types

* wip

* WIP type improvements

* update order models

* partially fix types temporarely

* rel

* fix: recursive type issue

* improve type inference breaks

* improve type inference breaks

* update models

* rm nullable

* default value

* repository

* update default value handling

* fix unit tests

* WIP

* toMikroORM

* fix relations

* cascades

* fix

* experimental dml hooks

* rm migration

* serial

* nullable autoincrement

* fix model

* model changes

* fix one to one DML

* order test

* fix addresses

* fix unit tests

* Re align dml entity name inference

* update model table name config

* update model table name config

* revert

* update return relation

* WIP

* hasOne

* models

* fix

* model

* initial commit

* cart service

* order module

* utils unit test

* index engine

* changeset

* merge

* fix hasOne with fk

* update

* free text filter per entity

* tests

* prod category

* property string many to many

* fix big number

* link modules migration set names

* merge

* shipping option rules

* serializer

* unit test

* fix test mikro orm init

* fix test mikro orm init

* Maintain merge object properties

* fix test mikro orm init

* prevent unit test from connecting to db

* wip

* fix test

* fix test

* link test

* schema

* models

* auto increment

* hook

* model hooks

* order

* wip

* orm version

* request return field

* fix return configuration on order model

* workflows

* core flows

* unit test

* test

* base repo

* test

* base repo

* test fix

* inventory move

* locking inventory

* test

* free text fix

* rm timeout mock

* migrate fulfillment values

* v6.4.3

* cleanup

* link-modules update sql

* revert test

* remove fake timers

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
Co-authored-by: Harminder Virk <virk.officials@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-01-21 08:04:47 -05:00
Stevche Radevski
05c8a67d8e feat: Add support for creating payment methods to payment module (#11063)
CLOSES CLO-407
2025-01-21 11:31:44 +00:00
Frane Polić
c1385c7002 fix(core-flows): cart validate sales channel (#11024) 2025-01-18 10:48:58 -05:00
olivermrbl
efe141f54b chore: Version packages 2025-01-17 10:29:04 -05:00
Riqwan Thamir
5eab9e7399 feat(promotion,dashboard,types,utils,medusa): Add statuses to promotions (#10950)
what:

- adds a status column to promotion table
- introduce active promotion query
- scope revert, register and compute actions to active promotions
- admin to create and update promotion with statuses

RESOLVES CMRC-845
RESOLVES CMRC-846
RESOLVES CMRC-847
RESOLVES CMRC-848
RESOLVES CMRC-849
RESOLVES CMRC-850
2025-01-16 19:17:22 +00:00