fix: workflow 'when' should return T or undefined instead of Partial<T> (#8195)
* fix: workflow 'when' should return T or undefined instead of Partial<T> * fix when usage
This commit is contained in:
1 parent
78b8a3c60f
commit
35c3759ed8
3 files changed
+7
-7
No files matched your search
@@ -7,11 +7,11 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { ChangeActionType, OrderChangeStatus } from "@medusajs/utils"
|
import { ChangeActionType, OrderChangeStatus } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
|
||||||
createStep,
|
createStep,
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
transform,
|
transform,
|
||||||
when,
|
when,
|
||||||
|
WorkflowData,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { useRemoteQueryStep } from "../../../common"
|
import { useRemoteQueryStep } from "../../../common"
|
||||||
import { createOrderChangeActionsStep } from "../../steps/create-order-change-actions"
|
import { createOrderChangeActionsStep } from "../../steps/create-order-change-actions"
|
||||||
@@ -88,7 +88,7 @@ export const orderClaimRequestItemReturnWorkflow = createWorkflow(
|
|||||||
const orderReturn: ReturnDTO = transform(
|
const orderReturn: ReturnDTO = transform(
|
||||||
{ createdReturn, existingOrderReturn, orderClaim },
|
{ createdReturn, existingOrderReturn, orderClaim },
|
||||||
({ createdReturn, existingOrderReturn, orderClaim }) => {
|
({ createdReturn, existingOrderReturn, orderClaim }) => {
|
||||||
return existingOrderReturn ?? (createdReturn[0] as ReturnDTO)
|
return existingOrderReturn ?? (createdReturn?.[0] as ReturnDTO)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ export const orderClaimRequestItemReturnWorkflow = createWorkflow(
|
|||||||
const createdReturnId = transform(
|
const createdReturnId = transform(
|
||||||
{ createdReturn },
|
{ createdReturn },
|
||||||
({ createdReturn }) => {
|
({ createdReturn }) => {
|
||||||
return createdReturn[0]!.id
|
return createdReturn?.[0]!.id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
updateOrderClaimsStep([
|
updateOrderClaimsStep([
|
||||||
|
|||||||
+3
-3
@@ -7,11 +7,11 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { ChangeActionType, OrderChangeStatus } from "@medusajs/utils"
|
import { ChangeActionType, OrderChangeStatus } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
|
||||||
createStep,
|
createStep,
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
transform,
|
transform,
|
||||||
when,
|
when,
|
||||||
|
WorkflowData,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { useRemoteQueryStep } from "../../../common"
|
import { useRemoteQueryStep } from "../../../common"
|
||||||
import { createOrderChangeActionsStep } from "../../steps/create-order-change-actions"
|
import { createOrderChangeActionsStep } from "../../steps/create-order-change-actions"
|
||||||
@@ -89,7 +89,7 @@ export const orderExchangeRequestItemReturnWorkflow = createWorkflow(
|
|||||||
const orderReturn: ReturnDTO = transform(
|
const orderReturn: ReturnDTO = transform(
|
||||||
{ createdReturn, existingOrderReturn, orderExchange },
|
{ createdReturn, existingOrderReturn, orderExchange },
|
||||||
({ createdReturn, existingOrderReturn, orderExchange }) => {
|
({ createdReturn, existingOrderReturn, orderExchange }) => {
|
||||||
return existingOrderReturn ?? (createdReturn[0] as ReturnDTO)
|
return existingOrderReturn ?? (createdReturn?.[0] as ReturnDTO)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ export const orderExchangeRequestItemReturnWorkflow = createWorkflow(
|
|||||||
const createdReturnId = transform(
|
const createdReturnId = transform(
|
||||||
{ createdReturn },
|
{ createdReturn },
|
||||||
({ createdReturn }) => {
|
({ createdReturn }) => {
|
||||||
return createdReturn[0]!.id
|
return createdReturn?.[0]!.id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
updateOrderExchangesStep([
|
updateOrderExchangesStep([
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type ConditionFunction<T extends object | WorkflowData> = (
|
|||||||
type ThenFunc = <ThenResolver extends () => any>(
|
type ThenFunc = <ThenResolver extends () => any>(
|
||||||
resolver: ThenResolver
|
resolver: ThenResolver
|
||||||
) => ReturnType<ThenResolver> extends WorkflowData<infer ReturnedWorkflowData>
|
) => ReturnType<ThenResolver> extends WorkflowData<infer ReturnedWorkflowData>
|
||||||
? Partial<WorkflowData<ReturnedWorkflowData>>
|
? WorkflowData<ReturnedWorkflowData> | undefined
|
||||||
: ReturnType<ThenResolver>
|
: ReturnType<ThenResolver>
|
||||||
|
|
||||||
export function when<T extends object | WorkflowData, Then extends Function>(
|
export function when<T extends object | WorkflowData, Then extends Function>(
|
||||||
|
|||||||
Reference in new issue
Block a user