feat(utils): Introduce promiseAll util (#5543)
This commit is contained in:
committed by
GitHub
parent
e4ce2f4e07
commit
f90ba02087
@@ -1,5 +1,6 @@
|
||||
import { IInventoryService, InventoryItemDTO } from "@medusajs/types"
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
|
||||
type Result = {
|
||||
tag: string
|
||||
@@ -23,7 +24,7 @@ export async function createInventoryItems({
|
||||
return void 0
|
||||
}
|
||||
|
||||
return await Promise.all(
|
||||
return await promiseAll(
|
||||
data.inventoryItems.map(async (item) => {
|
||||
const inventoryItem = await inventoryService!.createInventoryItem({
|
||||
sku: item.sku!,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { InventoryItemDTO } from "@medusajs/types"
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
|
||||
export async function detachInventoryItems({
|
||||
container,
|
||||
@@ -21,7 +22,7 @@ export async function detachInventoryItems({
|
||||
return []
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
await promiseAll(
|
||||
data.inventoryItems.map(async ({ tag, inventoryItem }) => {
|
||||
return await productVariantInventoryService.detachInventoryItem(
|
||||
inventoryItem.id,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
|
||||
type ProductHandle = string
|
||||
type SalesChannelId = string
|
||||
@@ -34,7 +35,7 @@ export async function attachSalesChannelToProducts({
|
||||
}
|
||||
})
|
||||
|
||||
await Promise.all(
|
||||
await promiseAll(
|
||||
Array.from(salesChannelIdProductIdsMap.entries()).map(
|
||||
async ([salesChannelId, productIds]) => {
|
||||
return await salesChannelServiceTx.addProducts(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
|
||||
type ProductHandle = string
|
||||
type ShippingProfileId = string
|
||||
@@ -33,7 +34,7 @@ export async function attachShippingProfileToProducts({
|
||||
}
|
||||
})
|
||||
|
||||
await Promise.all(
|
||||
await promiseAll(
|
||||
Array.from(profileIdProductIdsMap.entries()).map(
|
||||
async ([profileId, productIds]) => {
|
||||
return await shippingProfileServiceTx.addProducts(profileId, productIds)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
|
||||
type ProductHandle = string
|
||||
type SalesChannelId = string
|
||||
@@ -32,7 +33,7 @@ export async function detachSalesChannelFromProducts({
|
||||
}
|
||||
})
|
||||
|
||||
await Promise.all(
|
||||
await promiseAll(
|
||||
Array.from(salesChannelIdProductIdsMap.entries()).map(
|
||||
async ([salesChannelId, productIds]) => {
|
||||
return await salesChannelServiceTx.removeProducts(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { WorkflowArguments } from "../../helper"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
|
||||
type ProductHandle = string
|
||||
type ShippingProfileId = string
|
||||
@@ -32,7 +33,7 @@ export async function detachShippingProfileFromProducts({
|
||||
}
|
||||
})
|
||||
|
||||
await Promise.all(
|
||||
await promiseAll(
|
||||
Array.from(profileIdProductIdsMap.entries()).map(
|
||||
async ([profileId, productIds]) => {
|
||||
return await shippingProfileServiceTx.removeProducts(
|
||||
|
||||
Reference in New Issue
Block a user