feat(utils): Introduce promiseAll util (#5543)

This commit is contained in:
Adrien de Peretti
2023-11-08 08:48:48 +01:00
committed by GitHub
parent e4ce2f4e07
commit f90ba02087
99 changed files with 464 additions and 297 deletions
@@ -61,6 +61,7 @@ import {
mapObjectTo,
MedusaContext,
MedusaError,
promiseAll,
} from "@medusajs/utils"
import {
entityNameToLinkableKeysMap,
@@ -734,7 +735,7 @@ export default class ProductModuleService<
ProductTypes.CreateProductOptionDTO[]
>()
const productsData = await Promise.all(
const productsData = await promiseAll(
data.map(async (product) => {
const productData = { ...product }
if (!productData.handle) {
@@ -816,7 +817,7 @@ export default class ProductModuleService<
})
}
await Promise.all(
await promiseAll(
[...productVariantsMap].map(async ([handle, variants]) => {
return await this.productVariantService_.create(
productByHandleMap.get(handle)!,
@@ -861,7 +862,7 @@ export default class ProductModuleService<
const productOptionsMap = new Map<string, TProductOption[]>()
const productsData = await Promise.all(
const productsData = await promiseAll(
data.map(async (product) => {
const { variants, ...productData } = product
@@ -997,7 +998,7 @@ export default class ProductModuleService<
)
}
await Promise.all(promises)
await promiseAll(promises)
return products
}