chore: fixes to http and request types for fulfillment (#13826)

* chore: fixes to http and request types for fulfillment

* fix type error
This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-10-28 10:08:07 +01:00
1 parent faea42316a
commit bc87c9a0ba
18 files changed
+53 -38

No files matched your search

@@ -62,7 +62,7 @@ export class FulfillmentProvider {
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations). * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
*/ */
async list( async list(
query?: HttpTypes.AdminFulfillmentProviderListParams, query?: HttpTypes.AdminGetFulfillmentProvidersParams,
headers?: ClientHeaders headers?: ClientHeaders
) { ) {
return await this.client.fetch<HttpTypes.AdminFulfillmentProviderListResponse>( return await this.client.fetch<HttpTypes.AdminFulfillmentProviderListResponse>(
@@ -1,6 +1,6 @@
import { FindParams } from "../../common" import { FindParams } from "../../common"
export interface AdminFulfillmentProviderListParams extends FindParams { export interface AdminGetFulfillmentProvidersParams extends FindParams {
/** /**
* Filter by provider ID(s). * Filter by provider ID(s).
*/ */
@@ -1,3 +1,4 @@
export * from "./entities" export * from "./entities"
export * from "./payloads" export * from "./payloads"
export * from "./queries"
export * from "./responses" export * from "./responses"
@@ -1,4 +1,3 @@
export * from "./entitites" export * from "./entitites"
export * from "./payloads" export * from "./payloads"
export * from "./queries"
export * from "./responses" export * from "./responses"
@@ -1,6 +0,0 @@
export interface AdminGetFulfillmentProvidersParams {
id?: string | string[]
stock_location_id?: string | string[]
is_enabled?: boolean
q?: string
}
@@ -19,10 +19,9 @@ import {
MedusaRequest, MedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminUpdateFulfillmentSetServiceZonesType } from "../../../validators"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<AdminServiceZoneResponse> res: MedusaResponse<AdminServiceZoneResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -48,7 +47,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: MedusaRequest<AdminUpdateFulfillmentSetServiceZonesType>, req: MedusaRequest<
HttpTypes.AdminUpdateFulfillmentSetServiceZone,
HttpTypes.SelectParams
>,
res: MedusaResponse<AdminFulfillmentSetResponse> res: MedusaResponse<AdminFulfillmentSetResponse>
) => { ) => {
const fulfillmentModuleService = req.scope.resolve<IFulfillmentModuleService>( const fulfillmentModuleService = req.scope.resolve<IFulfillmentModuleService>(
@@ -1,11 +1,13 @@
import { createServiceZonesWorkflow } from "@medusajs/core-flows" import { createServiceZonesWorkflow } from "@medusajs/core-flows"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http" import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { AdminCreateFulfillmentSetServiceZonesType } from "../../validators"
import { refetchFulfillmentSet } from "../../helpers" import { refetchFulfillmentSet } from "../../helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: MedusaRequest<AdminCreateFulfillmentSetServiceZonesType>, req: MedusaRequest<
HttpTypes.AdminCreateFulfillmentSetServiceZone,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminFulfillmentSetResponse> res: MedusaResponse<HttpTypes.AdminFulfillmentSetResponse>
) => { ) => {
const workflowInput = { const workflowInput = {
@@ -7,7 +7,7 @@ import { refetchFulfillment } from "../../helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminFulfillmentResponse> res: MedusaResponse<HttpTypes.AdminFulfillmentResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -5,10 +5,12 @@ import {
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { refetchFulfillment } from "../../helpers" import { refetchFulfillment } from "../../helpers"
import { AdminCreateShipmentType } from "../../validators"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateShipmentType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateFulfillmentShipment,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminFulfillmentResponse> res: MedusaResponse<HttpTypes.AdminFulfillmentResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -5,10 +5,12 @@ import {
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { refetchFulfillment } from "./helpers" import { refetchFulfillment } from "./helpers"
import { AdminCreateFulfillmentType } from "./validators"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateFulfillmentType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateFulfillment,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminFulfillmentResponse> res: MedusaResponse<HttpTypes.AdminFulfillmentResponse>
) => { ) => {
const { result: fullfillment } = await createFulfillmentWorkflow( const { result: fullfillment } = await createFulfillmentWorkflow(
@@ -10,7 +10,6 @@ import {
import { refetchShippingOptionType } from "../helpers" import { refetchShippingOptionType } from "../helpers"
import { import {
AdminGetShippingOptionTypeParamsType, AdminGetShippingOptionTypeParamsType,
AdminUpdateShippingOptionTypeType,
} from "../validators" } from "../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
import { MedusaError } from "@medusajs/framework/utils" import { MedusaError } from "@medusajs/framework/utils"
@@ -35,7 +34,10 @@ export const GET = async (
* @since 2.10.0 * @since 2.10.0
*/ */
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateShippingOptionTypeType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateShippingOptionType,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminShippingOptionTypeResponse> res: MedusaResponse<HttpTypes.AdminShippingOptionTypeResponse>
) => { ) => {
const existingShippingOptionType = await refetchShippingOptionType( const existingShippingOptionType = await refetchShippingOptionType(
@@ -36,7 +36,10 @@ export const GET = async (
* @since 2.10.0 * @since 2.10.0
*/ */
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateShippingOptionType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateShippingOptionType,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminShippingOptionTypeResponse> res: MedusaResponse<HttpTypes.AdminShippingOptionTypeResponse>
) => { ) => {
const input = [req.validatedBody] const input = [req.validatedBody]
@@ -8,14 +8,10 @@ import {
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { refetchShippingOption } from "../helpers" import { refetchShippingOption } from "../helpers"
import {
AdminGetShippingOptionParamsType,
AdminUpdateShippingOptionType,
} from "../validators"
import { MedusaError } from "@medusajs/framework/utils" import { MedusaError } from "@medusajs/framework/utils"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetShippingOptionParamsType>, req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminShippingOptionResponse> res: MedusaResponse<HttpTypes.AdminShippingOptionResponse>
) => { ) => {
const shippingOption = await refetchShippingOption( const shippingOption = await refetchShippingOption(
@@ -35,7 +31,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateShippingOptionType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateShippingOption,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminShippingOptionResponse> res: MedusaResponse<HttpTypes.AdminShippingOptionResponse>
) => { ) => {
const shippingOptionPayload = req.validatedBody const shippingOptionPayload = req.validatedBody
@@ -11,7 +11,8 @@ export const POST = async (
BatchMethodRequest< BatchMethodRequest<
HttpTypes.AdminCreateShippingOptionRule, HttpTypes.AdminCreateShippingOptionRule,
HttpTypes.AdminUpdateShippingOptionRule HttpTypes.AdminUpdateShippingOptionRule
> >,
HttpTypes.SelectParams
>, >,
res: MedusaResponse<HttpTypes.AdminUpdateShippingOptionRulesResponse> res: MedusaResponse<HttpTypes.AdminUpdateShippingOptionRulesResponse>
) => { ) => {
@@ -36,7 +36,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateShippingOption>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateShippingOption,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminShippingOptionResponse> res: MedusaResponse<HttpTypes.AdminShippingOptionResponse>
) => { ) => {
const shippingOptionPayload = req.validatedBody const shippingOptionPayload = req.validatedBody
@@ -9,13 +9,9 @@ import {
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { refetchShippingProfile } from "../helpers" import { refetchShippingProfile } from "../helpers"
import {
AdminGetShippingProfileParamsType,
AdminUpdateShippingProfileType,
} from "../validators"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetShippingProfileParamsType>, req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminShippingProfileResponse> res: MedusaResponse<HttpTypes.AdminShippingProfileResponse>
) => { ) => {
const shippingProfile = await refetchShippingProfile( const shippingProfile = await refetchShippingProfile(
@@ -52,7 +48,10 @@ export const DELETE = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateShippingProfileType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateShippingProfile,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminShippingProfileResponse> res: MedusaResponse<HttpTypes.AdminShippingProfileResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -11,7 +11,10 @@ import {
import { refetchShippingProfile } from "./helpers" import { refetchShippingProfile } from "./helpers"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateShippingProfile>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateShippingProfile,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminShippingProfileResponse> res: MedusaResponse<HttpTypes.AdminShippingProfileResponse>
) => { ) => {
const shippingProfilePayload = req.validatedBody const shippingProfilePayload = req.validatedBody
@@ -4,7 +4,10 @@ import { calculateShippingOptionsPricesWorkflow } from "@medusajs/core-flows"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils" import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export const POST = async ( export const POST = async (
req: MedusaRequest<HttpTypes.StoreCalculateShippingOptionPrice>, req: MedusaRequest<
HttpTypes.StoreCalculateShippingOptionPrice,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.StoreShippingOptionResponse> res: MedusaResponse<HttpTypes.StoreShippingOptionResponse>
) => { ) => {
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY) const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)