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:
1 parent
ccc8588ea3
commit
91499081f4
5 files changed
+45
-111
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/promotion": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore(): Promotion auto managed joiner config
|
||||||
+40
@@ -35,8 +35,12 @@ moduleIntegrationTestRunner({
|
|||||||
|
|
||||||
expect(Object.keys(linkable)).toEqual([
|
expect(Object.keys(linkable)).toEqual([
|
||||||
"promotion",
|
"promotion",
|
||||||
|
"applicationMethod",
|
||||||
"campaign",
|
"campaign",
|
||||||
|
"campaignBudget",
|
||||||
|
"campaignBudgetUsage",
|
||||||
"promotionRule",
|
"promotionRule",
|
||||||
|
"promotionRuleValue",
|
||||||
])
|
])
|
||||||
|
|
||||||
Object.keys(linkable).forEach((key) => {
|
Object.keys(linkable).forEach((key) => {
|
||||||
@@ -53,6 +57,15 @@ moduleIntegrationTestRunner({
|
|||||||
field: "promotion",
|
field: "promotion",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
applicationMethod: {
|
||||||
|
id: {
|
||||||
|
linkable: "application_method_id",
|
||||||
|
entity: "ApplicationMethod",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "promotion",
|
||||||
|
field: "applicationMethod",
|
||||||
|
},
|
||||||
|
},
|
||||||
campaign: {
|
campaign: {
|
||||||
id: {
|
id: {
|
||||||
linkable: "campaign_id",
|
linkable: "campaign_id",
|
||||||
@@ -62,6 +75,24 @@ moduleIntegrationTestRunner({
|
|||||||
field: "campaign",
|
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: {
|
promotionRule: {
|
||||||
id: {
|
id: {
|
||||||
linkable: "promotion_rule_id",
|
linkable: "promotion_rule_id",
|
||||||
@@ -71,6 +102,15 @@ moduleIntegrationTestRunner({
|
|||||||
field: "promotionRule",
|
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,
|
FindConfig,
|
||||||
InferEntityType,
|
InferEntityType,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
PromotionDTO,
|
PromotionDTO,
|
||||||
PromotionTypes,
|
PromotionTypes,
|
||||||
@@ -62,7 +61,6 @@ import {
|
|||||||
validateApplicationMethodAttributes,
|
validateApplicationMethodAttributes,
|
||||||
validatePromotionRuleAttributes,
|
validatePromotionRuleAttributes,
|
||||||
} from "@utils"
|
} from "@utils"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
import { CreatePromotionRuleValueDTO } from "../types/promotion-rule-value"
|
import { CreatePromotionRuleValueDTO } from "../types/promotion-rule-value"
|
||||||
import { buildPromotionRuleQueryFilterFromContext } from "../utils/compute-actions/build-promotion-rule-query-filter-from-context"
|
import { buildPromotionRuleQueryFilterFromContext } from "../utils/compute-actions/build-promotion-rule-query-filter-from-context"
|
||||||
|
|
||||||
@@ -147,10 +145,6 @@ export default class PromotionModuleService
|
|||||||
this.campaignBudgetUsageService_ = campaignBudgetUsageService
|
this.campaignBudgetUsageService_ = campaignBudgetUsageService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
@InjectManager()
|
@InjectManager()
|
||||||
async listActivePromotions(
|
async listActivePromotions(
|
||||||
filters?: FilterablePromotionProps,
|
filters?: FilterablePromotionProps,
|
||||||
|
|||||||
Reference in new issue
Block a user