2247 Commits

Author SHA1 Message Date
Adrien de Peretti
a77780671a fix(medusa): Transaction lock issues on create/update cart items (#2612)
* fix(medusa): Transaction lock issues on create/update cart items

* fix add missing trans

* cleanup

* cleanup

* Create perfect-bears-invent.md

* cleanup

* revert draft order to no take it in that pr

* cleanup handler

* cleanup steps

* fix reference issue

* cleanup + fix tests and mock

* cleanup type

* rename file

* cleanup

* fix missing transaction

* wip

* Address pr feedback

* cleanup and fix unit tests

* fix handler

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2022-11-18 12:15:53 +01:00
Philip Korsholm
5332081972 fix(medusa, medusa-plugin-discount-generator, medusa-plugin-restock-notification): Bump Medusa package versions (#2623) 2022-11-18 10:50:13 +01:00
Philip Korsholm
c6c5667cdd Fix/staging release install and versioning (#2621) 2022-11-17 16:38:14 +00:00
Philip Korsholm
f60267a494 feat(medusa): Release staging version on push to develop (#2594)
* initial

* working config

* update name and add snapshot to release

* add changeset

* use correct command for action

* pr feedback
2022-11-16 20:08:18 +01:00
Patrick
022a84691e fix(draft-order): create tax-inclusive with discount (#2579)
**What**
Fix system error (500) with DraftOrder create operation when payload includes discount in a tax-inclusive context.

**How**
* Ensure newly created cart contains all required relation in order to calculate line item tax-inclusive pricing with discounts.
* Add resilience to TotalsService.getLineDiscounts()
* Ensure newly generate line items have variant relation loaded.
* fix TotalsService.getLineItemTotals to use the passed lineItem instead of relying on cartOrOrder.items.

**Test**
* Unit:
  *  TotalsService.getLineDiscounts - coverage
* Integration:
  * Admin API draft-order - coverage
  * Admin API draft-order create w/ discount in tax-inclusive

Resolves: CORE-771

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2022-11-16 15:34:18 +00:00
Adrien de Peretti
9e91a50df1 fix(medusa-payment-stripe): Missing transactions in Stripe provider (#2603) 2022-11-14 20:03:06 +01:00
olivermrbl
7914f2a82a chore: Version medusa-payment-stripe 2022-11-09 20:36:31 +01:00
olivermrbl
715bdf6b15 chore: Patch bump stripe 2022-11-09 20:35:21 +01:00
olivermrbl
a4dd26e137 chore(release): Publish 2022-11-09 19:34:59 +01:00
Oliver Windall Juhl
cfb24d72fa fix(medusa-telemetry): Fix incorrect import (#2574)
Duplicate of #2126
2022-11-09 16:51:37 +00:00
Patrick
7b0ceeffb4 feat: /store api product types (#2552)
## What
Allow users to fetch ProductTypes from the storefront API.

## Why
This endpoint will allow developers to implement better faceted product search in Medusa without the need for search plugin. Developers will be able to use this to render refinement lists based on types, like this:
![image](https://user-images.githubusercontent.com/116003638/200417828-863065de-3607-49db-bd72-62a6815129fa.png)

## How
Endpoint `GET /store/products/types` and `GET /store/product-types` (use [product types listing in admin](https://github.com/medusajs/medusa/blob/master/packages/medusa/src/api/routes/admin/products/list-types.ts) as reference)

Support added in @medusajs/medusa-js
Support added in medusa-react

## Testing
Similar automated tests as `GET /admin/products/types` and `GET /admin/product-types`

---

Resolves CORE-699
2022-11-09 16:10:17 +00:00
Adrien de Peretti
2d095a0ce1 fix(medusa): fix missing throw in the store cart create-payment-sessions (#2568) 2022-11-09 16:47:17 +01:00
Sebastian Rindom
8069ed5e99 fix(medusa): add support for retrying failed event bus jobs (#2566)
Closes CORE-770
2022-11-09 12:24:26 +00:00
olivermrbl
5ea4b728e7 chore: Add missing changeset 2022-11-09 10:56:02 +01:00
olivermrbl
4542906619 chore(release): Publish 2022-11-04 11:37:56 +01:00
Oliver Windall Juhl
222423625d chore(medusa): Enable analytics ff by default (#2532) 2022-11-04 11:33:21 +01:00
Sebastian Rindom
61da5f3650 fix(medusa-plugin-brightpearl): account for shipping prices being tax inclusive (#2536)
**What**
BP plugin was recording total shipping price based on the shipping_method.price; however, this value may be with or without taxes depending on the tax inclusivity setting. This change ensures that the shipping price is calculated correctly.
2022-11-03 15:22:49 +00:00
Philip Korsholm
38d4a7db3d Feat(Medusa): Allow custom shipping price on draft orders (#2531)
* create custom shipping option for cart to have custom shipping price on draft orders

* Create moody-chefs-stare.md
2022-11-03 08:44:47 +01:00
Philip Korsholm
ea3d738823 Feat(medusa): config error handling in loaders (#2514)
**What**
- add error handling when loading project config

**How**
- Add error parameter to get-medusa-config result if an error was thrown (previously we returned an empty config)
- Discussion: 
A different, but equally valid approach could be just throwing the error rather than creating an error parameter. This causes a more ugly output without warnings and changes the api a bit but it would force error handling. wdyt?

**Why**
- cli would fail with database error `databaseMissingDriverError` if config was invalid, ex. missing a comma


### example (missing `,` in config)
**old output**
```
Successfully compiled 2 files with Babel (143ms).
[medusa-config] ⚠️ redis_url not found. A fake redis instance will be used.
[medusa-config] ⚠️ database_type not found. fallback to default sqlite.
info:    Using flag MEDUSA_FF_ORDER_EDITING from environment with value true
info:    Using flag MEDUSA_FF_SALES_CHANNELS from environment with value true
info:    Using flag MEDUSA_FF_TAX_INCLUSIVE_PRICING from environment with value true
info:    Using fake Redis
✔ Models initialized – 13ms
✔ Plugin models initialized – 0ms
✔ Repositories initialized – 17ms
⠋ Initializing databaseMissingDriverError: Wrong driver: "undefined" given. Supported drivers are: "aurora-data-api", "aurora-data-api-pg", "better-sqlite3", "capacitor", "cockroachdb", "cordova", "expo", "mariadb", "mongodb", "mssql", "mysql", "nativescript", "oracle", "postgres", "react-native", "sap", "sqlite", "sqljs".
```

**new output** 
```
Successfully compiled 2 files with Babel (185ms).
error:    Error in loading config: Unexpected identifier
error:    /Users/phko/projects/community/my-medusa-store/medusa-config.js:129
  plugins,
  ^^^^^^^

SyntaxError: Unexpected identifier
    at compileFunction (<anonymous>)
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at getConfigFile (/Users/phko/projects/community/my-medusa-store/node_modules/medusa-core-utils/dist/get-config-file.js:26:20)
```
2022-11-02 18:58:02 +00:00
olivermrbl
ee8a71c692 chore(release): Publish 2022-11-02 16:44:54 +01:00
olivermrbl
a014e3623c chore: Add Stripe plugin changeset 2022-11-02 16:41:11 +01:00
olivermrbl
144ce0e42c chore: Add missing changeset for 2479 2022-10-31 13:42:27 +01:00
Sebastian Rindom
58c7ffdc6e fix(medusa): allow filtering collections by handle (#2482) 2022-10-31 08:51:15 +00:00
Adrien de Peretti
299c4ae7f5 feat(medusa): Align product import and export (#2471)
**What**

Create a data structure that facilitate the addition of new column descriptor for both export and import and ensure that the column name is shared between bother import and export to facilitate the import with an exported file. 

**Tests**

Add an additional integration tests that export a file, update the data, and re import the same file

FIXES CORE-716
FIXES CORE-713
2022-10-20 14:48:34 +00:00
Adrien de Peretti
13611e3e53 fix(medusa): Select config should be undefined if length === 0 (#2469) 2022-10-20 13:25:23 +02:00
Adrien de Peretti
8be67c734c feat(medusa): Filter product list by discount condition id (#2464) 2022-10-19 11:23:33 +02:00
Adrien de Peretti
9deec0fc3c fix(medusa): Idempotency workStage used within transaction (#2358) 2022-10-19 10:47:31 +02:00
Philip Korsholm
3c5e31c645 fix(medusa, medusa-file-*): Protected uploads for file services (#2433) 2022-10-18 10:46:47 +02:00
Oliver Windall Juhl
7d77d91a3d chore: Automate staging releases with action (#2458) 2022-10-17 18:11:49 +02:00
Adrien de Peretti
48411157b1 feat(medusa): Support batch remove resources on discount condition (#2444)
**what**
- Add support to remove resources by batch on discount conditions
- Add support on medusa-js and medusa-react

**Tests**
- Add integration tests to validate that the resources have been deleted and the length is the one expected
- Add unit tests on medusa react

FIXES CORE-609
2022-10-17 09:03:38 +00:00
Adrien de Peretti
765a2cccda Feat/add discount condition batch (#2430)
* feat(medusa): Allow to add items to a discount condition by batch + cleanup of discounts and discount conditions end points

* style(medusa): cleanup catch and log

* feat(medusa-react, medusa-js): Add support to add item batch to discount condition

* cleanup

* cleanup

* rename items to resources

* fix(medusa-js): url

* Create fast-suns-repair.md

* update naming

* tests(integration): Update tests to reflect API changes

* feat(medusa): Delete a condition should be idempotent on discount and condition

* revert
2022-10-13 16:34:06 +02:00
Kasper Fabricius Kristensen
69e579758f fix(medusa, medusa-js): Use price selection strategy for GET /admin/variants (#2270)
**What**
- Adds the use of price selection strategy to the endpoint `GET /admin/variants`
- Updates medusa-js to reflect this change (expanding the parameters).

**Testing**
- Adds a new integration test validating that returned variants are now of type PricedVariant, with the expected fields: original_price, calculated_price, etc.

**Why**
- Our current RMA flows (in our admin dashboard) relied heavily on simply using `order.tax_rate` to calculate variant prices in the different RMA menus. As taxes in Medusa, have become feature complete this approach had become very naive and has several potential issues. Moving the responsibility for calculating the correct prices guarantees that we always show the correct prices to admins.
2022-10-13 08:54:03 +00:00
Kasper Fabricius Kristensen
211720f24c fix(medusa): List products by type_id (#2427)
**What**
- Fixes `GET /products` in both admin and store API so they no longer accept the param `type?: string`, but instead accept `type_id?: string[]`

**Why**
- Filtering by type would never return any products as `ptyp_:id` !== `ProductType`.

**Testing**
- Added an integration test for each endpoint.

Closes CORE-695
2022-10-12 18:56:56 +00:00
Frane Polić
05f921711f fix(medusa): Product import - allow null product type (#2424)
**What**
- allow the product type field to be null

**How**
- in case the type is `null`, pass `undefined` as the value of type prop to product create/update services, otherwise pass an object with `{value}` which will be upserted

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2022-10-12 12:43:41 +00:00
Sebastian Rindom
196595cb65 fix(medusa-dev-cli): Avoid dev cli auth (#2360) 2022-10-12 09:45:45 +02:00
Adrien de Peretti
c717442451 feat(medusa): Allow to filter collections by discount condition id (#2411) 2022-10-11 16:14:10 +02:00
Adrien de Peretti
a9c703d56c feat(medusa): Allow to query product tags by condition id (#2340) 2022-10-11 11:24:50 +02:00
Adrien de Peretti
19ca18e71c feat(medusa): Allow to query product types by discount condition id (#2359) 2022-10-11 08:36:08 +02:00
olivermrbl
35df4962f8 chore(release): Publish 2022-10-10 18:02:50 +02:00
olivermrbl
8f4135fd5f chore: Add changeset for medusa-file-s3 2022-10-10 17:57:26 +02:00
Sebastian Rindom
a908a7716c fix(medusa-payment-klarna, medusa-payment-stripe, medusa-payment-paypal): Totals calculation (#2381) 2022-10-08 10:53:19 +02:00
Ayush Sharma
d8a5942d3d fix(medusa) : Improperly referenced product id in product import strategy (#2351)
* What - fixing PR #2350 

* Why - In the ProductImportStrategy class, the getImportInstructions improperly checks the product.id for each row. With it setup this way, products will always be considered new because the product.id column is not read here. So products will never be updated. [Link to the code line](bd94130916/packages/medusa/src/strategies/batch-jobs/product/import.ts (L166))

* How - Replacing `row["product.product.id"]` to  `row["product.id"]`

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2022-10-07 09:36:36 +00:00
Sebastian Rindom
3d255302b0 fix(medusa): Optimize Cart totals calculation (#2372)
**What**

The existing totals calculations are extremely heavy and perform an enormous amount of duplicate work. The changes here remove large parts of the overhead and improves response times for cart endpoints up to 30x.
2022-10-07 08:44:06 +00:00
Oliver Windall Juhl
edd35631f7 fix(medusa): Add sales channel to order on creation (#2374) 2022-10-07 09:12:25 +02:00
Oliver Windall Juhl
d2b272fab6 feat(medusa): Trim discount code on insert and retrieve (#2369) 2022-10-07 09:07:32 +02:00
Philip Korsholm
642902aaeb feat(medusa-js, medusa-react): Support expand fields in order retrieval (#2353) 2022-10-06 13:58:46 +02:00
olivermrbl
69f2f12d06 chore: Change minor to patch in changesets 2022-10-06 10:09:20 +02:00
olivermrbl
94eb2bfc02 Merge branch 'master' into develop 2022-10-04 10:50:12 +02:00
Adrien de Peretti
df62e618bc feat(medusa,medusa-payment-stripe): Migrate Stripe to Abstract payment service (#1790) 2022-10-04 10:49:43 +02:00
Oliver Windall Juhl
1024ac1a36 fix(medusa-payment-manual): Add missing update method (#2254) 2022-10-04 10:48:39 +02:00