feat(medusa-js, medusa-react, medusa): Prepare API for admin implementations (#3110)

********What********
Add `joinSalesChannels util to stock locations

Add the following endpoints to medusa-react
- inventory items
    - mutations
        - update
        - delete
        - update location level
        - delete location level
        - create location level
    - queries
        - list inventory items
        - get inventory item
        - list location levels
- Stock locations
    - mutations
        - create stock location
        - update stock location
        - delete stock location
    - queries
        - list stock locations
        - get stock locatoin
- Variants
    - queries
        - get inventory
- Reservations
    - mutations
        - create reservation
        - update reservation
        - delete reservation
    - queries
        - list reservations
        - get reservation
- sales channels 
  - mutations
    - associate location with sc
    - remove location association

**Why**
- Update clients to reflect new api endpoints in the core with inventory modules

Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
This commit is contained in:
Rares Stefan
2023-02-16 08:49:48 +00:00
committed by GitHub
parent 121b42acfe
commit 12d304307a
48 changed files with 1756 additions and 57 deletions
@@ -68,7 +68,7 @@ describe("Sales channels", () => {
)
expect(
await salesChannelLocationService.listLocations(sc.id)
await salesChannelLocationService.listLocationIds(sc.id)
).toHaveLength(2)
await api.delete(`/admin/sales-channels/${sc.id}`, {
@@ -78,7 +78,7 @@ describe("Sales channels", () => {
await expect(salesChannelService.retrieve(sc.id)).rejects.toThrowError()
await expect(
salesChannelLocationService.listLocations(sc.id)
salesChannelLocationService.listLocationIds(sc.id)
).rejects.toThrowError()
})
})
@@ -70,11 +70,11 @@ describe("Sales channels", () => {
)
expect(
await salesChannelLocationService.listLocations(saleChannel.id)
await salesChannelLocationService.listLocationIds(saleChannel.id)
).toHaveLength(1)
expect(
await salesChannelLocationService.listLocations(otherChannel.id)
await salesChannelLocationService.listLocationIds(otherChannel.id)
).toHaveLength(1)
await api.delete(`/admin/stock-locations/${loc.id}`, {
@@ -82,11 +82,11 @@ describe("Sales channels", () => {
})
expect(
await salesChannelLocationService.listLocations(saleChannel.id)
await salesChannelLocationService.listLocationIds(saleChannel.id)
).toHaveLength(0)
expect(
await salesChannelLocationService.listLocations(otherChannel.id)
await salesChannelLocationService.listLocationIds(otherChannel.id)
).toHaveLength(0)
})
})
@@ -60,7 +60,7 @@ describe("Sales channels", () => {
await salesChannelLocationService.associateLocation(sc.id, loc2.id)
expect(
await salesChannelLocationService.listLocations(sc.id)
await salesChannelLocationService.listLocationIds(sc.id)
).toHaveLength(2)
const [channels] = await salesChannelService.listAndCount(