feat(utils,types): campaigns and campaign budgets + services CRUD (#6063)
* chore: added item/shipping adjustments for order/items/shipping_methods * chore: add validation for order type and target rules * chore: add comment for applied promotions * chore: add shipping method and item adjustments * chore: include applied promotions to items/shipping_method for each case * chore: handle case for items across and order to consider existing applications * chore: handle case for applied promo values to shipping => across * chore: added changeset * chore: update return of function * chore: campaigns and campaign budgets + services CRUD * Apply suggestions from code review Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> * chore: minor refactor * chore: added single/bulk interfaces * Apply suggestions from code review Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> * chore: use DAL date entity * chore: align nullable * Update packages/promotion/src/models/promotion-rule.ts * chore: fix types * chore: review changes * Update packages/promotion/src/utils/compute-actions/shipping-methods.ts Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
This commit is contained in:
co-authored by
Oli Juhl
Philip Korsholm
parent
b782d3bcb7
commit
fade8ea7bf
@@ -0,0 +1,16 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export type CampaignBudgetTypeValues = "spend" | "usage"
|
||||
|
||||
export interface CampaignBudgetDTO {
|
||||
id: string
|
||||
type?: CampaignBudgetTypeValues
|
||||
limit?: string | null
|
||||
used?: string
|
||||
}
|
||||
|
||||
export interface FilterableCampaignBudgetProps
|
||||
extends BaseFilterable<FilterableCampaignBudgetProps> {
|
||||
id?: string[]
|
||||
type?: string[]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { CampaignBudgetDTO } from "./campaign-budget"
|
||||
|
||||
export interface CampaignDTO {
|
||||
id: string
|
||||
name?: string
|
||||
description?: string
|
||||
currency?: string
|
||||
campaign_identifier?: string
|
||||
starts_at?: Date
|
||||
ends_at?: Date
|
||||
budget?: CampaignBudgetDTO
|
||||
}
|
||||
|
||||
export interface FilterableCampaignProps
|
||||
extends BaseFilterable<FilterableCampaignProps> {
|
||||
id?: string[]
|
||||
campaign_identifier?: string[]
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from "./application-method"
|
||||
export * from "./campaign"
|
||||
export * from "./campaign-budget"
|
||||
export * from "./compute-actions"
|
||||
export * from "./promotion"
|
||||
export * from "./promotion-rule"
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./common"
|
||||
export * from "./mutations"
|
||||
export * from "./service"
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { CampaignBudgetTypeValues } from "./common"
|
||||
|
||||
export interface CreateCampaignBudgetDTO {
|
||||
type: CampaignBudgetTypeValues
|
||||
limit: number | null
|
||||
used?: number
|
||||
}
|
||||
|
||||
export interface UpdateCampaignBudgetDTO {
|
||||
id: string
|
||||
type?: CampaignBudgetTypeValues
|
||||
limit?: number | null
|
||||
used?: number
|
||||
}
|
||||
|
||||
export interface CreateCampaignDTO {
|
||||
name: string
|
||||
description?: string
|
||||
currency?: string
|
||||
campaign_identifier: string
|
||||
starts_at: Date
|
||||
ends_at: Date
|
||||
budget?: CreateCampaignBudgetDTO
|
||||
}
|
||||
|
||||
export interface UpdateCampaignDTO {
|
||||
id: string
|
||||
name?: string
|
||||
description?: string
|
||||
currency?: string
|
||||
campaign_identifier?: string
|
||||
starts_at?: Date
|
||||
ends_at?: Date
|
||||
budget?: Omit<UpdateCampaignBudgetDTO, "id">
|
||||
}
|
||||
@@ -2,16 +2,20 @@ import { FindConfig } from "../common"
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import {
|
||||
CampaignDTO,
|
||||
ComputeActionContext,
|
||||
ComputeActions,
|
||||
CreatePromotionDTO,
|
||||
CreatePromotionRuleDTO,
|
||||
FilterableCampaignProps,
|
||||
FilterablePromotionProps,
|
||||
PromotionDTO,
|
||||
RemovePromotionRuleDTO,
|
||||
UpdatePromotionDTO,
|
||||
} from "./common"
|
||||
|
||||
import { CreateCampaignDTO, UpdateCampaignDTO } from "./mutations"
|
||||
|
||||
export interface IPromotionModuleService extends IModuleService {
|
||||
computeActions(
|
||||
promotionCodesToApply: string[],
|
||||
@@ -24,11 +28,21 @@ export interface IPromotionModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<PromotionDTO[]>
|
||||
|
||||
create(
|
||||
data: CreatePromotionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<PromotionDTO>
|
||||
|
||||
update(
|
||||
data: UpdatePromotionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PromotionDTO[]>
|
||||
|
||||
update(
|
||||
data: UpdatePromotionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<PromotionDTO>
|
||||
|
||||
list(
|
||||
filters?: FilterablePromotionProps,
|
||||
config?: FindConfig<PromotionDTO>,
|
||||
@@ -42,6 +56,7 @@ export interface IPromotionModuleService extends IModuleService {
|
||||
): Promise<PromotionDTO>
|
||||
|
||||
delete(ids: string[], sharedContext?: Context): Promise<void>
|
||||
delete(ids: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
addPromotionRules(
|
||||
promotionId: string,
|
||||
@@ -66,4 +81,39 @@ export interface IPromotionModuleService extends IModuleService {
|
||||
rulesData: RemovePromotionRuleDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PromotionDTO>
|
||||
|
||||
createCampaigns(
|
||||
data: CreateCampaignDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<CampaignDTO>
|
||||
|
||||
createCampaigns(
|
||||
data: CreateCampaignDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<CampaignDTO[]>
|
||||
|
||||
updateCampaigns(
|
||||
data: UpdateCampaignDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<CampaignDTO[]>
|
||||
|
||||
updateCampaigns(
|
||||
data: UpdateCampaignDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<CampaignDTO>
|
||||
|
||||
listCampaigns(
|
||||
filters?: FilterableCampaignProps,
|
||||
config?: FindConfig<CampaignDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<CampaignDTO[]>
|
||||
|
||||
retrieveCampaign(
|
||||
id: string,
|
||||
config?: FindConfig<CampaignDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<CampaignDTO>
|
||||
|
||||
deleteCampaigns(ids: string[], sharedContext?: Context): Promise<void>
|
||||
deleteCampaigns(ids: string, sharedContext?: Context): Promise<void>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user