Merge branch 'feat/payment-module-models' into feat/payment-module-interfaces
This commit is contained in:
@@ -168,6 +168,11 @@ export interface CartShippingMethodDTO {
|
||||
*/
|
||||
id: string
|
||||
|
||||
/**
|
||||
* The ID of the associated cart
|
||||
*/
|
||||
cart_id: string
|
||||
|
||||
/**
|
||||
* The name of the shipping method
|
||||
*/
|
||||
@@ -336,6 +341,16 @@ export interface CartLineItemDTO {
|
||||
* @expandable
|
||||
*/
|
||||
adjustments?: LineItemAdjustmentLineDTO[]
|
||||
/**
|
||||
* The associated cart.
|
||||
*
|
||||
* @expandable
|
||||
*/
|
||||
cart: CartDTO
|
||||
/**
|
||||
* The ID of the associated cart.
|
||||
*/
|
||||
cart_id: string
|
||||
/**
|
||||
* Holds custom data in key-value pairs.
|
||||
*/
|
||||
@@ -470,12 +485,28 @@ export interface FilterableAddressProps
|
||||
id?: string | string[]
|
||||
}
|
||||
|
||||
export interface FilterableLineItemProps
|
||||
extends BaseFilterable<FilterableLineItemProps> {
|
||||
id?: string | string[]
|
||||
cart_id?: string | string[]
|
||||
title?: string
|
||||
variant_id?: string | string[]
|
||||
product_id?: string | string[]
|
||||
}
|
||||
|
||||
export interface FilterableShippingMethodProps
|
||||
extends BaseFilterable<FilterableShippingMethodProps> {
|
||||
id?: string | string[]
|
||||
cart_id?: string | string[]
|
||||
name?: string
|
||||
shipping_option_id?: string | string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Remove this in favor of CartDTO, when module is released
|
||||
* TODO: Remove this in favor of CartDTO, when module is released
|
||||
* @deprecated Use CartDTO instead
|
||||
*/
|
||||
|
||||
export type legacy__CartDTO = {
|
||||
export type legacy_CartDTO = {
|
||||
id?: string
|
||||
email?: string
|
||||
billing_address_id?: string
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { CartLineItemDTO } from "./common"
|
||||
|
||||
export interface UpsertAddressDTO {
|
||||
customer_id?: string
|
||||
company?: string
|
||||
@@ -23,17 +25,15 @@ export interface CreateCartDTO {
|
||||
region_id?: string
|
||||
customer_id?: string
|
||||
sales_channel_id?: string
|
||||
|
||||
email?: string
|
||||
currency_code: string
|
||||
|
||||
shipping_address_id?: string
|
||||
billing_address_id?: string
|
||||
|
||||
shipping_address?: CreateAddressDTO | UpdateAddressDTO
|
||||
billing_address?: CreateAddressDTO | UpdateAddressDTO
|
||||
|
||||
metadata?: Record<string, unknown>
|
||||
|
||||
items?: CreateLineItemDTO[]
|
||||
}
|
||||
|
||||
export interface UpdateCartDTO {
|
||||
@@ -54,7 +54,7 @@ export interface UpdateCartDTO {
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface CreateLineItemTaxLineDTO {
|
||||
export interface CreateTaxLineDTO {
|
||||
description?: string
|
||||
tax_rate_id?: string
|
||||
code: string
|
||||
@@ -62,7 +62,7 @@ export interface CreateLineItemTaxLineDTO {
|
||||
provider_id?: string
|
||||
}
|
||||
|
||||
export interface CreateLineItemAdjustmentDTO {
|
||||
export interface CreateAdjustmentDTO {
|
||||
code: string
|
||||
amount: number
|
||||
description?: string
|
||||
@@ -70,7 +70,7 @@ export interface CreateLineItemAdjustmentDTO {
|
||||
provider_id?: string
|
||||
}
|
||||
|
||||
export interface UpdateLineItemTaxLineDTO {
|
||||
export interface UpdateTaxLineDTO {
|
||||
id: string
|
||||
description?: string
|
||||
tax_rate_id?: string
|
||||
@@ -79,7 +79,7 @@ export interface UpdateLineItemTaxLineDTO {
|
||||
provider_id?: string
|
||||
}
|
||||
|
||||
export interface UpdateLineItemAdjustmentDTO {
|
||||
export interface UpdateAdjustmentDTO {
|
||||
id: string
|
||||
code?: string
|
||||
amount?: number
|
||||
@@ -93,6 +93,8 @@ export interface CreateLineItemDTO {
|
||||
subtitle?: string
|
||||
thumbnail?: string
|
||||
|
||||
cart_id?: string
|
||||
|
||||
quantity: number
|
||||
|
||||
product_id?: string
|
||||
@@ -116,24 +118,53 @@ export interface CreateLineItemDTO {
|
||||
compare_at_unit_price?: number
|
||||
unit_price: number
|
||||
|
||||
tax_lines: CreateLineItemTaxLineDTO[]
|
||||
adjustments: CreateLineItemAdjustmentDTO[]
|
||||
tax_lines?: CreateTaxLineDTO[]
|
||||
adjustments?: CreateAdjustmentDTO[]
|
||||
}
|
||||
|
||||
export interface CreateLineItemForCartDTO extends CreateLineItemDTO {
|
||||
cart_id: string
|
||||
}
|
||||
|
||||
export interface UpdateLineItemWithSelectorDTO {
|
||||
selector: Partial<CartLineItemDTO>
|
||||
data: Partial<UpdateLineItemDTO>
|
||||
}
|
||||
|
||||
export interface UpdateLineItemDTO
|
||||
extends Omit<CreateLineItemDTO, "tax_lines" | "adjustments"> {
|
||||
extends Omit<
|
||||
CreateLineItemDTO,
|
||||
"tax_lines" | "adjustments" | "title" | "quantity" | "unit_price"
|
||||
> {
|
||||
id: string
|
||||
|
||||
tax_lines: UpdateLineItemTaxLineDTO[] | CreateLineItemTaxLineDTO[]
|
||||
adjustments: UpdateLineItemAdjustmentDTO[] | CreateLineItemAdjustmentDTO[]
|
||||
title?: string
|
||||
quantity?: number
|
||||
unit_price?: number
|
||||
|
||||
tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[]
|
||||
adjustments?: UpdateAdjustmentDTO[] | CreateAdjustmentDTO[]
|
||||
}
|
||||
|
||||
export interface AddLineItemsDTO {
|
||||
export interface CreateShippingMethodDTO {
|
||||
name: string
|
||||
|
||||
cart_id: string
|
||||
items: CreateLineItemDTO[]
|
||||
|
||||
amount: number
|
||||
data?: Record<string, unknown>
|
||||
|
||||
tax_lines?: CreateTaxLineDTO[]
|
||||
adjustments?: CreateAdjustmentDTO[]
|
||||
}
|
||||
|
||||
export interface UpdateLineItemsDTO {
|
||||
cart_id: string
|
||||
items: UpdateLineItemDTO[]
|
||||
export interface UpdateShippingMethodDTO {
|
||||
id: string
|
||||
name?: string
|
||||
|
||||
amount?: number
|
||||
data?: Record<string, unknown>
|
||||
|
||||
tax_lines?: UpdateTaxLineDTO[] | CreateTaxLineDTO[]
|
||||
adjustments?: UpdateAdjustmentDTO[] | CreateAdjustmentDTO[]
|
||||
}
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
import { AddressDTO } from "../address"
|
||||
import { FindConfig } from "../common"
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import { CartAddressDTO, CartDTO, FilterableAddressProps, FilterableCartProps } from "./common"
|
||||
import {
|
||||
CartAddressDTO,
|
||||
CartDTO,
|
||||
CartLineItemDTO,
|
||||
CartShippingMethodDTO,
|
||||
FilterableAddressProps,
|
||||
FilterableCartProps,
|
||||
FilterableShippingMethodProps,
|
||||
} from "./common"
|
||||
import {
|
||||
CreateAddressDTO,
|
||||
CreateCartDTO,
|
||||
CreateLineItemDTO,
|
||||
CreateLineItemForCartDTO,
|
||||
CreateShippingMethodDTO,
|
||||
UpdateAddressDTO,
|
||||
UpdateCartDTO,
|
||||
UpdateLineItemDTO,
|
||||
UpdateLineItemWithSelectorDTO,
|
||||
} from "./mutations"
|
||||
|
||||
export interface ICartModuleService extends IModuleService {
|
||||
@@ -40,7 +52,7 @@ export interface ICartModuleService extends IModuleService {
|
||||
|
||||
listAddresses(
|
||||
filters?: FilterableAddressProps,
|
||||
config?: FindConfig<AddressDTO>,
|
||||
config?: FindConfig<CartAddressDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<CartAddressDTO[]>
|
||||
|
||||
@@ -65,20 +77,63 @@ export interface ICartModuleService extends IModuleService {
|
||||
deleteAddresses(ids: string[], sharedContext?: Context): Promise<void>
|
||||
deleteAddresses(ids: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
// addLineItems(data: AddLineItemsDTO, sharedContext?: Context): Promise<CartDTO>
|
||||
// addLineItems(
|
||||
// data: AddLineItemsDTO[],
|
||||
// sharedContext?: Context
|
||||
// ): Promise<CartDTO[]>
|
||||
addLineItems(data: CreateLineItemForCartDTO): Promise<CartLineItemDTO>
|
||||
addLineItems(data: CreateLineItemForCartDTO[]): Promise<CartLineItemDTO[]>
|
||||
addLineItems(
|
||||
cartId: string,
|
||||
items: CreateLineItemDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<CartLineItemDTO[]>
|
||||
|
||||
// updateLineItems(
|
||||
// data: UpdateLineItemsDTO,
|
||||
// sharedContext?: Context
|
||||
// ): Promise<CartDTO>
|
||||
// updateLineItems(
|
||||
// data: UpdateLineItemsDTO[],
|
||||
// sharedContext?: Context
|
||||
// ): Promise<CartDTO[]>
|
||||
updateLineItems(
|
||||
data: UpdateLineItemWithSelectorDTO[]
|
||||
): Promise<CartLineItemDTO[]>
|
||||
updateLineItems(
|
||||
selector: Partial<CartLineItemDTO>,
|
||||
data: Partial<UpdateLineItemDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<CartLineItemDTO[]>
|
||||
updateLineItems(
|
||||
lineId: string,
|
||||
data: Partial<UpdateLineItemDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<CartLineItemDTO>
|
||||
|
||||
// removeLineItems(lineItemIds: string[], sharedContext?: Context): Promise<void>
|
||||
removeLineItems(itemIds: string[], sharedContext?: Context): Promise<void>
|
||||
removeLineItems(itemIds: string, sharedContext?: Context): Promise<void>
|
||||
removeLineItems(
|
||||
selector: Partial<CartLineItemDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
listShippingMethods(
|
||||
filters: FilterableShippingMethodProps,
|
||||
config: FindConfig<CartShippingMethodDTO>,
|
||||
sharedContext: Context
|
||||
): Promise<CartShippingMethodDTO[]>
|
||||
|
||||
addShippingMethods(
|
||||
data: CreateShippingMethodDTO
|
||||
): Promise<CartShippingMethodDTO>
|
||||
addShippingMethods(
|
||||
data: CreateShippingMethodDTO[]
|
||||
): Promise<CartShippingMethodDTO[]>
|
||||
addShippingMethods(
|
||||
cartId: string,
|
||||
methods: CreateShippingMethodDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<CartShippingMethodDTO[]>
|
||||
|
||||
removeShippingMethods(
|
||||
methodIds: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
removeShippingMethods(
|
||||
methodIds: string,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
removeShippingMethods(
|
||||
selector: Partial<CartShippingMethodDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ export interface RepositoryService<T = any> extends BaseRepositoryService<T> {
|
||||
ids: string[],
|
||||
context?: Context
|
||||
): Promise<[T[], Record<string, unknown[]>]>
|
||||
|
||||
upsert?(data: unknown[], context?: Context): Promise<T[]>
|
||||
}
|
||||
|
||||
export interface TreeRepositoryService<T = any>
|
||||
@@ -81,7 +83,7 @@ export interface TreeRepositoryService<T = any>
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
*
|
||||
* An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
|
||||
*/
|
||||
export type SoftDeleteReturn<TReturnableLinkableKeys = string> = {
|
||||
@@ -93,7 +95,7 @@ export type SoftDeleteReturn<TReturnableLinkableKeys = string> = {
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
*
|
||||
* An object that is used to specify an entity's related entities that should be restored when the main entity is restored.
|
||||
*/
|
||||
export type RestoreReturn<TReturnableLinkableKeys = string> = {
|
||||
|
||||
@@ -5,8 +5,8 @@ export type CampaignBudgetTypeValues = "spend" | "usage"
|
||||
export interface CampaignBudgetDTO {
|
||||
id: string
|
||||
type?: CampaignBudgetTypeValues
|
||||
limit?: string | null
|
||||
used?: string
|
||||
limit?: number | null
|
||||
used?: number
|
||||
}
|
||||
|
||||
export interface FilterableCampaignBudgetProps
|
||||
|
||||
@@ -3,6 +3,16 @@ export type ComputeActions =
|
||||
| RemoveItemAdjustmentAction
|
||||
| AddShippingMethodAdjustment
|
||||
| RemoveShippingMethodAdjustment
|
||||
| CampaignBudgetExceededAction
|
||||
|
||||
export type UsageComputedActions =
|
||||
| AddShippingMethodAdjustment
|
||||
| AddItemAdjustmentAction
|
||||
|
||||
export interface CampaignBudgetExceededAction {
|
||||
action: "campaignBudgetExceeded"
|
||||
code: string
|
||||
}
|
||||
|
||||
export interface AddItemAdjustmentAction {
|
||||
action: "addItemAdjustment"
|
||||
@@ -16,6 +26,7 @@ export interface RemoveItemAdjustmentAction {
|
||||
action: "removeItemAdjustment"
|
||||
adjustment_id: string
|
||||
description?: string
|
||||
code: string
|
||||
}
|
||||
|
||||
export interface AddShippingMethodAdjustment {
|
||||
@@ -29,27 +40,28 @@ export interface AddShippingMethodAdjustment {
|
||||
export interface RemoveShippingMethodAdjustment {
|
||||
action: "removeShippingMethodAdjustment"
|
||||
adjustment_id: string
|
||||
code: string
|
||||
}
|
||||
|
||||
export interface ComputeActionAdjustmentLine {
|
||||
export interface ComputeActionAdjustmentLine extends Record<string, unknown> {
|
||||
id: string
|
||||
code: string
|
||||
}
|
||||
|
||||
export interface ComputeActionItemLine {
|
||||
export interface ComputeActionItemLine extends Record<string, unknown> {
|
||||
id: string
|
||||
quantity: number
|
||||
unit_price: number
|
||||
adjustments?: ComputeActionAdjustmentLine[]
|
||||
}
|
||||
|
||||
export interface ComputeActionShippingLine {
|
||||
export interface ComputeActionShippingLine extends Record<string, unknown> {
|
||||
id: string
|
||||
unit_price: number
|
||||
adjustments?: ComputeActionAdjustmentLine[]
|
||||
}
|
||||
|
||||
export interface ComputeActionContext {
|
||||
export interface ComputeActionContext extends Record<string, unknown> {
|
||||
items?: ComputeActionItemLine[]
|
||||
shipping_methods?: ComputeActionShippingLine[]
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { CreateCampaignDTO } from "../mutations"
|
||||
import {
|
||||
ApplicationMethodDTO,
|
||||
CreateApplicationMethodDTO,
|
||||
UpdateApplicationMethodDTO,
|
||||
} from "./application-method"
|
||||
import { CampaignDTO } from "./campaign"
|
||||
import { CreatePromotionRuleDTO, PromotionRuleDTO } from "./promotion-rule"
|
||||
|
||||
export type PromotionType = "standard" | "buyget"
|
||||
@@ -15,6 +17,7 @@ export interface PromotionDTO {
|
||||
is_automatic?: boolean
|
||||
application_method?: ApplicationMethodDTO
|
||||
rules?: PromotionRuleDTO[]
|
||||
campaign?: CampaignDTO
|
||||
}
|
||||
|
||||
export interface CreatePromotionDTO {
|
||||
@@ -23,6 +26,8 @@ export interface CreatePromotionDTO {
|
||||
is_automatic?: boolean
|
||||
application_method?: CreateApplicationMethodDTO
|
||||
rules?: CreatePromotionRuleDTO[]
|
||||
campaign?: CreateCampaignDTO
|
||||
campaign_id?: string
|
||||
}
|
||||
|
||||
export interface UpdatePromotionDTO {
|
||||
@@ -31,6 +36,7 @@ export interface UpdatePromotionDTO {
|
||||
code?: string
|
||||
type?: PromotionType
|
||||
application_method?: UpdateApplicationMethodDTO
|
||||
campaign_id?: string
|
||||
}
|
||||
|
||||
export interface FilterablePromotionProps
|
||||
@@ -39,4 +45,5 @@ export interface FilterablePromotionProps
|
||||
code?: string[]
|
||||
is_automatic?: boolean
|
||||
type?: PromotionType[]
|
||||
budget_id?: string[]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CampaignBudgetTypeValues } from "./common"
|
||||
import { CampaignBudgetTypeValues, PromotionDTO } from "./common"
|
||||
|
||||
export interface CreateCampaignBudgetDTO {
|
||||
type: CampaignBudgetTypeValues
|
||||
@@ -21,6 +21,7 @@ export interface CreateCampaignDTO {
|
||||
starts_at: Date
|
||||
ends_at: Date
|
||||
budget?: CreateCampaignBudgetDTO
|
||||
promotions?: Pick<PromotionDTO, "id">[]
|
||||
}
|
||||
|
||||
export interface UpdateCampaignDTO {
|
||||
@@ -32,4 +33,5 @@ export interface UpdateCampaignDTO {
|
||||
starts_at?: Date
|
||||
ends_at?: Date
|
||||
budget?: Omit<UpdateCampaignBudgetDTO, "id">
|
||||
promotions?: Pick<PromotionDTO, "id">[]
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import {
|
||||
import { CreateCampaignDTO, UpdateCampaignDTO } from "./mutations"
|
||||
|
||||
export interface IPromotionModuleService extends IModuleService {
|
||||
registerUsage(computedActions: ComputeActions[]): Promise<void>
|
||||
|
||||
computeActions(
|
||||
promotionCodesToApply: string[],
|
||||
applicationContext: ComputeActionContext,
|
||||
|
||||
Reference in New Issue
Block a user