Commit Graph

2977 Commits

Author SHA1 Message Date
Patrick
a59bd84e41 feat(oas) - accurate model OAS representation - PA to PU (#3223)
### Scope

Models PA to PU

### What

Refactor OAS for models to accurately represent their shape in API responses.

### Why

About 33% of model fields are not accurately represented in the OAS. Most of the issues are:
- fields that can not be omitted in the response are not declared as `required`
- fields that could return `null` as their value are not declared as `nullable: true`

When using a code generator, these OAS issues would lead to inaccurate response shapes in the generated client.

### How

#### nullable
Fields meeting at least one of the following condition will be represented as `nullable: true` in OAS:
* The field is decorated with `@Column({ nullable: true })`
* The field is decorated with `@OneToOne`, `@ManyToOne`
* The field is decorated with `@DeleteDateColumn`

#### optional
Fields meeting at least one of the following conditions will never be listed as `required` in OAS and will be considered optional and could be omitted in the response:
* The field is decorated with `@OneToOne`, `@ManyToOne`, `@OneToMany`, `@ManyToMany`
* The field is decorated with `@FeatureFlagColumn`
* The field is decorated with `@Column({select: false})`
* The field is representing dynamic values not persisted in the database

Fields not meeting any of the conditions above will be declared as `required` and are expected to be present in the response.

### Test
* Ran OAS validator.
* Ran docs build script.

Expect OAS changes to be reflected in the API documentation.
2023-02-10 15:35:24 +00:00
olivermrbl
4e4da52e8c Merge branch 'master' into develop 2023-02-10 09:27:19 +01:00
Oliver Windall Juhl
472f96d7fb fix(medusa): Missing refund amount when creating claim (#3224) 2023-02-10 09:26:54 +01:00
github-actions[bot]
91234c14b5 chore(docs): Generated Services Reference (automated) (#3227)
Co-authored-by: olivermrbl <olivermrbl@users.noreply.github.com>
2023-02-09 19:55:08 +02:00
Adrien de Peretti
eee9283818 feat(medusa): Allow empty fields/expand (#3220) 2023-02-09 18:05:56 +01:00
olivermrbl
d3feb62b85 Merge branch 'master' into develop 2023-02-09 17:52:41 +01:00
Frane Polić
61b0b2f3aa fix(medusa): Pass query transformer config in storefront controllers (#3219) 2023-02-09 17:52:04 +01:00
Adrien de Peretti
8c5219a31e chore: Update ignored files for npm (#3217) 2023-02-09 17:25:14 +01:00
Adrien de Peretti
6e443dc708 feat(medusa): Improve addShippingMethod on store cart route (#3222) 2023-02-09 16:55:40 +01:00
Patrick
507ad00bec feat(oas) - accurate model OAS representation - F to O (#3210)
### Scope

Models F to O

### What

Refactor OAS for models to accurately represent their shape in API responses.

### Why

About 33% of model fields are not accurately represented in the OAS. Most of the issues are:
- fields that can not be omitted in the response are not declared as `required`
- fields that could return `null` as their value are not declared as `nullable: true`

When using a code generator, these OAS issues would lead to inaccurate response shapes in the generated client.

### How

#### nullable
Fields meeting at least one of the following condition will be represented as `nullable: true` in OAS:
* The field is decorated with `@Column({ nullable: true })`
* The field is decorated with `@OneToOne`, `@ManyToOne`
* The field is decorated with `@DeleteDateColumn`

#### optional
Fields meeting at least one of the following conditions will never be listed as `required` in OAS and will be considered optional and could be omitted in the response:
* The field is decorated with `@OneToOne`, `@ManyToOne`, `@OneToMany`, `@ManyToMany`
* The field is decorated with `@FeatureFlagColumn`
* The field is decorated with `@Column({select: false})`
* The field is representing dynamic values not persisted in the database

Fields not meeting any of the conditions above will be declared as `required` and are expected to be present in the response.

### Test
* Ran OAS validator.
* Ran docs build script.

Expect OAS changes to be reflected in the API documentation.
2023-02-09 15:03:11 +00:00
github-actions[bot]
14b2de94e2 chore(docs): Generated API Reference (#3211)
Co-authored-by: olivermrbl <olivermrbl@users.noreply.github.com>
2023-02-09 09:50:55 +02:00
Carlos R. L. Rodrigues
d859ccf551 Feat(medusa) - delete cascade modules associations (#3190)
* delete cascade sales channel x locations, variant x inventory item
2023-02-08 17:23:47 -03:00
github-actions[bot]
9997485c55 chore(docs): Generated Docs Announcement Bar (automated) (#3212) 2023-02-08 20:04:13 +01:00
Shahed Nasser
cf946b26fa docs: added upgrade guide for v1.7.6 (#3207) 2023-02-08 19:51:47 +01:00
olivermrbl
3b474ec35c chore(release): Publish 2023-02-08 19:35:44 +01:00
Adrien de Peretti
bfa33f444c fix(medusa): Applying Discounts (with Conditions) on DraftOrders and Carts (#3197) 2023-02-08 19:01:23 +01:00
Patrick
4d3210bfbb feat(oas) - accurate model OAS representation - A to D (#3203)
### Scope

Models A to D

### What

Refactor OAS for models to accurately represent their shape in API responses.

### Why

About 33% of model fields are not accurately represented in the OAS. Most of the issues are:
- fields that can not be omitted in the response are not declared as `required`
- fields that could return `null` as their value are not declared as `nullable: true`

When using a code generator, these OAS issues would lead to inaccurate response shapes in the generated client.

### How

#### nullable
Fields meeting at least one of the following condition will be represented as `nullable: true` in OAS:
* The field is decorated with `@Column({ nullable: true })`
* The field is decorated with `@OneToOne`, `@ManyToOne`
* The field is decorated with `@DeleteDateColumn`

#### optional
Fields meeting at least one of the following conditions will never be listed as `required` in OAS and will be considered optional and could be omitted in the response:
* The field is decorated with `@OneToOne`, `@ManyToOne`, `@OneToMany`, `@ManyToMany`
* The field is decorated with `@FeatureFlagColumn`
* The field is decorated with `@Column({select: false})`
* The field is representing dynamic values not persisted in the database

Fields not meeting any of the conditions above will be declared as `required` and are expected to be present in the response.

### Test
* Ran OAS validator.
* Ran docs build script.

Expect OAS changes to be reflected in the API documentation.
2023-02-08 17:00:37 +00:00
Andrew Sprouse
f5dced6ad9 feat(oas): Improve OAS by adding missing type object to schemas (#3177)
This PR improves the OAS by adding `type: object` to schemas that have `properties` and no `type`. While this attribute is not required for a valid spec, omitting it opens the possibilities of non-object input. See https://stackoverflow.com/a/47390723 for a detailed description of this behavior. When generating code or schemas from an OAS with tools like takeshape.io having `type` attributes is important to get the correct behavior.
2023-02-08 16:31:39 +00:00
Patrick
53532df8d5 feat(OAS): sanitize circular reference for Redocly (#3198)
### What

Add OAS build step to patch known circular references that prevent Redocly from rendering the API documentation.

### Why

We've encountered crashing and loading issues with Redocly when the OAS contained circular references. We have been working around the limitation by omitting some known problematic $ref in our source OAS. We wish to move away from this strategy in order to always explicitly include $ref in our OAS.

### How

We are introducing a custom Redocly CLI plugin that will replace `$ref` by `type: object` base on a configurable set of instructions. These instructions can be modified in `docs-util/redocly/config.yaml`

We are adding a `redocly bundle` step in the current OAS build process in order to sanitize problematic circular references.

We updated the redocly-cli package version in order to ensure that plugins are supported.

### Test

We will use [Cart.payment](fd5c185159/packages/medusa/src/models/cart.ts (L72-L74)) to ensure that the new process is properly sanitizing.

* Run `yarn openapi:generate`
* Open `docs/api/store/components/schemas/Cart.yaml`
  * Expect the `payment` property to have been sanitized to `type: object`
* Run `yarn redocly preview-docs docs/api/store/openapi.yaml --config=docs-util/redocly/config.yaml`
* Visit http://127.0.0.1:8080/#tag/Cart/operation/GetCartsCart
  * In the response, expect cart.payment to not list the properties of the Payment schema.
2023-02-08 13:01:03 +00:00
Kasper Fabricius Kristensen
b9bda3bf4e fix(medusa): Allow method.data to be passed when creating/updating ShippingMethods in ClaimService (#3205)
**What**
- Allows passing data on shipping methods during claim creation and updates. Defaults to an empty object.

**Testing** 
- Updates a test so it also passes along shipping method data.
2023-02-08 12:37:35 +00:00
Kasper Fabricius Kristensen
86c87c7b10 fix(medusa): Deleting product prices (#3152) 2023-02-08 13:13:34 +01:00
Oliver Windall Juhl
08324355a4 chore: Patch bump all dependencies + minor bumps winston (#3185) 2023-02-07 19:15:29 +01:00
Adrien de Peretti
ce866475b4 chore(*-payment-*): Cleanup PaymentProvider plugins (#3011) 2023-02-07 12:43:24 +01:00
olivermrbl
0a2bf7845d Merge branch 'master' into develop 2023-02-06 20:01:54 +01:00
Pevey
78650ea665 feat(medusa): Include name in session options (#3186) 2023-02-06 19:26:02 +01:00
Frane Polić
5b63533c77 feat(medusa): Preserve custom adjustments when refreshing adjustments (#3085) 2023-02-06 19:22:05 +01:00
Kasper Fabricius Kristensen
d0adaf57ed fix(medusa): Shipping profile CRUD (#3154)
**What**
- Fixes wrong payload class for `POST /admin/shipping-profiles`
- Fixes wrong payload class for `POST /admin/shipping-profiles/:id`
- Fixes an issue where updating a shipping profile with products and/or shipping options would fail.
- Fixes an issue where passing `profile_id` to `ShippingOptionService.update()` would not update the shipping profile of the option.

**Testing** 
- Adds new `simpleshippingProfileFactory`
- Adds new integration test suite for shipping profiles operations.

Resolves CORE-1065
2023-02-06 16:57:12 +00:00
Frane Polić
4d6e63d68f feat(medusa): Decorate OrderEdit LineItems with totals (#3108) 2023-02-06 17:32:26 +01:00
Frane Polić
e22a383f47 fix(medusa): fields params usage in the storefront endpoints (#2980) 2023-02-06 16:18:23 +01:00
Pevey
4339d47e1f feat(medusa): Include rolling in session options config (#3184) 2023-02-06 14:51:59 +01:00
Adrien de Peretti
82da3605fb feat(medusa-payment-stripe): Avoid unnecessary customer update if the stripe id already exists (#3046) 2023-02-06 14:25:02 +01:00
Oliver Windall Juhl
5c1d2a5e83 feat(medusa): Option to override existing cron job (#2989) 2023-02-06 14:24:32 +01:00
Adrien de Peretti
dc156861d4 fix(medusa): ShippingOption type on listAndCount (#2040)
**What**
Fix typing issue

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-02-06 13:00:32 +00:00
Carlos R. L. Rodrigues
923ccece24 feat(medusa,stock-location,inventory): Integration tests (#3149) 2023-02-06 09:02:43 -03:00
Oliver Windall Juhl
71fdd28198 fix(medusa-payment-stripe): Prevent Stripe events from retrying (#3160) 2023-02-06 11:23:39 +01:00
Riqwan Thamir
28697e1bd0 chore(medusa): refactor service test for product categories (#3161)
Refactor:

- Moves the mocks to a separate file under
- Re-uses existing mocks
- Use actual IDs instead of id string in mocks

RESOLVES CORE-977
2023-02-06 09:55:25 +00:00
Shahed Nasser
6729f9b5a8 docs: updated docusaurus to the latest version 2.3.1 (#3181) 2023-02-06 11:46:21 +02:00
Daniel Barion
a3acf24f01 docs: add and use react-tooltip (#3176)
* chore: add react-tooltip package into docs

* chore: add react-tooltip styles globally into Layout

* chore: use react-tooltip component into docs

* fixes to the CSS

---------

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
2023-02-06 11:33:11 +02:00
Oliver Windall Juhl
9ebb50104c feat(medusa): Expose session options (#3162) 2023-02-03 13:36:59 +01:00
Carlos R. L. Rodrigues
d50db84a33 Feat: TO variant creation (#3097) 2023-02-02 09:01:10 -03:00
Riqwan Thamir
a049987215 chore: recommended meaningful oas fixes (#3159) 2023-02-02 10:45:57 +01:00
Riqwan Thamir
be0d36432a feat(medusa-js): added resources for product categories (#3157)
What:

JS client resources for product categories

Why:

To manage product categories and managing product-category relationship

How:

- adds a JS client resource for product categories.

RESOLVES CORE-1066
RESOLVES CORE-969
RESOLVES CORE-1061
2023-02-01 17:52:39 +00:00
Riqwan Thamir
4105405f28 feat(medusa): Filter products by category params in store/admin (#3155)
What:

Products can be filtered through the API by category parameters

Why:

To filter products by category

How:

- adds 2 params in admin/store route
- updates repository to accept 2 new parameters

RESOLVES CORE-1032
RESOLVES CORE-1033
2023-02-01 17:25:07 +00:00
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
Oliver Windall Juhl
b242e22326 fix(medusa): Upsert addresses on Orders (#3153) 2023-02-01 13:57:24 +01:00
Carlos R. L. Rodrigues
f776ed234f feat(medusa): Run shared module migrations (#3109) 2023-02-01 08:10:59 -03:00
Rafał Fortuński
63d61e31a9 docs: fix type in Spaces documentation (#3150) 2023-01-31 19:46:40 +02:00
Shahed Nasser
499427fbc4 docs: fix bug resulted from react-tooltip (#3147)
* docs: fixed bug from using react-tooltip

* reverted removing react-uuid
2023-01-31 16:33:54 +02:00
olivermrbl
0326d6cfa3 Merge branch 'master' into develop 2023-01-31 12:10:52 +01:00
Riqwan Thamir
5ec6d438fb feat(medusa): batch remove products from a category (#3141)
* chore: added batch endpoint to remove products from categories

* chore: remove consoles

* Apply suggestions from code review

Co-authored-by: Patrick <116003638+patrick-medusajs@users.noreply.github.com>

* chore: added oas changes

---------

Co-authored-by: Patrick <116003638+patrick-medusajs@users.noreply.github.com>
2023-01-31 10:23:03 +01:00