chore: Remove unused clients in admin + clean up js-sdk (#8839)
* feat(js-sdk): Add API key * chore: Remove unused clients in admin + clean up js-sdk * fix sales channel hooks
This commit is contained in:
@@ -1,23 +1,11 @@
|
||||
import Medusa from "@medusajs/js-sdk"
|
||||
import { campaigns } from "./campaigns"
|
||||
import { categories } from "./categories"
|
||||
import { currencies } from "./currencies"
|
||||
import { customerGroups } from "./customer-groups"
|
||||
import { fulfillmentProviders } from "./fulfillment-providers"
|
||||
import { fulfillments } from "./fulfillments"
|
||||
import { invites } from "./invites"
|
||||
import { payments } from "./payments"
|
||||
import { priceLists } from "./price-lists"
|
||||
import { productTypes } from "./product-types"
|
||||
import { promotions } from "./promotions"
|
||||
import { reservations } from "./reservations"
|
||||
import { salesChannels } from "./sales-channels"
|
||||
import { shippingOptions } from "./shipping-options"
|
||||
import { shippingProfiles } from "./shipping-profiles"
|
||||
import { stockLocations } from "./stock-locations"
|
||||
import { stores } from "./stores"
|
||||
import { tags } from "./tags"
|
||||
import { users } from "./users"
|
||||
import { workflowExecutions } from "./workflow-executions"
|
||||
|
||||
export const backendUrl = __BACKEND_URL__ ?? "http://localhost:9000"
|
||||
@@ -26,21 +14,9 @@ export const client = {
|
||||
campaigns: campaigns,
|
||||
categories: categories,
|
||||
customerGroups: customerGroups,
|
||||
currencies: currencies,
|
||||
promotions: promotions,
|
||||
payments: payments,
|
||||
stores: stores,
|
||||
salesChannels: salesChannels,
|
||||
shippingOptions: shippingOptions,
|
||||
shippingProfiles: shippingProfiles,
|
||||
productTags: tags,
|
||||
users: users,
|
||||
invites: invites,
|
||||
reservations: reservations,
|
||||
fulfillments: fulfillments,
|
||||
fulfillmentProviders: fulfillmentProviders,
|
||||
productTypes: productTypes,
|
||||
priceLists: priceLists,
|
||||
stockLocations: stockLocations,
|
||||
workflowExecutions: workflowExecutions,
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { CreateFulfillmentDTO } from "@medusajs/types"
|
||||
|
||||
import { FulfillmentRes } from "../../types/api-responses"
|
||||
import { postRequest } from "./common"
|
||||
|
||||
/**
|
||||
* Create a fulfillment.
|
||||
* NOTE: to create a fulfillment on an order use orders/:id/fulfillments endpoint
|
||||
*/
|
||||
async function createFulfillment(payload: CreateFulfillmentDTO) {
|
||||
return postRequest<FulfillmentRes>(`/admin/fulfillments`, payload)
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a fulfillment.
|
||||
* NOTE: to cancel a fulfillment on an order use orders/:id/fulfillments/:id/cancel endpoint
|
||||
*/
|
||||
async function cancelFulfillment(id: string) {
|
||||
return postRequest<FulfillmentRes>(`/admin/fulfillments/${id}/cancel`)
|
||||
}
|
||||
|
||||
export const fulfillments = {
|
||||
create: createFulfillment,
|
||||
cancel: cancelFulfillment,
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import { CreateInviteReq } from "../../types/api-payloads"
|
||||
import {
|
||||
InviteDeleteRes,
|
||||
InviteListRes,
|
||||
InviteRes,
|
||||
} from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveInvite(id: string, query?: Record<string, any>) {
|
||||
return getRequest<InviteRes, Record<string, any>>(
|
||||
`/admin/invites/${id}`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
async function listInvites(query?: Record<string, any>) {
|
||||
return getRequest<InviteListRes, Record<string, any>>(`/admin/invites`, query)
|
||||
}
|
||||
|
||||
async function createInvite(payload: CreateInviteReq) {
|
||||
return postRequest<InviteRes>(`/admin/invites`, payload)
|
||||
}
|
||||
|
||||
async function resendInvite(id: string) {
|
||||
return postRequest<InviteRes>(`/admin/invites/${id}/resend`)
|
||||
}
|
||||
|
||||
async function deleteInvite(id: string) {
|
||||
return deleteRequest<InviteDeleteRes>(`/admin/invites/${id}`)
|
||||
}
|
||||
|
||||
export const invites = {
|
||||
retrieve: retrieveInvite,
|
||||
list: listInvites,
|
||||
create: createInvite,
|
||||
resend: resendInvite,
|
||||
delete: deleteInvite,
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { PaymentProvidersListRes } from "../../types/api-responses"
|
||||
import { getRequest } from "./common"
|
||||
|
||||
async function listPaymentProviders(query?: Record<string, any>) {
|
||||
return getRequest<PaymentProvidersListRes, Record<string, any>>(
|
||||
`/admin/payments/payment-providers`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
export const payments = {
|
||||
listPaymentProviders,
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import {
|
||||
AddPriceListPricesReq,
|
||||
CreatePriceListReq,
|
||||
DeletePriceListPricesReq,
|
||||
UpdatePriceListReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
PriceListDeleteRes,
|
||||
PriceListListRes,
|
||||
PriceListRes,
|
||||
} from "../../types/api-responses"
|
||||
import { getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrievePriceLists(id: string, query?: Record<string, any>) {
|
||||
return getRequest<PriceListRes>(`/admin/price-lists/${id}`, query)
|
||||
}
|
||||
|
||||
async function listPriceLists(query?: Record<string, any>) {
|
||||
return getRequest<PriceListListRes>(`/admin/price-lists`, query)
|
||||
}
|
||||
|
||||
async function createPriceList(payload: CreatePriceListReq) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists`, payload)
|
||||
}
|
||||
|
||||
async function updatePriceList(id: string, payload: UpdatePriceListReq) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists/${id}`, payload)
|
||||
}
|
||||
|
||||
async function deletePriceList(id: string) {
|
||||
return postRequest<PriceListDeleteRes>(`/admin/price-lists/${id}/delete`)
|
||||
}
|
||||
|
||||
async function addPriceListPrices(id: string, payload: AddPriceListPricesReq) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists/${id}/prices/batch`, {
|
||||
create: payload.prices,
|
||||
})
|
||||
}
|
||||
|
||||
async function removePriceListPrices(
|
||||
id: string,
|
||||
payload: DeletePriceListPricesReq
|
||||
) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists/${id}/prices/batch`, {
|
||||
delete: payload.ids,
|
||||
})
|
||||
}
|
||||
|
||||
export const priceLists = {
|
||||
retrieve: retrievePriceLists,
|
||||
list: listPriceLists,
|
||||
create: createPriceList,
|
||||
update: updatePriceList,
|
||||
delete: deletePriceList,
|
||||
addPrices: addPriceListPrices,
|
||||
removePrices: removePriceListPrices,
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { getRequest } from "./common"
|
||||
|
||||
async function listProductTypes(query?: Record<string, any>) {
|
||||
return getRequest<{ product_types: HttpTypes.AdminProductType[] }>(
|
||||
`/admin/product-types`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
async function retrieveProductType(id: string, query?: Record<string, any>) {
|
||||
return getRequest<{ product_type: HttpTypes.AdminProductType }>(
|
||||
`/admin/product-types/${id}`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
export const productTypes = {
|
||||
list: listProductTypes,
|
||||
retrieve: retrieveProductType,
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { getRequest } from "./common"
|
||||
|
||||
async function listProductTags(query?: Record<string, any>) {
|
||||
return getRequest<any>(`/admin/product-tags`, query)
|
||||
}
|
||||
|
||||
async function retrieveProductTag(id: string, query?: Record<string, any>) {
|
||||
return getRequest<any>(`/admin/product-tags/${id}`, query)
|
||||
}
|
||||
|
||||
export const tags = {
|
||||
list: listProductTags,
|
||||
retrieve: retrieveProductTag,
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { UpdateUserReq } from "../../types/api-payloads"
|
||||
import { UserDeleteRes, UserListRes, UserRes } from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function me() {
|
||||
return getRequest<UserRes>("/admin/users/me")
|
||||
}
|
||||
|
||||
async function retrieveUser(id: string, query?: Record<string, any>) {
|
||||
return getRequest<UserRes>(`/admin/users/${id}`, query)
|
||||
}
|
||||
|
||||
async function listUsers(query?: Record<string, any>) {
|
||||
return getRequest<UserListRes>(`/admin/users`, query)
|
||||
}
|
||||
|
||||
async function updateUser(id: string, payload: UpdateUserReq) {
|
||||
return postRequest<UserRes>(`/admin/users/${id}`, payload)
|
||||
}
|
||||
|
||||
async function deleteUser(id: string) {
|
||||
return deleteRequest<UserDeleteRes>(`/admin/users/${id}`)
|
||||
}
|
||||
|
||||
export const users = {
|
||||
me,
|
||||
retrieve: retrieveUser,
|
||||
list: listUsers,
|
||||
update: updateUser,
|
||||
delete: deleteUser,
|
||||
}
|
||||
Reference in New Issue
Block a user