Commit Graph

7976 Commits

Author SHA1 Message Date
Frane Polić
3464617553 fix(medusa): Payment status on refunds (#2770) 2022-12-12 19:04:36 +01:00
Oliver Windall Juhl
b2ea8b7d45 fix(medusa): Throw on flat rate shipping options with no amount (#2628) 2022-12-12 18:34:30 +01:00
Adrien de Peretti
e63777e3c5 fix(medusa): Creating tax lines in cart completion strategy (#2761) 2022-12-12 18:28:41 +01:00
Adrien de Peretti
424efff919 feat(medusa): Allow to assign a Collection to a Product on import (#2764) 2022-12-12 17:10:03 +01:00
Kasper Fabricius Kristensen
33aa3edb80 fix(medusa): keep country_code when partially updating cart addresses (#2683)
**What**
- Fixes a bug where `country_code` was dropped when partially updating a shipping or billing address on a cart.
2022-12-12 14:03:54 +00:00
Sebastian Rindom
ae290a395a chore: move to GitHub Discussions for feature requests (#2765) 2022-12-12 13:20:16 +01:00
Shahed Nasser
64a4dcc53b docs: fixed tabs in create-medusa-app (#2762) 2022-12-12 13:27:48 +02:00
Adrien de Peretti
d68e81fb3d fix(medusa): Update line item adjustments upon cart discount removal (#2751)
**What**

When a discount is deleted from a cart, the line item adjustments must be refreshed. Now, the cart service `removeDiscount` includes updating the adjustments.

**Tests**

**Add a new integration test which:**
- create a cart with a discount 
- add a line item
- validate the adjustments
- remove the discount
- check that the adjustments are not present anymore

**Update unit tests**
The actual tests cases now check that the adjustments repository is called when needed

FIXES CORE-890
2022-12-12 09:53:40 +00:00
Kasper Fabricius Kristensen
72f70bc789 fix(medusa): Decorate order with totals in store domain (#2747) 2022-12-09 09:42:53 +01:00
Shahed Nasser
0d1e73f152 docs: added Klarna documentation (#2746) 2022-12-08 20:26:35 +02:00
Shahed Nasser
a57177ded5 docs: redesigned code blocks (#2745)
* docs: redesigned code blocks to include titles

* docs: added a title where necessary
2022-12-08 18:52:54 +02:00
Philip Korsholm
a6243618fe feat(medusa): Claim customer orders (#2710) 2022-12-08 17:48:49 +01:00
Patrick
86f9455d00 test: allow integration-tests to leverage workspaces optimizations (#2727)
### What
Leverage yarn workspaces and Turborepo for integration-tests in order to accelerate development and reduce DevX complexity.

### Why
The current solution for running integration tests requires using `medusa-dev-cli` in order to publish packages to a local npm repository. The package where the command is executed will have its package.json altered for any known medusa dependency in order to install from the local npm. The process is taxing on the host machine resources and prevents rapid iterations when working with integration tests.

For more information, see documentation: f0cc1b324c/docs/content/usage/local-development.md (run-api-integration-tests)

### How
By declaring `integeration-tests/**/*` as a workspace, Turborepo can now be leveraged to build and run integration test as if there were packages. The build process will take care of interdependency between package in order to ensure local dependency are met.

In addition, within each integration-tests "packages", we can declare local dependencies as "*" which will translate to using the one that is part of the current build, regardless of the dependency's version number. No more fiddling with version numbers.

Github actions pertaining to integration-tests have been streamlined to use the new behavior.

The integration-tests packages have been marked as `private:true` in order to avoid publishing them to the public npm registry.

### Testing
```
cd root-of-medusajs-medusa-repo/
yarn install
yarn build
yarn test:integration:api
yarn test:integration:plugins
```

After a code change, `yarn build` must be run before re-running an integration test, which is the same procedure as for unit tests.

Resolves: CORE-845
2022-12-08 14:57:16 +00:00
Riqwan Thamir
34e405c492 Merge pull request #2729 from medusajs/fix/discount-regions-validation
fix(medusa): discounts service create validates against at-least 1 region
2022-12-08 11:34:51 +01:00
Riqwan Thamir
dbe25245b5 Merge branch 'develop' into fix/discount-regions-validation 2022-12-08 10:50:20 +01:00
olivermrbl
2b2ea157a6 chore(workflows): Fix merge conflicts with master 2022-12-07 20:28:32 +01:00
Riqwan Thamir
5240972cef chore: remove expectations in callbacks 2022-12-07 17:03:51 +01:00
Riqwan Thamir
c1cdb80436 chore: use splat instead of lodash to clone, remove unnecessary expectations 2022-12-07 16:42:32 +01:00
Riqwan Thamir
40694bd5d1 chore: add a validation in the service layer to conform to 1 region rule 2022-12-07 16:42:32 +01:00
Riqwan Thamir
7fcf2b86a9 chore: prevent adminSession variable from being mutated in the helpers 2022-12-07 16:42:32 +01:00
Riqwan Thamir
66bec2f54d test: add a case when regions only contain invalid region Ids 2022-12-07 16:42:32 +01:00
Riqwan Thamir
bcc1edbf2b chore: addressing review - move repeated strings and objects to constants 2022-12-07 16:42:32 +01:00
Riqwan Thamir
cb2a32a82b chore: add changeset 2022-12-07 16:42:32 +01:00
Riqwan Thamir
f22e063ed8 test: fix existing integration tests and add a new test that validates regions inclusion and validity 2022-12-07 16:42:32 +01:00
Riqwan Thamir
d4e565b0b9 fix: regions are changed from an optional to required field
A discount should always be associated to atleast 1 region - we validate it against the region in the cart service.

Adding a request parameter validation to pass in atleast one regionID in an array of regions will ensure that regionID will be validated as a part of the discount service and fail if its not a valid region ID.
2022-12-07 16:42:32 +01:00
Carlos R. L. Rodrigues
15c667fbd3 feat(medusa,medusa-react): PaymentCollection support (#2659)
* chore: medusa react, order edit complete fix and single payment session
2022-12-07 12:39:35 -03:00
Adrien de Peretti
42d9c7222b feat(medusa): Performance improvements of Carts domain (#2648)
**What**

I have created a new method on the cart service which is `addLineItems`, allowing a user to add one or multiple items in an optimized way. Also updated the `generate` method from the line item service which now also accept a object data or a collection of data which. Various places have been optimized and cache support has been added to the price selection strategy.

The overall optimization allows to reach another 9000% improvement in the response time as a median (Creating a cart with 6 items):

|   | Min (ms)  | Median (ms)  | Max (ms)  | Median Improvement (%)
|---|:-:|---|---|---|
| Before optimisation  | 1200  | 9999 | 12698  |  N/A
| After optimisation | 63  | 252  | 500  | 39x
| After re optimisation | 56 | 82  | 399  | 121x
| After including addressed feedback | 65 | 202  | 495  | 49x

FIXES CORE-722
2022-12-07 14:39:12 +00:00
Frane Polić
3b2c929408 feat(medusa-js, medusa-react): PublishableKeys SC management (#2734) 2022-12-07 12:16:48 +01:00
Frane Polić
322d462311 feat(medusa): PublishableApiKeys SC scopes (#2590)
**What**
-  add/ remove sales channels to/from PublishableApiKey in batch
- associate created cart with SC defined by PK
- filter products if PK with SC association is present
- retrieve a list of sales channels for a PK
- implement 3 new middleware
  - `extendRequestParams`
    -  _extend req object with PK scopes (a list of sales channels) if a publishable key is present in the header of the request_
  - `validateProductSalesChannelAssociation`
    -  _validate if the passed product id belongs to a SC from the PK's scope_
  - `validateSalesChannelParam`
    -  _validate that passed SC ids in the req body/query are within the scope of the PK_

**How**
- The general idea was to reuse existing logic in the controller layer which expects `sales_channel_id` array to be passed. The middleware sets associated SC ids in the request context if a PK is present. These ids are then merged in the controller and passed to the service layer.

**TODO**
- filter response from the search endpoint (CORE-824)

**Testing**
- _integration tests_
  - add sales channels to the publishable API key scope
  - remove sales channels from the publishable API key scope
  - returns products from a specific channel associated with a publishable key
  - returns products from multiples sales channels associated with a publishable key
  - returns all products if PK is not passed
  - returns all products if passed PK doesn't have associated channels
  - should assign sales channel to order on cart completion if PK is present in the header
  - list sales channels from the publishable api key
  -  throws because sales channel in query/body is not in the scope of passed PK 

---

**Discussion**
- what about the other endpoints (e.g. GET /store/product/:id - do we return 404 if the product is not in the SC associated with passed PK)
- what about products search route
- what about `/admin/products` & `/admin/orders` routes (do we add the middleware there as well)

---

RESOLVES CORE-792
RESOLVES CORE-793
RESOLVES CORE-816
2022-12-07 07:50:20 +00:00
Shahed Nasser
8efae2dfcf docs: added details about admin analytics in usage documentation (#2733) 2022-12-06 18:14:07 +02:00
Shahed Nasser
2ffeaf567f docs: delete unused doc files (#2732) 2022-12-06 18:13:38 +02:00
chemicalkosek
5bd2faa02b docs: fix import path in medusa-react README (#2731) 2022-12-06 17:26:13 +02:00
Shahed Nasser
7363cae339 docs: Added Manage Discounts using Admin APIs doc (#2730) 2022-12-06 16:43:13 +02:00
Patrick
4cb93e37df chore(docs): remove unused files from www directory (#2722) 2022-12-05 10:52:34 -05:00
Patrick
621a37cb68 chore(docs): remove unused files from www directory 2022-12-05 10:23:09 -05:00
Patrick
65456252a1 chore(docs): remove www/reference directory from codebase 2022-12-05 10:23:09 -05:00
Adrien de Peretti
1b21af87ab chore(medusa-core-utils): Migrate to TS (#2670) 2022-12-05 10:21:04 +01:00
Philip Korsholm
406354c97e chore(workflows): Update trigger-staging-release.yml (#2718) 2022-12-04 15:42:27 +01:00
Shahed Nasser
f19e4de636 docs: added Use Discounts in Checkout documentation (#2717) 2022-12-02 16:10:54 +02:00
Patrick
1dc816039c chore(oas): explicitly declare type:object on schemas with properties (#2712)
### What

OAS: Explicitly declare type:object on schemas with properties.

### Why

While not officially required, schemas with properties should have their type explicitly declared as "object". Omitting the type translates to type: any with properties XYZ. The ambiguity can lead to issues when using code generators.

### How

Multiple regex searches to identify schemas missing type: object. Manually edit each schema. Spot check generated OAS.

### Testing
- Ran OAS validator.
- Ran docs build script

### Proof
![Screen Shot 2022-12-01 at 1 46 13 PM](https://user-images.githubusercontent.com/116003638/205137671-7a6770dd-4f9b-456c-99a6-ac654f6d0f59.png)


RESOLVES CORE-847
2022-12-02 13:51:16 +00:00
Shahed Nasser
c729921180 docs: fixes to discounts documentation percentage (#2711)
* docs: fixes to discounts documentation

* docs: added a note about regions for fixed discount
2022-12-01 17:37:56 +02:00
Shahed Nasser
b54405e3de docs: added Discounts Architecture documentation (#2709)
* docs: added discounts architecture documentation

* docs: fix tooltip text showing in the copied text

* docs: added missing link
2022-12-01 16:08:27 +02:00
Shahed Nasser
6cea109caa docs: added user guide for Manage Discounts (#2706) 2022-11-30 19:24:34 +02:00
Shahed Nasser
7bee40c6f3 docs: added Create a Discount user guide (#2705) 2022-11-30 17:32:43 +02:00
Philip Korsholm
761ea8383d chore(workflow): Ignore changes in ./github folder in staging release trigger 2022-11-30 13:59:27 +01:00
Philip Korsholm
b023d846c3 Feat(Medusa): Trigger staging deployment (#2695)
* initial implementation of trigger action

* rename access token

* update paths ignore
2022-11-30 13:59:26 +01:00
Sebastian Rindom
198fe78c13 fix: allow passing idempotency key to service layer create (#2701)
**What**

Allow DraftOrders to be created with an IdempotencyKey. 

Note this doesn't implement idempotency for the DraftOrder create endpoint but allows the service layer to ingest the key and store it in the database. This is a preliminary step to being able to support an idempotent API request.
2022-11-30 09:23:59 +00:00
Philip Korsholm
0764c6f994 chore(workflow): Ignore changes in ./github folder in staging release trigger 2022-11-30 09:39:12 +01:00
github-actions[bot]
daa31b78f6 chore(docs): Removed Docs Announcement Bar (automated) (#2700)
Co-authored-by: shahednasser <shahednasser@users.noreply.github.com>
2022-11-30 09:57:41 +02:00
Shahed Nasser
663e262cc4 docs: added deploy to railway docs (#2697) 2022-11-29 19:16:18 +02:00