Commit Graph

3142 Commits

Author SHA1 Message Date
Philip Korsholm
02c77d7059 Fix/adjust reservations correctly (#3474)
**What**
- Adjust reservations correctly according to the following heuristic: 

adjustment by addition:  (i.e. positive quantity adjustment passed to the adjustment method)
- if a reservation for the line-item in the location exists add quantity to that
- if not create a new reservation

adjustment by subtraction: 
- if a reservation with the exact quantity exists, delete it and return
- if a reservation with a greater quantity exists, subtract from it and return 
- otherwise delete from reservations until a reservation with greater quantity than the remaining is found and adjust that with the remaining quantity OR there are no more reservations

Fixes CORE-1247
2023-03-16 09:47:54 +00:00
Philip Korsholm
38c8d49f46 Feat(medusa): handle reservation quantity update for line items (#3484)
**What**
-  Raise exception if a reservation is updated or created to have larger quantity than is unfulfilled for a line-item

Fixes CORE-1249
2023-03-16 09:15:39 +00:00
Riqwan Thamir
061a600f80 fix(medusa): fix rank order changing on category update (#3486)
what:

- fixes issue where ranking changes when only properties other than rank are updated on categories

FIXES CORE-1253
2023-03-16 08:53:49 +00:00
Patrick
13f40d7217 feat(oas): declare x-expanded-relations - Admin (#3483)
* feat(oas): declare x-expanded-relations - Admin

* fixup! feat(oas): declare x-expanded-relations - Admin

* fixup! feat(oas): declare x-expanded-relations - Admin

* fixup! feat(oas): declare x-expanded-relations - Admin

* fixup! feat(oas): declare x-expanded-relations - Admin

* fixup! feat(oas): declare x-expanded-relations - Admin

* feat: move defaultAdminOrdersRelations and Fields to types directory

* chore(changeset): patch

* fix(test): update unit tests

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-16 09:33:09 +01:00
Patrick
522e306e2e feat(oas): declare x-expanded-relations - Store (#3482)
* feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* chore(changeset): patch

* fix(tests): update store auth integration test

* fix: pr feedback

* fix(test): match response code
2023-03-16 09:08:20 +01:00
olivermrbl
da0787bd11 chore: Update changeset for medusa-react 2023-03-15 18:51:16 +01:00
Riqwan Thamir
4ede91952d fix(medusa-react): invalidate products query on category delete (#3485) 2023-03-15 18:38:02 +01:00
Carlos R. L. Rodrigues
77d46220c2 Feat(modules-sdk,inventory,stock-location): modules isolated connection (#3329)
* feat: scoped container for modules
2023-03-15 12:09:45 -03:00
Rares Stefan
8e78c533c4 fix(admin-ui): Fix inventory table pagination on location filter change (#3479)
Inventory table offset should now correctly reset when a new location is selected from the filtering dropdown.

Resolves CORE-1231.
2023-03-15 12:20:30 +00:00
Philip Korsholm
3be6084dfd filter possible locations by inventory id (#3476)
**What**
- Ensure that an inventory level exists for a sales channel (which it will since this is invoked after `confirmInventory` that will validate that stock exists in the sales channel)

Fixes CORE-1225
2023-03-15 12:00:18 +00:00
Patrick
826d4bedfe feat(codegen,types): SetRelation on expanded types (#3477)
## What

On expanded relations, mutate type using SetRelation, an alias for SetRequired with SetNonNullable.

## Why

Simplifies implementation in client code.

## How

* Export SetRelation type util
* Update codegen template

Extra scope:

* Improve codegen error handling when processing x-expanded-relations
* Add `eager` sub-categorization to x-expanded-relations to highlight relations that are loaded using TypeORM eager.
2023-03-15 11:29:21 +00:00
Patrick
6748877c69 fix(oas,js,react): use AdminExtendedStoresRes instead of AdminStoresRes (#3478)
## What

Declare and use AdminExtendedStoresRes for `[get] /admin/store` endpoint.

## Why

Only `[get] /admin/store` returns `ExtendedStoreDTO`. Other `/admin/store` endpoints return `Store`.

## How

* Create new AdminExtendedStoresRes OAS schema
* Update medusa-js
* Update medusa-react
2023-03-15 11:17:34 +00:00
Philip Korsholm
10bf05c147 Fix(inventory, stock-location): Remove orphaned location levels and reservations (#3460)
**What**
- Remove related inventory levels and reservation items when a stock location is removed

**How**
- Add bulk deletion methods for both inventory levels and reservation items to the inventory service api
- invoke both on location removal

Fixes CORE-1232
2023-03-15 09:12:46 +00:00
Philip Korsholm
fe9eea4c18 feat(medusa, admin-ui, medusa-react, medusa-js): Allow toggling of manage inventory (#3435)
**What**
- Toggle manage inventory in the inventory management modal

**How**
- Create/update/remove inventory item based on if `manage_inventory` is set and if an inventory item already exists
- Move all stock location updates to when the modal is submitted
- Add create-inventory-item endpoint in the core

Fixes CORE-1196

Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
2023-03-14 16:14:31 +00:00
Philip Korsholm
30a3203640 Fix(medusa): Missing location id on fulfillments (#3462)
**What**
- include location id when creating a fulfillment
- Allow location updates to reservations without passing along quantity

**Why**
- location_id on fulfillment was null after creation

Fixes CORE-1242, CORE-1243
2023-03-14 11:08:52 +00:00
olivermrbl
24604f1b71 chore: Merge conflicts with master 2023-03-14 11:43:31 +01:00
Riqwan Thamir
d278ac25c8 fix(admin-ui): hide categories in products behind feature flag (#3467) 2023-03-14 11:20:39 +01:00
Rares Stefan
478903b55a fix(admin-ui): Inventory and order UI fixes and tweaks (#3461)
This PR aims to tackle a few different small fixes and tweaks related to inventory and order details UI, in connection to multiwarehousing features.

- Successfully deleting an allocation should now only present one toast
- Updated copy in allocation editing toasts
- Inventory table search should now be the same height as the location selection trigger
- Inventory table rows should now correctly visually indicate that they are clickable
- Removed Filters from Inventory table for the time being
- Added actions to Inventory table rows for adjusting availability (same action as clicking the row, which remains) and going to the product detail page for the inventory item

Resolves CORE-1229, CORE-1228, CORE-1227, CORE-1233, CORE-1230
2023-03-14 09:53:13 +00:00
Philip Korsholm
55a1f232a3 Feat(admin-ui, medusa): request return with location (#3451)
* add location_id to request_return endpoint to support "receive_now" returns

* changeset

* admin request return

* add locations to recieving returns

* cleanup test

* add check for inventory service
2023-03-14 10:35:59 +01:00
olivermrbl
271844aedb chore: Add missing changeset for @medusajs/modules-sdk 2023-03-14 10:03:37 +01:00
github-actions[bot]
9ceddf45a9 chore(docs): Generated Services Reference (automated) (#3465)
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-13 18:29:42 +00:00
github-actions[bot]
a5582b93b8 chore(docs): Generated Docs Announcement Bar (automated) (#3466)
Co-authored-by: olivermrbl <olivermrbl@users.noreply.github.com>
2023-03-13 19:22:06 +01:00
olivermrbl
77fd361ce8 chore(release): v1.7.13 2023-03-13 19:09:08 +01:00
Oliver Windall Juhl
88392e0176 chore(create-medusa-app): Remove Admin + Gatsby starter from npx (#3376) 2023-03-13 18:59:52 +01:00
Riqwan Thamir
2f42ed35d6 feat(medusa, admin-ui): increase tree depth + scope categories on store + allow categories relation in products API (#3450)
What:
- increase tree depth in react nestable
- scope categories on store queries
- allow categories relation in products API

RESOLVES CORE-1238
RESOLVES CORE-1237
RESOLVES CORE-1236
2023-03-13 17:30:21 +00:00
olivermrbl
85640475e5 chore: Remove from ignores in test pipeline 2023-03-13 15:44:03 +01:00
Adrien de Peretti
f0a1355feb feat(medusa): Bulk emit events (#3407) 2023-03-13 15:28:51 +01:00
Patrick
7b57695e00 feat(codegen): x-expanded-relations (#3442)
## What

Alter generated types base on `x-expanded-relations` OAS extension declared on schemaObjects.

## Why

Often, API endpoints will automatically expand a model relations by default. They can also decorate a model with calculated totals. In order to more accurately represent the API, we wish to alter the generated types based on the expanded relations information.

## How

- Follow the relation declaration signature as the backend controllers and the `expand` query param, i.e.: `items.variant.product`.
- Introduce a custom `x-expended-relations` OAS extension.
- Allow for organizing declared relations to help their maintenance.
- Use traversal algorithms in codegen to support deeply nested relationships.
- Use [type-fest](https://www.npmjs.com/package/type-fest)'s `Merge` and `SetRequired` to efficiently alter the types while enabling great intellisense for IDEs.

Extra scope: 
* Added convenience yarn script to interact with the `medisa-oas` CLI within the monorepo. 

## Test

Include in the PR are two implementations of the x-expanded-relations on OAS schema, a simple and a complex one.

### Step 1
* Run `yarn install`
* Run `yarn build`
* Run `yarn medusa-oas oas --type combined --out-dir ~/tmp/oas`
* Run `yarn medusa-oas client --type combined --component types --src-file ~/tmp/oas/combined.osa.json --out-dir ~/tmp/types`
* Open `~/tmp/types/models/StoreRegionsRes`
* Expect relations to be declared as required

### Step 2
* Open `~/tmp/types/models/StoreCartsRes`
* Expect relations to be declared as required
* Expect nested relations to have relations as required.

### Step 3 (optional)
* Open `~/tmp/types` in an intellisense capable IDE
* Within the `index.ts` file, attempt to declare a `const storeRegionRes: StoreRegionRes = {}`
* Expect IDE to highlight that `countries` is a required field of `StoreRegionRes`
2023-03-13 14:21:56 +00:00
Philip Korsholm
c16f387d1c fix(admin-ui): Edit allocation update (#3447)
**What**
- update the edit-allocation side-bar with the new table layout

Fixes CORE-1215
2023-03-13 14:08:05 +00:00
Kasper Fabricius Kristensen
ad7d7fcd51 fix(admin-ui): Lint all UI files (#3459) 2023-03-13 14:02:20 +01:00
Patrick
55febef7f1 feat(types): package scaffolding for generated types (#3452)
## What

Generated client types package based on the API's OpenApi Spec.

## Why

This package aims at replacing the need to import types directly from the core `@medusajs/medusa` package which can lead to side effects like importing backend dependencies into the client's realm.

## How

* The package contains a script that is invoked during the build step. 
* The script will use the `medusa-oas oas --type=combined` cli to generate a combined oas file. 
* Then, `medusa-oas client --component=types` uses the oas file to generate the types based on the OAS schema definitions. The result is outputted into `/src/lib`
* `prettier` is run on the `/src/lib` directory to ensure that the generated code follows the monorepo coding style.
* Finally, with `"emitDeclarationOnly": true`,  `tsc` compiles the src directory to only output types.

Until we update our CI pipeline, we will not commit the content `/src/lib`.

## Test

* Run `yarn install`
* Run `yarn build`
* Expect `packages/generated/client-types/dist/` to contain types generated from the OAS defined by `@medusajs/medusa`
2023-03-13 12:23:26 +00:00
olivermrbl
6d928628a9 chore: Fix merge conflicts with master 2023-03-12 12:53:07 +01:00
Patrick
b7a48e51df fix(oas): fix OAS typos in AdminVariant (#3453) 2023-03-12 09:43:06 +01:00
Rares Stefan
d4af873113 fix(admin-ui): Show all locations in allocation creation modal (#3448)
* Remove SC constraint from allocation location options

* Create tricky-peas-clean.md

* Update company field placeholder in address form
2023-03-10 15:43:18 +01:00
Frane Polić
f97b3d7cce feat(medusa): Cache modules (#3187) 2023-03-10 15:09:26 +01:00
Rares Stefan
f43f03badb fix(admin): Fix fulfilment creation (#3434)
* Remove error object nesting that stopped fulfilment creation

* Create stale-adults-tease.md

* Fix quantities object creation check

* Add some debug logs
2023-03-10 14:41:03 +01:00
Carlos R. L. Rodrigues
54dcc1871c feat(medusa,medusa-core-utils): graceful shutdown server (#3408)
* feat: graceful shutdown
2023-03-10 09:11:45 -03:00
Riqwan Thamir
9ba09ba4d7 feat(medusa, medusa-js, medusa-react): Add store queries to react medusa (#3436)
What:

- Adds queries to medusa react for core
- Fix naming issues in types

RESOLVES CORE-1131
2023-03-10 10:14:48 +00:00
Patrick
966aea65c2 feat(oas-cli): combine admin + store + custom OAS (#3411) 2023-03-10 10:37:59 +01:00
Philip Korsholm
ef4a36794e Fix(admin-ui): border overflow (#3437)
**What**
- Fix border clipping out of component

Fixes CORE-1190
2023-03-09 17:28:00 +00:00
Rares Stefan
f027bc26fc fix(admin): Show correct reserved/available values when editing stock on variant (#3438)
Update displayed labels to use actual `reserved_quantity` and a calculation for available quantity, now that we have the correct fields on the level. 

![2023-03-09 17 04 16](https://user-images.githubusercontent.com/948623/224101557-1d0c28d9-4775-4ad4-a6ef-ebc7427c4119.gif)

Resolves CORE-1194
2023-03-09 17:17:37 +00:00
Philip Korsholm
80b95a2300 Fix(medusa, admin-ui): Order allocations (#3419)
**What**
- Fix `delete-reservation` endpoint to allow deletions of reservations 
- remove `inventory_item_id` from reservation update call to properly update reservation
- invalidate all list caches to properly update order overview after an allocation has been created
- Fix overlap for long product titles in edit-allocation-modal

Fixes CORE-1214
2023-03-09 17:07:49 +00:00
Riqwan Thamir
cdbc5ff3d8 feat(admin-ui): added breadcrumbs for categories on create/edit modal (#3420)
What:
- Adds breadcrumbs to create modal
- Adds breadcrumbs to edit modal

<img width="581" alt="2" src="https://user-images.githubusercontent.com/5105988/223782603-f168d554-65bd-4cfc-bdcd-eabdd9f06b20.png">
<img width="1115" alt="1" src="https://user-images.githubusercontent.com/5105988/223782607-1ae441c9-c9eb-4cb0-9015-2038db55dd64.png">


RESOLVES CORE-1210
2023-03-09 15:43:43 +00:00
Adrien de Peretti
601d20e7ab chores(medusa): Improve draft order creation perf flow (#3431) 2023-03-09 16:17:41 +01:00
Patrick
4042beb102 feat(oas): add @schema OAS for address request payloads (#3423)
## What

Replace AddressFields with actual AddressPayload schema based off the actual type used by the controllers.

## Why

AddressPayload is currently being referenced in client code. Our OAS schema should attempt to match current client usage in order to reduce friction when migrating to a OAS generated types package.

## How

* Represent AddressPayload and AddressCreatePayload in our OAS schemas.
* Replace reference to AddressFields
* Plus, fix typo in /admin/orders/ route
2023-03-09 14:31:40 +00:00
Philip Korsholm
784723a039 Fix/disable allocate button (#3426)
* remove allocate option from order editing summary if no further allocations can be made

* add changeset

* add minor button styles to badge component
2023-03-09 13:05:56 +01:00
Oliver Windall Juhl
ea28eea251 docs: Added upgrade guide for v1.7.12 (#3425)
* docs: Added upgrade guide for v1.7.12

* Update 1-7-12.md

* Update 1-7-12.md

---------

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
2023-03-09 12:20:19 +01:00
olivermrbl
e5f0a60090 chore: Update yarn.lock 2023-03-09 10:37:27 +01:00
olivermrbl
2fe056f4cf chore(release): v1.7.12 2023-03-09 08:58:49 +01:00
Riqwan Thamir
478d1af8d0 feat(medusa, admin-ui): Improvements to product categories (#3416) 2023-03-08 16:56:49 +01:00