Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core-flows,fulfillment, fulfillment-manual, types): make fulfillment typings more specific #10677

Merged
merged 11 commits into from
Jan 7, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ export class ManualFulfillmentService extends AbstractFulfillmentProviderService

async createFulfillment() {
// No data is being sent anywhere
return {}
return {
data: {},
labels: [],
}
}

async cancelFulfillment() {
return {}
}

async createReturnFulfillment() {
return {}
return { data: {}, labels: [] }
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Modules, promiseAll } from "@medusajs/framework/utils"
import {
CartDTO,
IFulfillmentModuleService,
StockLocationDTO,
ValidateFulfillmentDataContext,
} from "@medusajs/types"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"

Expand All @@ -11,7 +10,7 @@ export type ValidateShippingMethodsDataInput = {
provider_id: string
option_data: Record<string, unknown>
method_data: Record<string, unknown>
context: CartDTO & { from_location: StockLocationDTO; [k: string]: unknown }
context: ValidateFulfillmentDataContext
}[]

export const validateAndReturnShippingMethodsDataStepId =
Expand All @@ -38,7 +37,7 @@ export const validateAndReturnShippingMethodsDataStep = createStep(
option.provider_id,
option.option_data,
option.method_data,
option.context
option.context as ValidateFulfillmentDataContext
)

return {
Expand Down
29 changes: 29 additions & 0 deletions packages/core/types/src/fulfillment/common/cart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CartDTO } from "../.."

export type CartPropsForFulfillment = {
id: CartDTO["id"]
shipping_address: CartDTO["shipping_address"]
items: CartDTO["items"] & {
variant: {
id: string
weight: number
length: number
height: number
width: number
material: string
product: {
id: string
}
}
product: {
id: string
collection_id: string
categories: {
id: string
}[]
tags: {
id: string
}[]
}
}
}
2 changes: 2 additions & 0 deletions packages/core/types/src/fulfillment/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export * from "./fulfillment-provider"
export * from "./fulfillment"
export * from "./fulfillment-item"
export * from "./fulfillment-label"
export * from "./cart"
export * from "./order"
Loading
Loading