Commit Graph

444 Commits

Author SHA1 Message Date
Shahed Nasser
3a0c69fbe0 fix(fulfillment): export schema types (#10700)
Export `ServiceZoneSchema` and `GeoZoneSchema` so that we can infer types correctly in references
2024-12-23 12:58:43 +00:00
olivermrbl
348f866ffe chore: Version packages 2024-12-20 11:25:36 +01:00
Adrien de Peretti
100da64242 chore(fulfillment, utils): Migrate module to DML (#10617)
**What**
- Allow to provide `foreignKeyName` option for hasOne and belongsTo relationships
  - `model.hasOne(() => OtherEntity, { foreignKey: true, foreignKeyName: 'other_entity_something_id' })`
  - The above will also output a generated type that takes into consideration the custom fk name 🔽 
- Update types to account for defined custom foreign key name
- Fix joiner config linkable generation to account for custom linkable keys that provide a public API for their model but are not part of the list of the models included in the MedusaService
  - This was supposed to be handled correctly but the implementation was not considering that custom linkable keys could reference models not part of the one provided to medusa service
- Migrate fulfillment module to DML
- Fix has one with fk behaviour and hooks (the relation should be assigned but not the fk)
- Fix has one belongsTo hooks (the relation should be assigned but not the fk)
- Fix hasOneWithFk and belongsTo non persisted fk to be selectable
- Allow to define `belongsTo` without other side definition for `ManyToOne` with no counter part defined
  - Meaning that if a user defined `belongsTo` on one side andnot mapped by and no counter part on the other entity it will be considered as a `ManyToOne`
- `orphanRemoval` on `OneToOne` have been removed, this means that when assigning a new object relation to an entity, the previous one gets deconected but not deleted automatically. This prevent removing data un volountarely

**NOTE**
As per our convention here are some information to keep in mind

**HasOne <> BelongsTo**
Define `OneToOne`, The foreign key is owned by the belongs to and the relation needs to be provided to cascade if wanted

**HasMany <> BelongsTo**
Define `OneToMane` <> `ManyToOne`, the foreign key is owned by the many to one and for those relation no cascade will be performed, the foreign key must be provided. For the `HasMany` the cascade is available

**HasOne (with FK)**
Will act similarly to belongs to with **HasOne <> BelongsTo**

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2024-12-19 16:40:11 +00:00
Riqwan Thamir
d08b71f9b8 fix(product): updating collections with products fix (#10668) 2024-12-19 16:31:45 +01:00
Riqwan Thamir
3f4d574748 feat(order, types): Add Credit Line to order module (#10636)
* feat(order, types): Add Credit Line to order module

* chore: add action to inject credit lines
2024-12-19 10:36:59 +01:00
Oli Juhl
9133957a94 fix(notification): Only use enabled providers for notis (#10659) 2024-12-18 13:59:12 +01:00
Oli Juhl
c9b8db04c1 feat: Custom line items (#10408)
* feat: Custom line items

* fix tests

* fix migration

* Allow custom items in update line item workflow

* throw if line item doesn't have a price

* minor things

* wip

* fix flows

* fix test

* add default

* add to type
2024-12-18 12:53:57 +01:00
Frane Polić
bde4b82194 feat(core-flows,dashboard,js-sdk,medusa,types): support Fulfillment Options (#10622)
**What**
- add a list point for fetching fulfillment options for a provider
- add FO support on SO create & update on dashboard
- pass `cart` and `stockLocation` to `validateFufillmentData` context

---

CLOSES CMRC-789
CLOSES CMRC-790
2024-12-18 09:16:26 +00:00
olivermrbl
a391a29aa8 chore: Version packages 2024-12-17 14:41:05 +01:00
Riqwan Thamir
6367bccde8 feat(medusa,pricing): Cart pricing context with customer group (#10579)
* fix(carts): Fixes cart modifications not accounting for certain price lists (#10493)

*What*

* Fixes #10490
* Expands any available customer_id into its customer_group_ids for cart
  updates that add line items.

*Why*

* Cart updates from the storefront were overriding any valid price lists
  that were correctly being shown in the storefront's product pages.

*How*

* Adds a new workflow step that expands an optional customer_id into the
  customer_group_ids it belongs to.
* Uses this step in the addToCartWorkflow and
  updateLineItemInCartWorkflow workflows.

*Testing*
* Using medusa-dev to test on a local backend.
* Adds integration tests for the addToCart and updateLineItemInCart
  workflows.

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>

* chore: update cart workflows to accept new pricing context

* chore: add transfer specs

* chore: fix specs

* chore: modify types + specs

* chore: add data migration + dashboard changes

* chore: fix update line item workflow

* chore: add changeset + unskip spec

---------

Co-authored-by: Sergio Campamá <sergiocampama@gmail.com>
2024-12-17 11:10:30 +01:00
Frane Polić
0c49470066 feat(core-flows): calculate SO price on cart ops (#10563)
**What**
- calculate the shipping option price when creating a shipping method
- calculate the shipping option price when refreshing cart
- add testing for calculated SO flow
- fix validation on calculated SO creation
- add manual fulfillment provider for testing
- add `from_location` to calculation context

---

RESOLVES CMRC-778
RESOLVES CMRC-602
RESOLVES SUP-136
2024-12-16 22:28:30 +00:00
Carlos R. L. Rodrigues
95baacfd00 fix(cart): Tax rate data type (#10626)
* fix(cart): tax rate data type

* update test
2024-12-16 20:09:05 +01:00
Riqwan Thamir
90ad2566fd feat(types,fulfillment): ability to delete a canceled fulfillment (#10602) 2024-12-16 11:17:45 +01:00
Carlos R. L. Rodrigues
729eb5da7b chore(inventory): convert to dml (#10569)
Fixes: FRMW-2848

Co-authored-by: Harminder Virk <1706381+thetutlage@users.noreply.github.com>
2024-12-13 12:51:26 +00:00
Harminder Virk
e021c9258c Feat/tax dml (#10525)
Fixes: FRMW-2842

There are zero breaking changes and the users will have to run the migrations
2024-12-12 09:35:11 +00:00
Frane Polić
472e92e400 feat(medusa, core-flows, fulfillment): calculate SO price endpoint (#10532)
**What**
- endpoint + flow for fetching calculated price for a shipping option

---

CLOSES CMRC-777
2024-12-12 08:03:56 +00:00
Carlos R. L. Rodrigues
0264294ab5 chore(payment): Payment module DML (#10553)
* chore(payment): Payment module DML

* rm log

* migration
2024-12-11 13:09:10 -03:00
Stevche Radevski
3626118eef feat(file-s3): Add support for IAM role authentication to file-s3 provider (#10528) 2024-12-11 18:30:37 +08:00
Harminder Virk
16d27ea6e4 feat: Migrate customer module to DML (#10499) 2024-12-11 14:37:27 +05:30
Frane Polić
d8a92dbb2d feat(core-flows, dashboard, fulfillment, fulfillment-manual, utils, types): create shipping options with calculated prices (#10495)
**What**
- support creating SO with calculated price
- support updating SO for both types of pricing
- update `validateShippingOptionPricesStep` to handle both SO price_types
- add the `validateShippingOptionsForPriceCalculation` method to `FulfillementModule`
- add `canCalculate` and `calculatePrice` to fulfillment provider service service / interface / manual provider
- disable SO pricing edit on Admin if SO price type is calculated

---

CLOSES CMRC-776
2024-12-11 08:38:44 +00:00
Harminder Virk
fad85a9d29 refactor: migrate promotion module (#10410) 2024-12-11 13:12:39 +05:30
Kasper Fabricius Kristensen
16192d9b30 fix(product): Only apply default order to products if user has not specified one (#10535) 2024-12-10 16:57:11 +00:00
Harminder Virk
4ad9ac1e5f refactor: migration stock location module (#10471)
Fixes: FRMW-2831
2024-12-10 16:08:48 +00:00
olivermrbl
0e342b491d chore: Version packages 2024-12-10 14:01:50 +01:00
Carlos R. L. Rodrigues
69f4c4f4e0 chore(index): index dml (#10482)
What:
- DML - `autoincrement` property
- Index `type` option (GIN)
- Index module - DML
2024-12-10 10:55:12 +00:00
Riqwan Thamir
a04238a7f1 fix(payment): ensure that payment error is captured in logger (#10506)
what:

- when an error occurs upon retrieving a provider, log the original error through the logger

Helps https://github.com/medusajs/medusa/issues/10500 in debugging.
2024-12-09 16:44:32 +00:00
Riqwan Thamir
9e797dc3d2 feat(core-flows, types): update shipping methods upon cart ops (#10382)
* feat(core-flows,framework,medusa): list shipping options pass in cart as pricing context

* chore: add test for shipping options returning free shipping

* feat(core-flows, types): update shipping methods upon cart ops

* chore: fix specs

* chore: fix bugs + specs

* Update update-shipping-methods.ts

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

* Update mutations.ts

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

* chore: undo refresh changes

* chore: merge with latest

* chore: address PR comments

* chore: fix conflicts

* chore: fix specs

* chore: address reviews

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-12-08 14:06:50 +01:00
Riqwan Thamir
f95c4e240c fix(promotion, core-flows): updating cart with removed promotion removes adjustments (#10489) 2024-12-08 13:13:31 +01:00
Adrien de Peretti
0a077d48e1 chore(workflow-engine): Migrate to DML (#10477)
RESOLVES FRMW-2832
RESOLVES FRMW-2833

**What**
Migrate workflow engines to DML. Alos includes and update to the linkable generation which now takes into account id and primary keys to generate the linkable instead of only primary keys
2024-12-06 13:23:07 +00:00
Carlos R. L. Rodrigues
b0448a7c35 chore: locking-postgres provider dml (#10478) 2024-12-06 10:14:14 -03:00
Harminder Virk
f3c91c908a refactor: migrate store module to DML (#10467) 2024-12-06 17:38:15 +05:30
Carlos R. L. Rodrigues
90ae187e09 fix(workflows-sdk): name for when/then step (#10459) 2024-12-05 15:47:42 -03:00
Harminder Virk
70d77ea22f refactor: migrate api key module to DML (#10450)
Fixes: FRMW-2827
2024-12-05 16:37:54 +00:00
Harminder Virk
be15240909 refactor: migrate sales-channel to DML (#10452)
Fixes: FRMW-2830
2024-12-05 14:02:08 +00:00
Harminder Virk
0a16efa426 refactor: migrate cart module to DML (#10385)
FIXES: FRMW-2815

This PR has no breaking changes
2024-12-05 12:30:50 +00:00
olivermrbl
4723acd949 chore: Version packages 2024-12-04 18:36:57 +01:00
Frane Polić
340769595a feat(admin, js-sdk, types): update order forms (#10418)
* feat: edit shipping, billing and email forms

* feat: timeline history, update change model, update tests

* fix: address comments

* fix: invalidation, translation schema, update label

* fix: old/new
2024-12-04 14:56:40 +01:00
Kasper Fabricius Kristensen
4e7d242a78 fix(stock-location): Fix export of StockLocation module (#10406) 2024-12-03 18:35:52 +01:00
Frane Polić
ab948b7c65 feat(core-flows,medusa,order,types): update orders (#10373)
**What**
- add order update endpoint
- add workflows and steps for updating orders
- add `registerChanges` method to Order module + workflow step

---

CLOSES CMRC-633
2024-12-03 17:15:26 +00:00
Adrien de Peretti
ac79585232 feat(user): Migrate user module to DML (#10389)
* feat(user): Migrate user module to DML

* Create rotten-tigers-worry.md

* update indexes names following conventions

* remove duplicate modifier
2024-12-02 12:36:40 +01:00
Adrien de Peretti
4ef353a7b9 feat(auth): Migrate auth module to DML (#10387)
* feat(auth): Migrate auth module to DML

* Create lazy-eagles-bow.md
2024-12-02 11:58:04 +01:00
Harminder Virk
913cf15e2b refactor: migrate pricing entities to DML models (#10335)
Fixes: FRMW-2810

## Breaking changes
There is only one breaking change

- The `min_quantity` and `max_quantity` properties are now consistently typed as numbers. Earlier, it was [typed as numbers](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L68-L69) in some API responses and as [string in others](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L186-L187). I did not go to the bottom of this inconsistency, but the tests reveals them.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-12-02 09:44:41 +00:00
Riqwan Thamir
11bd556133 feat(core-flows,framework,medusa): list shipping options pass in cart as pricing context (#10374)
* feat(core-flows,framework,medusa): list shipping options pass in cart as pricing context

* chore: add test for shipping options returning free shipping
2024-12-01 20:59:26 +01:00
Riqwan Thamir
324b4ab438 feat(pricing, types): add price rule operators to price calculations (#10350)
what:

- adds price rule operators when doing price calculations
- rules now accepts a key where the value can be an array of objects `({ operator: string, value: number })`
  - validation for available types of operator and value to be a number
```
await service.createPriceSets({
  prices: [
    {
      amount: 50,
      currency_code: "usd",
      rules: {
        region_id: "de",
        cart_total: [
          { operator: "gte", value: 400 },
          { operator: "lte", value: 500 },
        ]
      },
    },
  ]
})
```
- price calculations will now account for the operators - lte, gte, lt, gt when the price context is a number

RESOLVES CMRC-747
2024-11-28 20:48:00 +00:00
Frane Polić
805fe4b1db fix(order): archive order status update (#10340)
**What**
- array was passed as an id when updating order status upon archive

---

RESOLVES SUP-305
CLOSES https://github.com/medusajs/medusa/issues/10328
2024-11-28 16:51:02 +00:00
Harminder Virk
d57c739052 fix: do not initialize FKs to null (#10337) 2024-11-28 17:15:08 +05:30
Stevche Radevski
f7279f1b96 fix: Use the correct defaults for the invite token expiry (#10344) 2024-11-28 12:06:32 +01:00
Riqwan Thamir
3b1a63eca7 feat(pricing,utils,types): add operator field to price rule (#10315)
what:

- adds an operator field to price rule with specific operator fields

RESOLVES CMRC-746
2024-11-28 09:23:26 +00:00
Shahed Nasser
2838100efc fix(product): change export name of ProductImage (#10326)
Change export of `Image` to `ProductImage` to match the data model's name.
2024-11-27 17:35:06 +00:00
olivermrbl
e9c1b1127e chore: Version packages 2024-11-27 15:40:07 +01:00