Commit Graph

69 Commits

Author SHA1 Message Date
Kasper Fabricius Kristensen
4fbf6b7ad3 fix(medusa-react): Fix production.min.js causing invalid hook usage error in CJS environments (#3144) 2023-02-01 14:07:02 +01:00
Kasper Fabricius Kristensen
6293fccc65 hotfix(medusa-react): Invalidate query keys on successful mutations (#3099)
**What**
- Fixes an issue where query keys weren't invalidated on successful mutations.

**How**
- Update `buildOptions` function to be called per `QueryKey` instead of passing them all as a single query key, resulting in no matches found.
- Fixes imports that aren't compatible with ESM modules.
2023-01-24 12:55:24 +00:00
Kasper Fabricius Kristensen
150696de99 feat(medusa, medusa-js, medusa-react): Add endpoint to retrieve product tags from the storefront (#3051) 2023-01-18 10:47:15 +01:00
olivermrbl
ab580066ae fix: Merge conflicts with master 2023-01-18 10:17:39 +01:00
Kasper Fabricius Kristensen
cb25244007 hotfix(medusa-js, medusa-react): Fix issue with JS client bundle (#3038) 2023-01-16 17:44:24 +01:00
Kasper Fabricius Kristensen
8d1275c942 feat(medusa-react): Upgrade react-query and clean up dependencies (#2969) 2023-01-11 19:19:34 +01:00
Kasper Fabricius Kristensen
c2c38dd091 fix(medusa, medusa-react): Typing of optional fields on multiple product endpoints (#2771) 2022-12-12 19:10:06 +01:00
Philip Korsholm
a6243618fe feat(medusa): Claim customer orders (#2710) 2022-12-08 17:48:49 +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
Frane Polić
3b2c929408 feat(medusa-js, medusa-react): PublishableKeys SC management (#2734) 2022-12-07 12:16:48 +01:00
Frane Polić
9eafde07fe feat(medusa-js): Register PublishableApiKey (#2616)
**What**
- register a publishable API key through `medusa-js` i.e. define the key that will be sent with each request

**How**
- introduce KeyManager class which is used to share keys between medusa-js objects.

**Usage**
1. Set the key through the `Medusa` config
2. Set the key through `KeyManager` dynamically:
```ts
import { KeyManager } from "medusa-js"

KeyManager.registerPublishableApiKey("pk_123")
```

---

RESOLVES CORE-794
2022-11-17 12:19:18 +00:00
Frane Polić
03fc9e18e9 feat(medusa, medusa-js, medusa-react): PublishableApiKey "update" endpoint & add "title" property (#2609)
**What**
- update PK endpoint
  - medusa-js/react implementation
- add a title property to the entity
  - update the migration file
  - pass a title on create
  - list PKs by title
  - update the client libs with new param signatures
- change id prefix to: "pk_"
2022-11-16 04:35:22 +00:00
Frane Polić
3de553c27f feat(medusa-js, medusa-react): PublishableApiKeys clients (#2582)
**What**
- add `PublishableApiKeys` endpoints to the `medusa-js` and `medusa-react` clients

--- 

RESOLVES CORE-791
DEPENDS ON https://github.com/medusajs/medusa/pull/2567
2022-11-15 15:41:58 +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
Kasper Fabricius Kristensen
fcfb7d167b fix(medusa): Allow AddressPayload or string on DraftOrder creation (#1902) 2022-10-19 18:01:08 +02:00
Philip Korsholm
3c5e31c645 fix(medusa, medusa-file-*): Protected uploads for file services (#2433) 2022-10-18 10:46:47 +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
Adrien de Peretti
143f8543e5 feat(medusa, medusa-js, medusa-react): Support listing order edits (#2436)
* feat(medusa, medusa-js, medusa-react): Support listing order edits

* feat(medusa): Update OAS

* fix oas

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2022-10-13 14:44:08 +02:00
Frane Polić
308b99cc5d fix(medusa-react): OrderEdit add item hook renaming (#2392) 2022-10-11 12:28:24 +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
Philip Korsholm
00959f79bc Feat(medusa): remove item from order (#2273)
* wait for update to order edit model

* delete line item tests

* create remove method for lineitem with tax lines

* add remove item tests

* split delete allocation tests into two: more and less than total

* remove unused import

* cleanup

* add medusa-js and react endpoints

* pr feedback fixes

* linting

* remove unused relation from query

* remove removed-event and unused imports

* add await
2022-09-30 09:48:18 +02:00
Adrien de Peretti
95c0dc653a feat(medusa, medusa-js, medusa-react): Implement store complete order… (#2275)
**What**

Allow a customer to complete a requested order edit.

**Test**
- Unit tests complete flow
- Unit tests medusa react
- Integration tests of order edit completion

FIXES CORE-501
2022-09-29 17:06:45 +00:00
Adrien de Peretti
678a06752a feat(medusa): Migrate services to use TransactionBaseService (#2276) 2022-09-29 15:58:17 +02:00
Adrien de Peretti
2be00007b2 Feat(medusa, medusa-js, medusa-react): order edit confirmation (#2264)
**what**

Support confirm of an order edit:

Upon confirmation, the items of the original order are detached and the items from the order edit are attached to the order.
The order total is recomputed with the correct total which can defer from the paid_total and refundable_amount (based on the paid_total)


**Tests**

- Unit tests medusa-js and medusa-react as well as the core
- Integration test of the confirmation flow which check that the order edit is properly confirmed and can be confirmed idempotently. Also validate the totals and that the order items correspond to the order edit items. Also validate the order totals.

FIXES CORE-498
2022-09-29 08:00:48 +00:00
Frane Polić
884f36e8a8 feat: add a line item to an order edit (#2243)
**What**
- Implement adding a line item to order (edit)

**How**
- _by implementing the following "flow"_
  - generate a line item
  - computing line item adjustments for that line item
  - creating tax lines
  - creating a change record

**Testing**
- **_integration tests_**
  - check if line item and order item change objects are created (with correct tax lines)
  - line item adjustments are generated if
    - fixed discount is applied to cart
    - percentage discount is applied
- **_unit tests_** 
  - ensure that methods from Inventory, LineItem, LineItemAdjustment etc. services are called 

---

RESOLVES CORE-495
2022-09-28 11:51:13 +00:00
Adrien de Peretti
474e97252c Feat(medusa, medusa-js, medusa-react): order edit item update (#2246)
**what**
Support `updateLineItem` which does the following:
- If no item change exist then create a new one and attaches the clone item with the adjustments and tax lines
- if an item change exists then delete/create adjustments and tax lines and update the cloned item quantity

**Tests**
- Unit tests core + client
- integration tests
  - When no item change already exists
  - When an item change already exists

FIXES CORE-497
2022-09-28 09:09:33 +00:00
Philip Korsholm
1807bff029 Feat(medusa): cancel order edit (#2240)
**What**
- cancel an order edit

Fixes CORE-500
2022-09-27 03:13:15 +00:00
Philip Korsholm
6da29c72c4 Feat(medusa): request order edit (#2239)
**What**
- Implement `admin/order-edits/:id/request`

Fixes CORE-499
2022-09-22 10:17:00 +00:00
Adrien de Peretti
14e808c724 feat(medusa, medusa-js, medusa-react): Implement item change deletion from an order edit (#2241) 2022-09-22 11:02:58 +02:00
Philip Korsholm
c661cc789b Feat/decline order edit (#2234)
**What**
- Decline an order edit from a store endpoint
- Refactor totals setting to a service method

Fixes CORE-502
2022-09-21 11:02:10 +00:00
Frane Polić
e1fe5ed094 feat(medusa): Update OrderEdit (#2220) 2022-09-19 13:29:12 +02:00
Adrien de Peretti
f7177c9033 feat(medusa): Implement premises of the creation flow of an order edit (#2187)
**What**
- Implements the admin create end point 
- Service implementation of the create method and the retrieveActive as well as the totals computation
- Improve compute line items
- client
  - medusa-js api
  - medusa-react mutations hooks

**Tests**
- Unit tests of the create end points
- Unit tests of the service create method
- Integration tests for admin that also take into account totals computations
- client
  - medusa-js tests
  - medusa-react hooks tests

FIXES CORE-491
2022-09-16 08:29:40 +00:00
Philip Korsholm
09627c01d3 feat(medusa): Support OrderEdit removal (#2204) 2022-09-16 08:39:40 +02:00
Adrien de Peretti
f863d28b9a feat(medusa): Implement premises of order edit retrieval (#2183)
**What**
- Implements the admin/store retrieval end point 
- Service implementation of the retrieve method
- Service implementation of the computeLineItems method which aggregates the right line item based on the changes that are made
- client
  - medusa-js api
  - medusa-react queries hooks

**Tests**
- Unit tests of the retrieval end points
- Unit tests of the service retrieve method and computeLineItems
- Integration tests for admin/store
- client
  - medusa-js tests
  - medusa-react hooks tests

FIXES CORE-492
2022-09-15 09:12:20 +00:00
Kasper Fabricius Kristensen
64949dc721 feat(medusa-js,medusa-react,medusa): Add missing Currency endpoints (#2185) 2022-09-12 19:28:43 +02:00
Richard Ward
2a723dcd4f feat(medusa-react): Add Collection batch (remove, add) endpoints (#1959) 2022-08-08 12:58:23 +02:00
Adrien de Peretti
b603f7dc8f chore(medusa): Add transaction on mutation actions (2) (#1855)
**What**
Wrap all actions that require the usage of an atomic phase into a transaction from the handler

**Info**
The following end points have been removed since that they rely on non existing stuff and can't be used and are not used
admin - create-order
admin - delete order metadata
admin - set region metadata
admin - remove region metadata

Fixes CORE-358
2022-08-02 10:23:01 +00:00
Adrien de Peretti
b54d5178c9 feat(medusa): Migrate and fix order service (#1894)
* feat(medusa): Migrate and fix order service

* fix(medusa): Order service pass Payment instead of the session:

* fix(medusa): Remove unnecessary method in the client library

* test(medusa): Fix unit tests

* test(medusa): Fix unit tests

* fix(medusa): Typo

* test(meduas): fix unit test

* feat(medusa): Update base service used and missing transaction

* test(meduas): fix unit test

* fix(medusa): cleanup and missing transaction

* fix(medusa): missing withTransaction on some mocks

* feat(medusa): Update order service method visibility

* include feedback

* feat(medusa); revert order payment status"

* test(medusa): fix unit

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2022-08-01 11:01:17 +02:00
Frane Polić
97c48a5ab9 feat: invalidate product list hooks (#1931)
**What**
- invalidate cache on prodcut list hooks when a product is added/removed to/from a sales channel
2022-07-28 14:01:35 +00:00
Adrien de Peretti
f35ea5156a feat(medusa, medusa-js, medusa-react): Bulk add Products to a SalesChannel (#1833) 2022-07-14 16:39:44 +02:00
Adrien de Peretti
cdd91974f9 feat(medusa, medusa-js, medusa-react): Start implementing remove batch products on a sales channel (#1842)
What
Support sales channel remove product batch in medusa, medusa-js and medusa-react

How
By implementing a new endpoint and the associated service method as well as the repository methods.

Medusa-js new removeProductd method in the resource

Medusa-react new hook in the mutations

Tests

Endpoint test
Service test
Integration test
Hook tests

Fixes CORE-292
2022-07-13 19:40:23 +00:00
Adrien de Peretti
a1a5848827 feat(medusa, medusa-js, medusa-react): Implement Sales Channel list (#1815)
**What**
Support sales channel list in medusa, medusa-js and medusa-react

**How**

By implementing a new endpoint and the associated service method as well as the repository methods.

Medusa-js new list method in the resource

Medusa-react new hook in the queries

**Tests**

Endpoint test
Service test
Integration test
Hook tests

Fixes CORE-280
2022-07-13 10:28:53 +00:00
Kasper Fabricius Kristensen
fb4cfc3c3c fix(medusa-react): Use correct type for hook useAdminCreateDraftOrder (#1832) 2022-07-11 16:14:10 +02:00
Adrien de Peretti
2d03634cfc feat(medusa, medusa-js, medusa-react): Implement Sales Channel deletion (#1804) 2022-07-07 10:47:51 +02:00
Frane Polić
0d1624cf6a feat(medusa, medusa-js, medusa-react): Implement Sales Channel creation (#1795) 2022-07-06 22:18:05 +02:00
Philip Korsholm
428a801293 feat(medusa-js, medusa-react): Update jsdoc with experimental annotation for sales channels (#1811)
**What**
- Add tag to indicate methods are part of an experimental feature under development

**Why**
- To notify developers because we cant support featureflags in the same way from the client side libraries.
2022-07-06 15:38:26 +00:00
Philip Korsholm
9d19cc0818 feat(medusa, medusa-js, medusa-react): Implement Sales Channel update (#1797) 2022-07-06 15:44:09 +02:00
Adrien de Peretti
263a661031 feat(medusa, medusa-js, medusa-react): Implement Sales Channel retrieval (#1793) 2022-07-06 12:17:26 +02:00
Adrien de Peretti
9e0f65dee3 fix(medusa-react): Allow to not invalidate any cache (#1756)
### What
At the moment, it is not possible to not invalidate any queries>
Example, when we want to Create a new signed url, it does not require to invalidate any of the queries.
But the way it is done in the buildOptions, require to give either a key or an array of keys. 

### How
The behaviour for empty array is to invalidate all the queries and here we would like to be able to just pass undefined in order to not trigger the invalidation. The update allow the arg to be optional and check for undefined explicitly before choosing the invalidation
2022-06-30 09:01:31 +00:00