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:
@@ -114,7 +114,7 @@ export const useRevokeApiKey = (
|
||||
export const useDeleteApiKey = (
|
||||
id: string,
|
||||
options?: MutationOptions<
|
||||
HttpTypes.DeleteResponse<"api_key">,
|
||||
HttpTypes.AdminApiKeyDeleteResponse,
|
||||
FetchError,
|
||||
void
|
||||
>
|
||||
|
||||
@@ -129,7 +129,7 @@ export const useCreateCollection = (
|
||||
export const useDeleteCollection = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.DeleteResponse<"collection">,
|
||||
HttpTypes.AdminCollectionDeleteResponse,
|
||||
FetchError,
|
||||
void
|
||||
>
|
||||
|
||||
@@ -105,7 +105,7 @@ export const useUpdateCustomerGroup = (
|
||||
export const useDeleteCustomerGroup = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.DeleteResponse<"customer_group">,
|
||||
HttpTypes.AdminCustomerGroupDeleteResponse,
|
||||
FetchError,
|
||||
void
|
||||
>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
import { DeleteResponse, HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
import { HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -96,7 +96,11 @@ export const useUpdateCustomer = (
|
||||
|
||||
export const useDeleteCustomer = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<DeleteResponse<"customer">, FetchError, void>
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminCustomerDeleteResponse,
|
||||
FetchError,
|
||||
void
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => sdk.admin.customer.delete(id),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
AdminInviteResponse,
|
||||
DeleteResponse,
|
||||
HttpTypes,
|
||||
PaginatedResponse,
|
||||
} from "@medusajs/types"
|
||||
@@ -94,7 +93,7 @@ export const useResendInvite = (
|
||||
|
||||
export const useDeleteInvite = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<DeleteResponse<"invite">, Error, void>
|
||||
options?: UseMutationOptions<HttpTypes.AdminInviteDeleteResponse, Error, void>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => sdk.admin.invite.delete(id),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DeleteResponse, HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
import { HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -111,7 +111,7 @@ export const useUpdateRegion = (
|
||||
|
||||
export const useDeleteRegion = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<DeleteResponse<"region">, Error, void>
|
||||
options?: UseMutationOptions<HttpTypes.AdminRegionDeleteResponse, Error, void>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => sdk.admin.region.delete(id),
|
||||
|
||||
@@ -122,7 +122,7 @@ export const useCreateReservationItem = (
|
||||
export const useDeleteReservationItem = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.DeleteResponse<"reservation">,
|
||||
HttpTypes.AdminReservationDeleteResponse,
|
||||
FetchError,
|
||||
void
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user