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:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user