Commit Graph

3115 Commits

Author SHA1 Message Date
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
Oliver Windall Juhl
8ed67d2d7d fix(admin,oas-github-cli): Make staging release pipeline pass (#3410)
* fix(admin,oas-github-cli): Make staging release pipeline pass

* Create .changeset/clean-cobras-listen.md

---------

Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com>
2023-03-08 16:41:03 +01:00
Rares Stefan
57d7728dd9 feat(admin-ui, medusa-js, medusa-react, medusa): Multiwarehousing UI (#3403)
* add "get-variant" endpoint

* import from a different place

* fix unit test

* add changeset

* inventory management for orders

* add changeset

* initial create-fulfillment

* add changeset

* type oas and admin

* Move inv. creation and listing from admin repo

* Fix location editing bug (CORE-1216)

* Fix default warehouse on inventory table view

* remove actions from each table line

* Use feature flag hook instead of context directly

* remove manage inventory action if inventory management is not enabled

* Address review comments

* fix queries made when inventorymodules are disabled

* variant form changes for feature enabled

* move exclamation icon into warning icon

* ensure queries are not run unless feature is enabled for create-fulfillment

---------

Co-authored-by: Philip Korsholm <philip.korsholm@hotmail.com>
Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
2023-03-08 16:08:56 +01:00
Philip Korsholm
9f508c8bd8 fix(medusa): Create migration to ensure correct variant inventory column (#3384)
* add migration to ensure quantity is called required quantity

* add changeset
2023-03-08 15:27:43 +01:00
Adrien de Peretti
53eda215e0 fix(medusa): Issue when ordering with multiple columns (#3385)
**What**
No true fix due to the same issue as [here](https://github.com/typeorm/typeorm/issues/6294) but at least the pagination works again. The ordering can't be applied on multiple columns/relation as it produce the wrong SQL.

FIXES CORE-1193
2023-03-08 12:37:18 +00:00
Oliver Windall Juhl
ce577f2696 feat(medusa): Add global job options for events (#3394) 2023-03-08 11:09:43 +01:00
github-actions[bot]
c7eee77bd9 chore(docs): Removed Docs Announcement Bar (automated) (#3412)
Co-authored-by: shahednasser <shahednasser@users.noreply.github.com>
2023-03-08 10:01:40 +02:00
Adrien de Peretti
84e4489683 chore(medusa): Little improvement in draft order creation (#3374)
**What**
Only call line item service create once, instead of twice.
2023-03-07 19:10:53 +00:00
Kasper Fabricius Kristensen
d0d11307d2 fix(admin-ui): Fix use of expand parameter on order page (#3383)
* Create cuddly-seahorses-thank.md

* add integration tests

* revert back from master to develop

* fix expand

* add new integration test

* add missing default relations

* add missing refunds relation

* re work

* fix tests

* init

* fix order page according to fixes to expand

* expand shipping on returns

* Create .changeset/cuddly-beers-tease.md

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-07 19:43:44 +01:00
Riqwan Thamir
47d3440766 feat(admin-ui, medusa-react): product page categories management + nested multiselect (#3401)
* chore: allow products to be categorized in product create/edit page

* refactor: cleanup

* feat: invalidate product details cache when categories change

* fix: update changesets

* fix: push ner changeset

* feat: limit popup height

---------

Co-authored-by: fPolic <frane@medusajs.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-07 19:42:01 +01:00
Patrick
2d2727f753 fix(eslint): remove unused .eslintignore in medusa-react package (#3406)
## What

remove unused .eslintignore in medusa-react package

## Why

Some IDEs, like JetBrains, will establish the eslint working directory by finding the nearest .eslintrc or .eslintignore file. The  .eslintignore in `/packages/medusa-react` adds complexity to configuring and resolving eslint for that package.

## How

.eslintignore is already declared at the root of the monorepo and /packages/medusa-react is already ignored as a whole. We can safely remove the `.eslintignore` from `/packages/medusa-react`
2023-03-07 16:10:56 +00:00
Riqwan Thamir
1d09a266be feat(medusa): category list API can return all descendant (#3392)
* chore: category list API can return all descendant

* chore: category handle is no longer required via api

* chore: added treescope to sorting

* chore: address feedback on PR
2023-03-07 15:54:49 +01:00
Kasper Fabricius Kristensen
cf51ad0d46 fix(admin-ui): move dependencies from devDependencies (#3405) 2023-03-07 14:43:08 +01:00
Riqwan Thamir
b5662d0c6a feat(admin-ui): adds category ui for tree/list, edit, create, delete (#3399)
* chore: adds category ui for tree/list, edit, create, delete

* fix: address feedback

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: fPolic <frane@medusajs.com>
2023-03-07 13:29:22 +01:00
Philip Korsholm
06f567f446 fix(admin-ui): table action gap (#3386)
* add gap in table actions

* add changeset

* Update .changeset/light-frogs-smoke.md

Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com>

---------

Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-07 13:14:14 +01:00
Kasper Fabricius Kristensen
b4eba69911 fix(admin-ui): Resolve tailwindcss/nesting correctly (#3404)
* attempt resolving tailwind nesting

* fix import of tailwindcss/nesting plugin

* trigger pipeline

* trigger pipeline

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-07 13:12:13 +01:00
Adrien de Peretti
33c6ccf059 fix(medeusa): Transform query includes options should only be added to allowed props if there is already at least one allowed props (#3362)
**What**
when `fields` only contain includes options, it should return the entire object plus the include options. If the fields contains the included options + other fields, it should only return the requested fields + the included options
2023-03-07 11:52:14 +00:00
Philip Korsholm
15f47baf56 Fix(admin-ui, medusa): stock location fixes (#3395)
**What**
- A series of minor fixes for admin-ui relating to managing stock locations: 
  - make "create location" `primary`
  - add delete prompt when cancelling creation if information has been input
  - avoid clipping focus border on country select when creating a stock location
  - allow removals of sales channels from stock locations 

Fixes CORE-1191, CORE-1192, CORE-1190, CORE-1189
2023-03-07 10:54:09 +00:00
Oliver Windall Juhl
aadc1e19e9 chore: Ignore admin-ui in core pipeline (#3381) 2023-03-07 11:27:55 +01:00
Patrick
240d0ea7b8 fix(ci,oas) move oas ci script to a package under the oas workspace (#3391)
* feat(ci,oas) run oas ci on all PRs

* fix(ci,oas) move oas ci script to a package under the oas workspace

* chore(changeset): patch
2023-03-07 10:33:12 +01:00
Riqwan Thamir
bca731a148 chore: Product page shows list of categories associated with it (#3400) 2023-03-07 10:04:25 +01:00
Oliver Windall Juhl
aa0d1f3215 fix(medusa): Remove default job age option from EventBus (#3388)
* fix(medusa): Remove default job age option from EventBus

* Create .changeset/spicy-camels-invite.md
2023-03-06 19:41:12 +01:00
Shahed Nasser
6496c20800 docs: improved generation details in migrations guide (#3396) 2023-03-06 19:58:52 +02:00
Oliver Windall Juhl
ed0f777431 fix(admin-ui): Discount in DraftOrder create flow (#3378)
Solves #3332
2023-03-06 16:06:28 +00:00
Riqwan Thamir
0a6aa0e624 feat(medusa): categories can be ranked based on position (#3341)
* chore: categories can be ranked based on position

* chore: fix tests

* chore: sort categories by order

* chore: fix bug where mpath relationship is messed up

* chore: enable linting - lint changes

* Update packages/medusa/src/repositories/product-category.ts

Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>

* chore: fixed specs

* chore: cleanup repository to new typeorm interfaces + cleanup

* chore: revert repository changes due to incorrect sql

* chore: addressed pr reviews

---------

Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
2023-03-06 15:49:16 +01:00
Shahed Nasser
ba5d34efba docs: migrate netlify redirects to vercel redirects (#3387)
* docs: added redirects for vercel

* fixed vercel error
2023-03-06 14:39:38 +02:00
Johannes Riedmüller
0d7725d3d3 docs: fix env variable name in sendgrid (#3382)
I think this reference is wrong.
2023-03-06 10:40:20 +02:00
Kasper Fabricius Kristensen
67ba8be02b fix(admin): Add skus to claim menus (#3368)
**What**
- Adds SKU to all tables in claim flow, allowing admins to easily copy them to their clipboard.
2023-03-05 17:17:45 +00:00