feat: refactor module joiner config and links generation (#7859)
* feat: refactor module joiner config and links generation * improve typings * WIP * WIP * WIP * rename type file * create link config * finish typings and add utils * improve links * WIP typings * finalize ExportModule utils * finalize ExportModule utils * fix: dml tests * improve and fixes * simplify typings with id changes * add toJSON * multiple fixes and entity builder fixes * fix currency searchable * fix tests * medusa service refactoring * cleanup * cleanup and fixes * make module name optional * renaming --------- Co-authored-by: Harminder Virk <virk.officials@gmail.com>
This commit is contained in:
committed by
GitHub
parent
5aa62e59e4
commit
617a5972bf
@@ -1,11 +1,7 @@
|
||||
import {
|
||||
buildEntitiesNameToLinkableKeysMap,
|
||||
defineJoinerConfig,
|
||||
MapToConfig,
|
||||
Modules,
|
||||
} from "@medusajs/utils"
|
||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
||||
|
||||
export const joinerConfig = defineJoinerConfig(Modules.PRODUCT, {
|
||||
primaryKeys: ["id", "handle"],
|
||||
// This module provides more alias than the default config builder
|
||||
alias: [
|
||||
{
|
||||
@@ -58,6 +54,3 @@ export const joinerConfig = defineJoinerConfig(Modules.PRODUCT, {
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
export const entityNameToLinkableKeysMap: MapToConfig =
|
||||
buildEntitiesNameToLinkableKeysMap(joinerConfig.linkableKeys)
|
||||
|
||||
@@ -51,7 +51,7 @@ import {
|
||||
UpdateTypeInput,
|
||||
} from "../types"
|
||||
import { eventBuilders } from "../utils"
|
||||
import { entityNameToLinkableKeysMap, joinerConfig } from "./../joiner-config"
|
||||
import { joinerConfig } from "./../joiner-config"
|
||||
|
||||
type InjectedDependencies = {
|
||||
baseRepository: DAL.RepositoryService
|
||||
@@ -90,18 +90,15 @@ export default class ProductModuleService
|
||||
ProductVariant: {
|
||||
dto: ProductTypes.ProductVariantDTO
|
||||
}
|
||||
}>(
|
||||
{
|
||||
Product,
|
||||
ProductCategory,
|
||||
ProductCollection,
|
||||
ProductOption,
|
||||
ProductTag,
|
||||
ProductType,
|
||||
ProductVariant,
|
||||
},
|
||||
entityNameToLinkableKeysMap
|
||||
)
|
||||
}>({
|
||||
Product,
|
||||
ProductCategory,
|
||||
ProductCollection,
|
||||
ProductOption,
|
||||
ProductTag,
|
||||
ProductType,
|
||||
ProductVariant,
|
||||
})
|
||||
implements ProductTypes.IProductModuleService
|
||||
{
|
||||
protected baseRepository_: DAL.RepositoryService
|
||||
|
||||
@@ -18,9 +18,10 @@ type NormalizedFilterableProductProps = ProductTypes.FilterableProductProps & {
|
||||
}
|
||||
}
|
||||
|
||||
export default class ProductService extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||
export default class ProductService extends ModulesSdkUtils.MedusaInternalService<
|
||||
InjectedDependencies,
|
||||
Product
|
||||
)<Product> {
|
||||
>(Product) {
|
||||
protected readonly productRepository_: DAL.RepositoryService<Product>
|
||||
|
||||
constructor({ productRepository }: InjectedDependencies) {
|
||||
|
||||
Reference in New Issue
Block a user