fix(core-flows, types, medusa): fix batch delete types in workflows and routes (#8974)
- Fix the returned data of batch delete steps / workflows for deleted records to just be the array of IDs. - Add a new type `BatchResponse` for API routes to have a different shape for deleted records - Update batch delete helpers to return the expected shape for API routes
This commit is contained in:
@@ -33,7 +33,7 @@ export const deleteShippingOptionRulesStep = createStep(
|
||||
|
||||
await fulfillmentModule.deleteShippingOptionRules(ids)
|
||||
|
||||
return new StepResponse(null, shippingOptionRules)
|
||||
return new StepResponse(ids, shippingOptionRules)
|
||||
},
|
||||
async (shippingOptionRules, { container }) => {
|
||||
if (!shippingOptionRules?.length) {
|
||||
|
||||
@@ -54,11 +54,7 @@ export const batchProductVariantsWorkflow = createWorkflow(
|
||||
return {
|
||||
created: data.res[0],
|
||||
updated: data.res[1],
|
||||
deleted: {
|
||||
ids: data.input.delete ?? [],
|
||||
object: "product_variant",
|
||||
deleted: true,
|
||||
},
|
||||
deleted: data.input.delete ?? [],
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -47,11 +47,7 @@ export const batchProductsWorkflow = createWorkflow(
|
||||
return {
|
||||
created: data.res[0],
|
||||
updated: data.res[1],
|
||||
deleted: {
|
||||
ids: data.input.delete ?? [],
|
||||
object: "product",
|
||||
deleted: true,
|
||||
},
|
||||
deleted: data.input.delete ?? [],
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -22,11 +22,7 @@ export const deletePromotionRulesWorkflowStep = createStep(
|
||||
}
|
||||
|
||||
return new StepResponse(
|
||||
{
|
||||
ids: data.data.rule_ids ?? [],
|
||||
object: "promotion-rule",
|
||||
deleted: true,
|
||||
},
|
||||
data.data.rule_ids ?? [],
|
||||
transaction
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user