chore: Adjusting the v2 product module to follow the v1 specs (#6618)
In this PR: 1. I added upsert support for the product 2. I updated the create and update signatures to match the latest interface standards 3. Small changes to make the v1 and v2 APIs compatible (WIP)
This commit is contained in:
@@ -27,7 +27,7 @@ export async function revertUpdateProducts({
|
||||
product.variants = product.variants.map((v) => ({ id: v.id }))
|
||||
})
|
||||
|
||||
return await productModuleService.update(
|
||||
return await productModuleService.upsert(
|
||||
data.originalProducts as unknown as UpdateProductDTO[]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function updateProducts({
|
||||
const productModuleService: ProductTypes.IProductModuleService =
|
||||
container.resolve(ModulesDefinition[Modules.PRODUCT].registrationName)
|
||||
|
||||
const products = await productModuleService.update(data.products)
|
||||
const products = await productModuleService.upsert(data.products)
|
||||
|
||||
return await productModuleService.list(
|
||||
{ id: products.map((p) => p.id) },
|
||||
|
||||
@@ -25,9 +25,7 @@ export const updateProductsStep = createStep(
|
||||
relations,
|
||||
})
|
||||
|
||||
// TODO: We need to update the module's signature
|
||||
// const products = await service.update(data.selector, data.update)
|
||||
const products = []
|
||||
const products = await service.update(data.selector, data.update)
|
||||
return new StepResponse(products, prevData)
|
||||
},
|
||||
async (prevData, { container }) => {
|
||||
@@ -39,11 +37,10 @@ export const updateProductsStep = createStep(
|
||||
ModuleRegistrationName.PRODUCT
|
||||
)
|
||||
|
||||
// TODO: We need to update the module's signature
|
||||
// await service.upsert(
|
||||
// prevData.map((r) => ({
|
||||
// ...r,
|
||||
// }))
|
||||
// )
|
||||
await service.upsert(
|
||||
prevData.map((r) => ({
|
||||
...(r as unknown as ProductTypes.UpdateProductDTO),
|
||||
}))
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user