Files
medusa-store/integration-tests/api/__tests__/admin
Adrien de Peretti e77a02aca5 feat(): Update transformer middleware and API (#6647)
**What**
Update all transform middleware to support the new API
- deprecate `defaultRelations`
- deprecate `allowedRelations`
- Add `defaults` and `allowed` in replacement for `defaultFields` and `allowedFields` respectively
- in the `defaults` it is possible to specify a field such as `*variants` in order to be recognized as a relation only without specifying any property
- add support for `remoteQueryConfig` assigned to req like we have for `listConfig` and `retrieveConfig`
- add support to override `allowed|allowedFields` if a previous middleware have set it up on the req.allowed
- The api now accepts `fields` as the only accepted fields to manage the requested props and relations, the `expand` property have been deprecated. New supported symbols have been added in complement of the fields
  - `+` (e.g `/store/products?fields=+description`) to specify that description should be added as part of the returned data among the other defined fields
  - `-` (e.g `/store/products?fields=-description`) to specify that description should be removed as part of the returned data
  - `*` (e.g `/store/products?fields=*variants`) to specify that the variants relations should be added as part of the returned data among the other defined fields without having to specify which property of the variants should be returned. In the `defaults` config of the transform middleware it is also possible to use this symbol
  - In the case no symbol is provided, it will replace the default fields and mean that only the specified fields must be returned

About the allowed validation, all fields in the `defaults` configuration must be present in the `allowed` configuration. 
In case the `defaults` contains full relation selection (e.g `*product.variants`) it should be present in the `allowed` as `product.variants`. In case in the `defaults` you add `product.variants.id`, it will be allowed if the `allowed` configuration includes either `product.variants.id` as full match or `product.variants` as it means that we allow all properties from `product.variants`

Also, support for `*` selection on the remote query/joiner have been added


**Note**
All v2 end points refactoring can be done separately
2024-03-18 08:37:59 +00:00
..