chore(): Promotion auto managed joiner config (#14115)
* chore(): Promotion auto managed joiner config * Create light-trainers-tie.md * chore(): align tests expectactions
This commit is contained in:
committed by
GitHub
parent
ccc8588ea3
commit
91499081f4
@@ -35,8 +35,12 @@ moduleIntegrationTestRunner({
|
||||
|
||||
expect(Object.keys(linkable)).toEqual([
|
||||
"promotion",
|
||||
"applicationMethod",
|
||||
"campaign",
|
||||
"campaignBudget",
|
||||
"campaignBudgetUsage",
|
||||
"promotionRule",
|
||||
"promotionRuleValue",
|
||||
])
|
||||
|
||||
Object.keys(linkable).forEach((key) => {
|
||||
@@ -53,6 +57,15 @@ moduleIntegrationTestRunner({
|
||||
field: "promotion",
|
||||
},
|
||||
},
|
||||
applicationMethod: {
|
||||
id: {
|
||||
linkable: "application_method_id",
|
||||
entity: "ApplicationMethod",
|
||||
primaryKey: "id",
|
||||
serviceName: "promotion",
|
||||
field: "applicationMethod",
|
||||
},
|
||||
},
|
||||
campaign: {
|
||||
id: {
|
||||
linkable: "campaign_id",
|
||||
@@ -62,6 +75,24 @@ moduleIntegrationTestRunner({
|
||||
field: "campaign",
|
||||
},
|
||||
},
|
||||
campaignBudget: {
|
||||
id: {
|
||||
linkable: "campaign_budget_id",
|
||||
entity: "CampaignBudget",
|
||||
primaryKey: "id",
|
||||
serviceName: "promotion",
|
||||
field: "campaignBudget",
|
||||
},
|
||||
},
|
||||
campaignBudgetUsage: {
|
||||
id: {
|
||||
linkable: "campaign_budget_usage_id",
|
||||
entity: "CampaignBudgetUsage",
|
||||
primaryKey: "id",
|
||||
serviceName: "promotion",
|
||||
field: "campaignBudgetUsage",
|
||||
},
|
||||
},
|
||||
promotionRule: {
|
||||
id: {
|
||||
linkable: "promotion_rule_id",
|
||||
@@ -71,6 +102,15 @@ moduleIntegrationTestRunner({
|
||||
field: "promotionRule",
|
||||
},
|
||||
},
|
||||
promotionRuleValue: {
|
||||
id: {
|
||||
linkable: "promotion_rule_value_id",
|
||||
entity: "PromotionRuleValue",
|
||||
primaryKey: "id",
|
||||
serviceName: "promotion",
|
||||
field: "promotionRuleValue",
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { defineJoinerConfig, Modules } from "@medusajs/framework/utils"
|
||||
import { Campaign, Promotion, PromotionRule } from "@models"
|
||||
import { default as schema } from "./schema"
|
||||
|
||||
export const joinerConfig = defineJoinerConfig(Modules.PROMOTION, {
|
||||
schema,
|
||||
models: [Promotion, Campaign, PromotionRule],
|
||||
})
|
||||
@@ -1,97 +0,0 @@
|
||||
export default `
|
||||
enum PromotionTypeValues {
|
||||
standard
|
||||
buyget
|
||||
}
|
||||
|
||||
enum PromotionRuleOperatorValues {
|
||||
gt
|
||||
lt
|
||||
eq
|
||||
ne
|
||||
in
|
||||
lte
|
||||
gte
|
||||
}
|
||||
|
||||
enum CampaignBudgetTypeValues {
|
||||
spend
|
||||
usage
|
||||
}
|
||||
|
||||
enum ApplicationMethodTypeValues {
|
||||
fixed
|
||||
percentage
|
||||
}
|
||||
|
||||
enum ApplicationMethodTargetTypeValues {
|
||||
order
|
||||
shipping_methods
|
||||
items
|
||||
}
|
||||
|
||||
enum ApplicationMethodAllocationValues {
|
||||
each
|
||||
across
|
||||
once
|
||||
}
|
||||
|
||||
type Promotion {
|
||||
id: ID!
|
||||
code: String
|
||||
type: PromotionTypeValues
|
||||
is_automatic: Boolean
|
||||
application_method: ApplicationMethod
|
||||
rules: [PromotionRule]
|
||||
campaign_id: String
|
||||
campaign: Campaign
|
||||
}
|
||||
|
||||
type PromotionRule {
|
||||
id: ID!
|
||||
description: String
|
||||
attribute: String
|
||||
operator: PromotionRuleOperatorValues
|
||||
values: [PromotionRuleValue!]!
|
||||
}
|
||||
|
||||
type PromotionRuleValue {
|
||||
id: ID!
|
||||
value: String
|
||||
}
|
||||
|
||||
type Campaign {
|
||||
id: ID!
|
||||
name: String
|
||||
description: String
|
||||
campaign_identifier: String
|
||||
starts_at: DateTime
|
||||
ends_at: DateTime
|
||||
budget: CampaignBudget
|
||||
promotions: [Promotion]
|
||||
}
|
||||
|
||||
type CampaignBudget {
|
||||
id: ID!
|
||||
type: CampaignBudgetTypeValues
|
||||
limit: Int
|
||||
used: Int
|
||||
currency_code: String
|
||||
}
|
||||
|
||||
type ApplicationMethod {
|
||||
id: ID!
|
||||
type: ApplicationMethodTypeValues
|
||||
target_type: ApplicationMethodTargetTypeValues
|
||||
allocation: ApplicationMethodAllocationValues
|
||||
value: Float
|
||||
currency_code: String
|
||||
max_quantity: Int
|
||||
buy_rules_min_quantity: Int
|
||||
apply_to_quantity: Int
|
||||
promotion: Promotion
|
||||
target_rules: [PromotionRule]
|
||||
buy_rules: [PromotionRule]
|
||||
}
|
||||
|
||||
`
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
FindConfig,
|
||||
InferEntityType,
|
||||
InternalModuleDeclaration,
|
||||
ModuleJoinerConfig,
|
||||
ModulesSdkTypes,
|
||||
PromotionDTO,
|
||||
PromotionTypes,
|
||||
@@ -62,7 +61,6 @@ import {
|
||||
validateApplicationMethodAttributes,
|
||||
validatePromotionRuleAttributes,
|
||||
} from "@utils"
|
||||
import { joinerConfig } from "../joiner-config"
|
||||
import { CreatePromotionRuleValueDTO } from "../types/promotion-rule-value"
|
||||
import { buildPromotionRuleQueryFilterFromContext } from "../utils/compute-actions/build-promotion-rule-query-filter-from-context"
|
||||
|
||||
@@ -147,10 +145,6 @@ export default class PromotionModuleService
|
||||
this.campaignBudgetUsageService_ = campaignBudgetUsageService
|
||||
}
|
||||
|
||||
__joinerConfig(): ModuleJoinerConfig {
|
||||
return joinerConfig
|
||||
}
|
||||
|
||||
@InjectManager()
|
||||
async listActivePromotions(
|
||||
filters?: FilterablePromotionProps,
|
||||
|
||||
Reference in New Issue
Block a user