chore: fixes to http and request types for sales channes, taxes, and store (#13832)

This commit is contained in:
Shahed Nasser
2025-10-28 10:10:14 +01:00
committed by GitHub
parent a2b6ef36d9
commit 4f4ab6208d
13 changed files with 48 additions and 29 deletions
@@ -1,4 +1,4 @@
import { FindParams } from "../../common" import { SelectParams } from "../../common"
import { import {
BaseProductListParams, BaseProductListParams,
BaseProductOptionParams, BaseProductOptionParams,
@@ -25,7 +25,7 @@ export interface StoreProductPricingContext {
*/ */
cart_id?: string cart_id?: string
} }
export interface StoreProductParams extends FindParams, StoreProductPricingContext {} export interface StoreProductParams extends SelectParams, StoreProductPricingContext {}
export interface StoreProductListParams export interface StoreProductListParams
extends Omit<BaseProductListParams, "tags" | "status" | "categories" | "deleted_at">, StoreProductPricingContext { extends Omit<BaseProductListParams, "tags" | "status" | "categories" | "deleted_at">, StoreProductPricingContext {
@@ -1,4 +1,4 @@
interface AdminCreateTaxRateRule { export interface AdminCreateTaxRateRule {
/** /**
* The name of the table that the rule references. * The name of the table that the rule references.
* *
@@ -4,11 +4,14 @@ import {
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { linkProductsToSalesChannelWorkflow } from "@medusajs/core-flows" import { linkProductsToSalesChannelWorkflow } from "@medusajs/core-flows"
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
import { refetchSalesChannel } from "../../helpers" import { refetchSalesChannel } from "../../helpers"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<LinkMethodRequest>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminBatchLink,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse> res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -8,14 +8,10 @@ import {
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { refetchSalesChannel } from "../helpers" import { refetchSalesChannel } from "../helpers"
import {
AdminGetSalesChannelParamsType,
AdminUpdateSalesChannelType,
} from "../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetSalesChannelParamsType>, req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse> res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => { ) => {
const salesChannel = await refetchSalesChannel( const salesChannel = await refetchSalesChannel(
@@ -35,7 +31,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateSalesChannelType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateSalesChannel,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse> res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => { ) => {
const existingSalesChannel = await refetchSalesChannel( const existingSalesChannel = await refetchSalesChannel(
@@ -36,7 +36,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateSalesChannel>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateSalesChannel,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse> res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => { ) => {
const salesChannelsData = [req.validatedBody] const salesChannelsData = [req.validatedBody]
@@ -8,7 +8,7 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminGetStoreParamsType, AdminUpdateStoreType } from "../validators" import { AdminGetStoreParamsType } from "../validators"
import { refetchStore } from "../helpers" import { refetchStore } from "../helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
@@ -30,7 +30,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateStoreType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateStore,
HttpTypes.AdminStoreParams
>,
res: MedusaResponse<HttpTypes.AdminStoreResponse> res: MedusaResponse<HttpTypes.AdminStoreResponse>
) => { ) => {
const existingStore = await refetchStore(req.params.id, req.scope, ["id"]) const existingStore = await refetchStore(req.params.id, req.scope, ["id"])
@@ -12,14 +12,13 @@ import {
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { refetchTaxRate } from "../helpers" import { refetchTaxRate } from "../helpers"
import {
AdminGetTaxRateParamsType,
AdminUpdateTaxRateType,
} from "../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateTaxRateType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateTaxRate,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse> res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => { ) => {
const existingTaxRate = await refetchTaxRate(req.params.id, req.scope, ["id"]) const existingTaxRate = await refetchTaxRate(req.params.id, req.scope, ["id"])
@@ -47,7 +46,9 @@ export const POST = async (
} }
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetTaxRateParamsType>, req: AuthenticatedMedusaRequest<
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse> res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -7,7 +7,7 @@ import { refetchTaxRate } from "../../../helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const DELETE = async ( export const DELETE = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminTaxRateRuleDeleteResponse> res: MedusaResponse<HttpTypes.AdminTaxRateRuleDeleteResponse>
) => { ) => {
await deleteTaxRateRulesWorkflow(req.scope).run({ await deleteTaxRateRulesWorkflow(req.scope).run({
@@ -3,12 +3,14 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminCreateTaxRateRuleType } from "../../validators"
import { refetchTaxRate } from "../../helpers" import { refetchTaxRate } from "../../helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateTaxRateRuleType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateTaxRateRule,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse> res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => { ) => {
await createTaxRateRulesWorkflow(req.scope).run({ await createTaxRateRulesWorkflow(req.scope).run({
@@ -11,7 +11,10 @@ import { refetchTaxRate } from "./helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateTaxRate>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateTaxRate,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse> res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => { ) => {
const { result } = await createTaxRatesWorkflow(req.scope).run({ const { result } = await createTaxRatesWorkflow(req.scope).run({
@@ -11,10 +11,9 @@ import {
ContainerRegistrationKeys, ContainerRegistrationKeys,
remoteQueryObjectFromString, remoteQueryObjectFromString,
} from "@medusajs/framework/utils" } from "@medusajs/framework/utils"
import { AdminUpdateTaxRegionType } from "../validators"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminUpdateTaxRegion>, req: AuthenticatedMedusaRequest<HttpTypes.AdminTaxRegionParams>,
res: MedusaResponse<HttpTypes.AdminTaxRegionResponse> res: MedusaResponse<HttpTypes.AdminTaxRegionResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -32,7 +31,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateTaxRegionType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateTaxRegion,
HttpTypes.AdminTaxRegionParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRegionResponse> res: MedusaResponse<HttpTypes.AdminTaxRegionResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -11,7 +11,10 @@ import { refetchTaxRegion } from "./helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateTaxRegion>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateTaxRegion,
HttpTypes.AdminTaxRegionParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRegionResponse> res: MedusaResponse<HttpTypes.AdminTaxRegionResponse>
) => { ) => {
const { result } = await createTaxRegionsWorkflow(req.scope).run({ const { result } = await createTaxRegionsWorkflow(req.scope).run({
@@ -11,7 +11,7 @@ import {
} from "@medusajs/framework/utils" } from "@medusajs/framework/utils"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminFileResponse> res: MedusaResponse<HttpTypes.AdminFileResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)