feat(product, pricing, utils): Transaction issues and reference issues (#5533)
* feat(product, pricing, utils): Transaction issues and reference issues * fixes decorators * cleanup * fix product module upsert * fix missing active manager * increase timeout * revert package.json * WIP * try another node version based on findings with memory issues with jest introduced after 16.11 but fixed in 21 * re add bail * fix variant options * chore: bulk create pricing * chore: workflow bulk * Create big-chefs-dream.md * fix missing update for upserty * Add integration tests for product options upsert * rm unnecessary return * fix product prices workflow issue * cleanup * fix flag * fix model --------- Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com> Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
co-authored by
Carlos R. L. Rodrigues
Carlos R. L. Rodrigues
Riqwan Thamir
parent
57c3a24ad3
commit
f88d75b0a7
@@ -9,8 +9,6 @@ import {
|
||||
MedusaError,
|
||||
ModulesSdkUtils,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { shouldForceTransaction } from "../utils"
|
||||
import { ProductCategoryServiceTypes } from "../types"
|
||||
|
||||
type InjectedDependencies = {
|
||||
@@ -114,10 +112,7 @@ export default class ProductCategoryService<
|
||||
)) as [TEntity[], number]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(
|
||||
shouldForceTransaction,
|
||||
"productCategoryRepository_"
|
||||
)
|
||||
@InjectTransactionManager("productCategoryRepository_")
|
||||
async create(
|
||||
data: ProductCategoryServiceTypes.CreateProductCategoryDTO,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -127,10 +122,7 @@ export default class ProductCategoryService<
|
||||
).create(data, sharedContext)) as TEntity
|
||||
}
|
||||
|
||||
@InjectTransactionManager(
|
||||
shouldForceTransaction,
|
||||
"productCategoryRepository_"
|
||||
)
|
||||
@InjectTransactionManager("productCategoryRepository_")
|
||||
async update(
|
||||
id: string,
|
||||
data: ProductCategoryServiceTypes.UpdateProductCategoryDTO,
|
||||
@@ -141,10 +133,7 @@ export default class ProductCategoryService<
|
||||
).update(id, data, sharedContext)) as TEntity
|
||||
}
|
||||
|
||||
@InjectTransactionManager(
|
||||
shouldForceTransaction,
|
||||
"productCategoryRepository_"
|
||||
)
|
||||
@InjectTransactionManager("productCategoryRepository_")
|
||||
async delete(
|
||||
id: string,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -6,8 +6,6 @@ import {
|
||||
ModulesSdkUtils,
|
||||
retrieveEntity,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { shouldForceTransaction } from "../utils"
|
||||
import { ProductCollectionRepository } from "../repositories"
|
||||
|
||||
import { ProductCollection } from "@models"
|
||||
@@ -85,10 +83,7 @@ export default class ProductCollectionService<
|
||||
return queryOptions
|
||||
}
|
||||
|
||||
@InjectTransactionManager(
|
||||
shouldForceTransaction,
|
||||
"productCollectionRepository_"
|
||||
)
|
||||
@InjectTransactionManager("productCollectionRepository_")
|
||||
async create(
|
||||
data: ProductTypes.CreateProductCollectionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -98,10 +93,7 @@ export default class ProductCollectionService<
|
||||
).create(data, sharedContext)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(
|
||||
shouldForceTransaction,
|
||||
"productCollectionRepository_"
|
||||
)
|
||||
@InjectTransactionManager("productCollectionRepository_")
|
||||
async update(
|
||||
data: ProductTypes.UpdateProductCollectionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -111,10 +103,7 @@ export default class ProductCollectionService<
|
||||
).update(data, sharedContext)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(
|
||||
shouldForceTransaction,
|
||||
"productCollectionRepository_"
|
||||
)
|
||||
@InjectTransactionManager("productCollectionRepository_")
|
||||
async delete(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Image } from "@models"
|
||||
import { Context, DAL } from "@medusajs/types"
|
||||
import { InjectTransactionManager, MedusaContext } from "@medusajs/utils"
|
||||
import { doNotForceTransaction } from "../utils"
|
||||
import { ProductImageRepository } from "@repositories"
|
||||
|
||||
type InjectedDependencies = {
|
||||
@@ -15,7 +14,7 @@ export default class ProductImageService<TEntity extends Image = Image> {
|
||||
this.productImageRepository_ = productImageRepository
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productImageRepository_")
|
||||
@InjectTransactionManager("productImageRepository_")
|
||||
async upsert(
|
||||
urls: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -62,8 +62,6 @@ import {
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { shouldForceTransaction } from "../utils"
|
||||
import {
|
||||
entityNameToLinkableKeysMap,
|
||||
joinerConfig,
|
||||
@@ -277,7 +275,7 @@ export default class ProductModuleService<
|
||||
return [JSON.parse(JSON.stringify(tags)), count]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async createTags(
|
||||
data: ProductTypes.CreateProductTagDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -290,7 +288,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productTags))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async updateTags(
|
||||
data: ProductTypes.UpdateProductTagDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -303,7 +301,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productTags))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async deleteTags(
|
||||
productTagIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -356,7 +354,7 @@ export default class ProductModuleService<
|
||||
return [JSON.parse(JSON.stringify(types)), count]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async createTypes(
|
||||
data: ProductTypes.CreateProductTypeDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -369,7 +367,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productTypes))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async updateTypes(
|
||||
data: ProductTypes.UpdateProductTypeDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -382,7 +380,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productTypes))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async deleteTypes(
|
||||
productTypeIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -436,7 +434,7 @@ export default class ProductModuleService<
|
||||
return [JSON.parse(JSON.stringify(productOptions)), count]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async createOptions(
|
||||
data: ProductTypes.CreateProductOptionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -453,7 +451,7 @@ export default class ProductModuleService<
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async updateOptions(
|
||||
data: ProductTypes.UpdateProductOptionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -470,7 +468,7 @@ export default class ProductModuleService<
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async deleteOptions(
|
||||
productOptionIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -523,7 +521,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(collections))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async createCollections(
|
||||
data: ProductTypes.CreateProductCollectionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -543,7 +541,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productCollections))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async updateCollections(
|
||||
data: ProductTypes.UpdateProductCollectionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -563,7 +561,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productCollections))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async deleteCollections(
|
||||
productCollectionIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -611,7 +609,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(categories))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async createCategory(
|
||||
data: CreateProductCategoryDTO,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -629,7 +627,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productCategory))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async updateCategory(
|
||||
categoryId: string,
|
||||
data: UpdateProductCategoryDTO,
|
||||
@@ -649,7 +647,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(productCategory))
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async deleteCategory(
|
||||
categoryId: string,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -677,6 +675,7 @@ export default class ProductModuleService<
|
||||
return JSON.parse(JSON.stringify(categories))
|
||||
}
|
||||
|
||||
@InjectManager("baseRepository_")
|
||||
async create(
|
||||
data: ProductTypes.CreateProductDTO[],
|
||||
sharedContext?: Context
|
||||
@@ -698,6 +697,7 @@ export default class ProductModuleService<
|
||||
return createdProducts
|
||||
}
|
||||
|
||||
@InjectManager("baseRepository_")
|
||||
async update(
|
||||
data: ProductTypes.UpdateProductDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -720,7 +720,7 @@ export default class ProductModuleService<
|
||||
return updatedProducts
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
protected async create_(
|
||||
data: ProductTypes.CreateProductDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -829,7 +829,7 @@ export default class ProductModuleService<
|
||||
return products
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
protected async update_(
|
||||
data: ProductTypes.UpdateProductDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -859,14 +859,11 @@ export default class ProductModuleService<
|
||||
)[]
|
||||
>()
|
||||
|
||||
const productOptionsMap = new Map<
|
||||
string,
|
||||
ProductTypes.CreateProductOptionDTO[]
|
||||
>()
|
||||
const productOptionsMap = new Map<string, TProductOption[]>()
|
||||
|
||||
const productsData = await Promise.all(
|
||||
data.map(async (product) => {
|
||||
const { variants, options, ...productData } = product
|
||||
const { variants, ...productData } = product
|
||||
|
||||
if (!isDefined(productData.id)) {
|
||||
throw new MedusaError(
|
||||
@@ -876,7 +873,6 @@ export default class ProductModuleService<
|
||||
}
|
||||
|
||||
productVariantsMap.set(productData.id, variants ?? [])
|
||||
productOptionsMap.set(productData.id, options ?? [])
|
||||
|
||||
if (productData.is_giftcard) {
|
||||
productData.discountable = false
|
||||
@@ -894,6 +890,15 @@ export default class ProductModuleService<
|
||||
productData,
|
||||
sharedContext
|
||||
)
|
||||
await this.upsertAndAssignOptionsToProductData(
|
||||
productData,
|
||||
sharedContext
|
||||
)
|
||||
|
||||
productOptionsMap.set(
|
||||
productData.id,
|
||||
(productData.options ?? []) as TProductOption[]
|
||||
)
|
||||
|
||||
return productData as UpdateProductDTO
|
||||
})
|
||||
@@ -908,20 +913,6 @@ export default class ProductModuleService<
|
||||
products.map((product) => [product.id, product])
|
||||
)
|
||||
|
||||
const productOptionsData = [...productOptionsMap]
|
||||
.map(([id, options]) =>
|
||||
options.map((option) => ({
|
||||
...option,
|
||||
product: productByIdMap.get(id)!,
|
||||
}))
|
||||
)
|
||||
.flat()
|
||||
|
||||
const productOptions = await this.productOptionService_.create(
|
||||
productOptionsData,
|
||||
sharedContext
|
||||
)
|
||||
|
||||
const productVariantIdsToDelete: string[] = []
|
||||
const productVariantsToCreateMap = new Map<
|
||||
string,
|
||||
@@ -937,6 +928,7 @@ export default class ProductModuleService<
|
||||
const variantsToCreate: ProductTypes.CreateProductVariantDTO[] = []
|
||||
const variantsToUpdate: ProductTypes.UpdateProductVariantDTO[] = []
|
||||
const existingVariants = existingProductVariantsMap.get(productId)
|
||||
const productOptions = productOptionsMap.get(productId)!
|
||||
|
||||
variants.forEach((variant) => {
|
||||
const isVariantIdDefined = "id" in variant && isDefined(variant.id)
|
||||
@@ -955,7 +947,7 @@ export default class ProductModuleService<
|
||||
}
|
||||
})
|
||||
|
||||
if (variantOptions) {
|
||||
if (variantOptions?.length) {
|
||||
variant.options = variantOptions
|
||||
}
|
||||
})
|
||||
@@ -1010,6 +1002,18 @@ export default class ProductModuleService<
|
||||
return products
|
||||
}
|
||||
|
||||
protected async upsertAndAssignOptionsToProductData(
|
||||
productData: ProductTypes.CreateProductDTO | ProductTypes.UpdateProductDTO,
|
||||
sharedContext: Context = {}
|
||||
) {
|
||||
if (productData.options?.length) {
|
||||
productData.options = await this.productOptionService_.upsert(
|
||||
productData.options,
|
||||
sharedContext
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
protected async upsertAndAssignImagesToProductData(
|
||||
productData: ProductTypes.CreateProductDTO | ProductTypes.UpdateProductDTO,
|
||||
sharedContext: Context = {}
|
||||
@@ -1060,7 +1064,7 @@ export default class ProductModuleService<
|
||||
}
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async delete(
|
||||
productIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -1075,6 +1079,7 @@ export default class ProductModuleService<
|
||||
)
|
||||
}
|
||||
|
||||
@InjectManager("baseRepository_")
|
||||
async softDelete<
|
||||
TReturnableLinkableKeys extends string = Lowercase<
|
||||
keyof typeof LinkableKeys
|
||||
@@ -1116,7 +1121,7 @@ export default class ProductModuleService<
|
||||
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
protected async softDelete_(
|
||||
productIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -1124,6 +1129,7 @@ export default class ProductModuleService<
|
||||
return await this.productService_.softDelete(productIds, sharedContext)
|
||||
}
|
||||
|
||||
@InjectManager("baseRepository_")
|
||||
async restore<
|
||||
TReturnableLinkableKeys extends string = Lowercase<
|
||||
keyof typeof LinkableKeys
|
||||
@@ -1152,7 +1158,7 @@ export default class ProductModuleService<
|
||||
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0
|
||||
}
|
||||
|
||||
@InjectManager("baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async restoreVariants<
|
||||
TReturnableLinkableKeys extends string = Lowercase<
|
||||
keyof typeof LinkableKeys
|
||||
@@ -1179,7 +1185,7 @@ export default class ProductModuleService<
|
||||
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async restore_(
|
||||
productIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -2,15 +2,13 @@ import { ProductOption } from "@models"
|
||||
import { Context, DAL, FindConfig, ProductTypes } from "@medusajs/types"
|
||||
import { ProductOptionRepository } from "@repositories"
|
||||
import {
|
||||
InjectTransactionManager,
|
||||
InjectManager,
|
||||
InjectTransactionManager,
|
||||
MedusaContext,
|
||||
ModulesSdkUtils,
|
||||
retrieveEntity,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { doNotForceTransaction, shouldForceTransaction } from "../utils"
|
||||
|
||||
type InjectedDependencies = {
|
||||
productOptionRepository: DAL.RepositoryService
|
||||
}
|
||||
@@ -80,7 +78,7 @@ export default class ProductOptionService<
|
||||
return queryOptions
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "productOptionRepository_")
|
||||
@InjectTransactionManager("productOptionRepository_")
|
||||
async create(
|
||||
data: ProductTypes.CreateProductOptionOnlyDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -92,7 +90,7 @@ export default class ProductOptionService<
|
||||
})) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "productOptionRepository_")
|
||||
@InjectTransactionManager("productOptionRepository_")
|
||||
async update(
|
||||
data: ProductTypes.UpdateProductOptionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -102,11 +100,22 @@ export default class ProductOptionService<
|
||||
).update(data, sharedContext)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productOptionRepository_")
|
||||
@InjectTransactionManager("productOptionRepository_")
|
||||
async delete(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<void> {
|
||||
return await this.productOptionRepository_.delete(ids, sharedContext)
|
||||
}
|
||||
|
||||
@InjectTransactionManager("productOptionRepository_")
|
||||
async upsert(
|
||||
data:
|
||||
| ProductTypes.CreateProductOptionDTO[]
|
||||
| ProductTypes.UpdateProductOptionDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<TEntity[]> {
|
||||
return (await (this.productOptionRepository_ as ProductOptionRepository)
|
||||
.upsert!(data, sharedContext)) as TEntity[]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@ import { ProductTag } from "@models"
|
||||
import {
|
||||
Context,
|
||||
CreateProductTagDTO,
|
||||
UpdateProductTagDTO,
|
||||
UpsertProductTagDTO,
|
||||
DAL,
|
||||
FindConfig,
|
||||
ProductTypes,
|
||||
UpdateProductTagDTO,
|
||||
UpsertProductTagDTO,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
InjectTransactionManager,
|
||||
InjectManager,
|
||||
InjectTransactionManager,
|
||||
MedusaContext,
|
||||
ModulesSdkUtils,
|
||||
retrieveEntity,
|
||||
} from "@medusajs/utils"
|
||||
import { ProductTagRepository } from "@repositories"
|
||||
|
||||
import { doNotForceTransaction, shouldForceTransaction } from "../utils"
|
||||
import { shouldForceTransaction } from "../utils"
|
||||
|
||||
type InjectedDependencies = {
|
||||
productTagRepository: DAL.RepositoryService
|
||||
@@ -84,7 +84,7 @@ export default class ProductTagService<
|
||||
return queryOptions
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "productTagRepository_")
|
||||
@InjectTransactionManager("productTagRepository_")
|
||||
async create(
|
||||
data: CreateProductTagDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -95,7 +95,7 @@ export default class ProductTagService<
|
||||
)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "productTagRepository_")
|
||||
@InjectTransactionManager("productTagRepository_")
|
||||
async update(
|
||||
data: UpdateProductTagDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -106,7 +106,7 @@ export default class ProductTagService<
|
||||
)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productTagRepository_")
|
||||
@InjectTransactionManager("productTagRepository_")
|
||||
async delete(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -114,7 +114,7 @@ export default class ProductTagService<
|
||||
await this.productTagRepository_.delete(ids, sharedContext)
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productTagRepository_")
|
||||
@InjectTransactionManager("productTagRepository_")
|
||||
async upsert(
|
||||
data: UpsertProductTagDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -2,11 +2,11 @@ import { ProductType } from "@models"
|
||||
import {
|
||||
Context,
|
||||
CreateProductTypeDTO,
|
||||
UpsertProductTypeDTO,
|
||||
UpdateProductTypeDTO,
|
||||
DAL,
|
||||
FindConfig,
|
||||
ProductTypes,
|
||||
UpdateProductTypeDTO,
|
||||
UpsertProductTypeDTO,
|
||||
} from "@medusajs/types"
|
||||
import { ProductTypeRepository } from "@repositories"
|
||||
import {
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
retrieveEntity,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { doNotForceTransaction, shouldForceTransaction } from "../utils"
|
||||
import { shouldForceTransaction } from "../utils"
|
||||
|
||||
type InjectedDependencies = {
|
||||
productTypeRepository: DAL.RepositoryService
|
||||
@@ -87,7 +87,7 @@ export default class ProductTypeService<
|
||||
return queryOptions
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productTypeRepository_")
|
||||
@InjectTransactionManager("productTypeRepository_")
|
||||
async upsert(
|
||||
types: UpsertProductTypeDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -96,7 +96,7 @@ export default class ProductTypeService<
|
||||
.upsert!(types, sharedContext)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "productTypeRepository_")
|
||||
@InjectTransactionManager("productTypeRepository_")
|
||||
async create(
|
||||
data: CreateProductTypeDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -107,7 +107,7 @@ export default class ProductTypeService<
|
||||
)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "productTypeRepository_")
|
||||
@InjectTransactionManager("productTypeRepository_")
|
||||
async update(
|
||||
data: UpdateProductTypeDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -118,7 +118,7 @@ export default class ProductTypeService<
|
||||
)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productTypeRepository_")
|
||||
@InjectTransactionManager("productTypeRepository_")
|
||||
async delete(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
|
||||
import { ProductVariantServiceTypes } from "../types/services"
|
||||
import ProductService from "./product"
|
||||
import { doNotForceTransaction } from "../utils"
|
||||
|
||||
type InjectedDependencies = {
|
||||
productVariantRepository: DAL.RepositoryService
|
||||
@@ -86,7 +85,7 @@ export default class ProductVariantService<
|
||||
)) as [TEntity[], number]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productVariantRepository_")
|
||||
@InjectTransactionManager("productVariantRepository_")
|
||||
async create(
|
||||
productOrId: TProduct | string,
|
||||
data: ProductTypes.CreateProductVariantOnlyDTO[],
|
||||
@@ -119,7 +118,7 @@ export default class ProductVariantService<
|
||||
})) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productVariantRepository_")
|
||||
@InjectTransactionManager("productVariantRepository_")
|
||||
async update(
|
||||
productOrId: TProduct | string,
|
||||
data: ProductVariantServiceTypes.UpdateProductVariantDTO[],
|
||||
@@ -145,7 +144,7 @@ export default class ProductVariantService<
|
||||
})) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productVariantRepository_")
|
||||
@InjectTransactionManager("productVariantRepository_")
|
||||
async delete(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -155,7 +154,7 @@ export default class ProductVariantService<
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productVariantRepository_")
|
||||
@InjectTransactionManager("productVariantRepository_")
|
||||
async softDelete(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -165,7 +164,7 @@ export default class ProductVariantService<
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productVariantRepository_")
|
||||
@InjectTransactionManager("productVariantRepository_")
|
||||
async restore(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -8,17 +8,16 @@ import {
|
||||
import {
|
||||
InjectManager,
|
||||
InjectTransactionManager,
|
||||
isDefined,
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
ModulesSdkUtils,
|
||||
ProductUtils,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { Product } from "@models"
|
||||
import { ProductRepository } from "@repositories"
|
||||
|
||||
import { ProductServiceTypes } from "../types/services"
|
||||
import { doNotForceTransaction } from "../utils"
|
||||
|
||||
type InjectedDependencies = {
|
||||
productRepository: DAL.RepositoryService
|
||||
@@ -118,7 +117,7 @@ export default class ProductService<TEntity extends Product = Product> {
|
||||
)) as [TEntity[], number]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productRepository_")
|
||||
@InjectTransactionManager("productRepository_")
|
||||
async create(
|
||||
data: ProductTypes.CreateProductOnlyDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -138,7 +137,7 @@ export default class ProductService<TEntity extends Product = Product> {
|
||||
)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productRepository_")
|
||||
@InjectTransactionManager("productRepository_")
|
||||
async update(
|
||||
data: ProductServiceTypes.UpdateProductDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -154,7 +153,7 @@ export default class ProductService<TEntity extends Product = Product> {
|
||||
)) as TEntity[]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productRepository_")
|
||||
@InjectTransactionManager("productRepository_")
|
||||
async delete(
|
||||
ids: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -164,7 +163,7 @@ export default class ProductService<TEntity extends Product = Product> {
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productRepository_")
|
||||
@InjectTransactionManager("productRepository_")
|
||||
async softDelete(
|
||||
productIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -174,7 +173,7 @@ export default class ProductService<TEntity extends Product = Product> {
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "productRepository_")
|
||||
@InjectTransactionManager("productRepository_")
|
||||
async restore(
|
||||
productIds: string[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
Reference in New Issue
Block a user