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:
co-authored by
Harminder Virk
parent
5aa62e59e4
commit
617a5972bf
@@ -1,19 +1,11 @@
|
||||
import {
|
||||
buildEntitiesNameToLinkableKeysMap,
|
||||
defineJoinerConfig,
|
||||
MapToConfig,
|
||||
Modules,
|
||||
} from "@medusajs/utils"
|
||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
||||
import { Campaign, Promotion, PromotionRule } from "@models"
|
||||
|
||||
export const joinerConfig = defineJoinerConfig(Modules.PROMOTION, {
|
||||
entityQueryingConfig: [Promotion, Campaign, PromotionRule],
|
||||
models: [Promotion, Campaign, PromotionRule],
|
||||
linkableKeys: {
|
||||
promotion_id: Promotion.name,
|
||||
campaign_id: Campaign.name,
|
||||
promotion_rule_id: PromotionRule.name,
|
||||
},
|
||||
})
|
||||
|
||||
export const entityNameToLinkableKeysMap: MapToConfig =
|
||||
buildEntitiesNameToLinkableKeysMap(joinerConfig.linkableKeys)
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
MedusaService,
|
||||
ModulesSdkUtils,
|
||||
PromotionType,
|
||||
transformPropertiesToBigNumber,
|
||||
} from "@medusajs/utils"
|
||||
@@ -54,7 +53,7 @@ import {
|
||||
validateApplicationMethodAttributes,
|
||||
validatePromotionRuleAttributes,
|
||||
} from "@utils"
|
||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||
import { joinerConfig } from "../joiner-config"
|
||||
import { CreatePromotionRuleValueDTO } from "../types/promotion-rule-value"
|
||||
|
||||
type InjectedDependencies = {
|
||||
@@ -75,17 +74,14 @@ export default class PromotionModuleService
|
||||
CampaignBudget: { dto: PromotionTypes.CampaignBudgetDTO }
|
||||
PromotionRule: { dto: PromotionTypes.PromotionRuleDTO }
|
||||
PromotionRuleValue: { dto: PromotionTypes.PromotionRuleValueDTO }
|
||||
}>(
|
||||
{
|
||||
Promotion,
|
||||
ApplicationMethod,
|
||||
Campaign,
|
||||
CampaignBudget,
|
||||
PromotionRule,
|
||||
PromotionRuleValue,
|
||||
},
|
||||
entityNameToLinkableKeysMap
|
||||
)
|
||||
}>({
|
||||
Promotion,
|
||||
ApplicationMethod,
|
||||
Campaign,
|
||||
CampaignBudget,
|
||||
PromotionRule,
|
||||
PromotionRuleValue,
|
||||
})
|
||||
implements PromotionTypes.IPromotionModuleService
|
||||
{
|
||||
protected baseRepository_: DAL.RepositoryService
|
||||
|
||||
Reference in New Issue
Block a user