fix(dashboard, js-sdk, types, medusa): separate between delete response with and without parent (#8852)

- Separate the previous `DeleteResponse` to `DeleteResponse` and `DeleteResponseWithParent`, as not every API route's delete response returns a parent. This ensures more accurate types shown in OAS / documentation.
- Use `DeleteResponse` or `DeleteResponseWithParent` in response API routes based on what they return
- Remove direct usage of `DeleteResponse` in API route, and instead create a type in the `type` package specific for the route / domain.
- Use the new types in the `js-sdk` and `dashboard`.
This commit is contained in:
Shahed Nasser
2024-08-30 10:15:02 +03:00
committed by GitHub
parent 9f495fd853
commit 0ee5c2d501
57 changed files with 145 additions and 106 deletions

View File

@@ -73,7 +73,7 @@ export class ApiKey {
}
async delete(id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.DeleteResponse<"api_key">>(
return await this.client.fetch<HttpTypes.AdminApiKeyDeleteResponse>(
`/admin/api-keys/${id}`,
{
method: "DELETE",

View File

@@ -71,7 +71,7 @@ export class CustomerGroup {
}
async delete(id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.DeleteResponse<"customer_group">>(
return await this.client.fetch<HttpTypes.AdminCustomerGroupDeleteResponse>(
`/admin/customer-groups/${id}`,
{
method: "DELETE",

View File

@@ -1,5 +1,4 @@
import {
DeleteResponse,
FindParams,
HttpTypes,
PaginatedResponse,
@@ -69,7 +68,7 @@ export class Customer {
}
async delete(id: string, headers?: ClientHeaders) {
return this.client.fetch<DeleteResponse<"customer">>(
return this.client.fetch<HttpTypes.AdminCustomerDeleteResponse>(
`/admin/customers/${id}`,
{
method: "DELETE",

View File

@@ -1,5 +1,4 @@
import {
DeleteResponse,
FindParams,
HttpTypes,
PaginatedResponse,
@@ -76,7 +75,7 @@ export class Invite {
}
async delete(id: string, headers?: ClientHeaders) {
return await this.client.fetch<DeleteResponse<"invite">>(
return await this.client.fetch<HttpTypes.AdminInviteDeleteResponse>(
`/admin/invites/${id}`,
{
method: "DELETE",

View File

@@ -1,5 +1,4 @@
import {
DeleteResponse,
FindParams,
HttpTypes,
PaginatedResponse,
@@ -70,7 +69,7 @@ export class Region {
}
async delete(id: string, headers?: ClientHeaders) {
return await this.client.fetch<DeleteResponse<"region">>(
return await this.client.fetch<HttpTypes.AdminRegionDeleteResponse>(
`/admin/regions/${id}`,
{
method: "DELETE",

View File

@@ -71,7 +71,7 @@ class Reservation {
}
async delete(id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.DeleteResponse<"reservation">>(
return await this.client.fetch<HttpTypes.AdminReservationDeleteResponse>(
`/admin/reservations/${id}`,
{
method: "DELETE",

View File

@@ -1,4 +1,4 @@
import { DeleteResponse, HttpTypes, SelectParams } from "@medusajs/types"
import { HttpTypes, SelectParams } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
@@ -59,7 +59,7 @@ export class Upload {
}
async delete(id: string, headers?: ClientHeaders) {
return this.client.fetch<DeleteResponse<"file">>(`/admin/uploads/${id}`, {
return this.client.fetch<HttpTypes.AdminFileDeleteResponse>(`/admin/uploads/${id}`, {
method: "DELETE",
headers,
})