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

This commit is contained in:
Shahed Nasser
2025-10-28 11:10:14 +02:00
committed by GitHub
parent a2b6ef36d9
commit 4f4ab6208d
13 changed files with 48 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
import { FindParams } from "../../common"
import { SelectParams } from "../../common"
import {
BaseProductListParams,
BaseProductOptionParams,
@@ -25,7 +25,7 @@ export interface StoreProductPricingContext {
*/
cart_id?: string
}
export interface StoreProductParams extends FindParams, StoreProductPricingContext {}
export interface StoreProductParams extends SelectParams, StoreProductPricingContext {}
export interface StoreProductListParams
extends Omit<BaseProductListParams, "tags" | "status" | "categories" | "deleted_at">, StoreProductPricingContext {

View File

@@ -1,4 +1,4 @@
interface AdminCreateTaxRateRule {
export interface AdminCreateTaxRateRule {
/**
* The name of the table that the rule references.
*

View File

@@ -4,11 +4,14 @@ import {
} from "@medusajs/framework/http"
import { linkProductsToSalesChannelWorkflow } from "@medusajs/core-flows"
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types"
import { HttpTypes } from "@medusajs/framework/types"
import { refetchSalesChannel } from "../../helpers"
export const POST = async (
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminBatchLink,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => {
const { id } = req.params

View File

@@ -8,14 +8,10 @@ import {
MedusaResponse,
} from "@medusajs/framework/http"
import { refetchSalesChannel } from "../helpers"
import {
AdminGetSalesChannelParamsType,
AdminUpdateSalesChannelType,
} from "../validators"
import { HttpTypes } from "@medusajs/framework/types"
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetSalesChannelParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => {
const salesChannel = await refetchSalesChannel(
@@ -35,7 +31,10 @@ export const GET = async (
}
export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateSalesChannelType>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateSalesChannel,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => {
const existingSalesChannel = await refetchSalesChannel(

View File

@@ -36,7 +36,10 @@ export const GET = async (
}
export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateSalesChannel>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateSalesChannel,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminSalesChannelResponse>
) => {
const salesChannelsData = [req.validatedBody]

View File

@@ -8,7 +8,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/framework/http"
import { AdminGetStoreParamsType, AdminUpdateStoreType } from "../validators"
import { AdminGetStoreParamsType } from "../validators"
import { refetchStore } from "../helpers"
import { HttpTypes } from "@medusajs/framework/types"
@@ -30,7 +30,10 @@ export const GET = async (
}
export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateStoreType>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateStore,
HttpTypes.AdminStoreParams
>,
res: MedusaResponse<HttpTypes.AdminStoreResponse>
) => {
const existingStore = await refetchStore(req.params.id, req.scope, ["id"])

View File

@@ -12,14 +12,13 @@ import {
MedusaResponse,
} from "@medusajs/framework/http"
import { refetchTaxRate } from "../helpers"
import {
AdminGetTaxRateParamsType,
AdminUpdateTaxRateType,
} from "../validators"
import { HttpTypes } from "@medusajs/framework/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateTaxRateType>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateTaxRate,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => {
const existingTaxRate = await refetchTaxRate(req.params.id, req.scope, ["id"])
@@ -47,7 +46,9 @@ export const POST = async (
}
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetTaxRateParamsType>,
req: AuthenticatedMedusaRequest<
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -7,7 +7,7 @@ import { refetchTaxRate } from "../../../helpers"
import { HttpTypes } from "@medusajs/framework/types"
export const DELETE = async (
req: AuthenticatedMedusaRequest,
req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminTaxRateRuleDeleteResponse>
) => {
await deleteTaxRateRulesWorkflow(req.scope).run({

View File

@@ -3,12 +3,14 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/framework/http"
import { AdminCreateTaxRateRuleType } from "../../validators"
import { refetchTaxRate } from "../../helpers"
import { HttpTypes } from "@medusajs/framework/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateTaxRateRuleType>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateTaxRateRule,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => {
await createTaxRateRulesWorkflow(req.scope).run({

View File

@@ -11,7 +11,10 @@ import { refetchTaxRate } from "./helpers"
import { HttpTypes } from "@medusajs/framework/types"
export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateTaxRate>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateTaxRate,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => {
const { result } = await createTaxRatesWorkflow(req.scope).run({

View File

@@ -11,10 +11,9 @@ import {
ContainerRegistrationKeys,
remoteQueryObjectFromString,
} from "@medusajs/framework/utils"
import { AdminUpdateTaxRegionType } from "../validators"
export const GET = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminUpdateTaxRegion>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminTaxRegionParams>,
res: MedusaResponse<HttpTypes.AdminTaxRegionResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -32,7 +31,10 @@ export const GET = async (
}
export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateTaxRegionType>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateTaxRegion,
HttpTypes.AdminTaxRegionParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRegionResponse>
) => {
const { id } = req.params

View File

@@ -11,7 +11,10 @@ import { refetchTaxRegion } from "./helpers"
import { HttpTypes } from "@medusajs/framework/types"
export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateTaxRegion>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateTaxRegion,
HttpTypes.AdminTaxRegionParams
>,
res: MedusaResponse<HttpTypes.AdminTaxRegionResponse>
) => {
const { result } = await createTaxRegionsWorkflow(req.scope).run({

View File

@@ -11,7 +11,7 @@ import {
} from "@medusajs/framework/utils"
export const GET = async (
req: AuthenticatedMedusaRequest,
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminFileResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)