Skip to content

Commit

Permalink
feat(core-flows,fulfillment, fulfillment-manual, types): make fulfill…
Browse files Browse the repository at this point in the history
…ment typings more specific (#10677)

**What**
- attempt to add more specific type definitions around fulfillment provider APIs

---

CLOSES CMRC-814
CLOSES CMRC-816
CLOSES CMRC-817
  • Loading branch information
fPolic authored Jan 7, 2025
1 parent 333ed53 commit 16b0672
Show file tree
Hide file tree
Showing 12 changed files with 1,358 additions and 68 deletions.
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

0 comments on commit 16b0672

Please sign in to comment.