feat(customer): Introduce customer group (#6137)
**What** Methods for: - Bulk create customers - Bulk and single create of customer groups - Assigning customer <> group relationships - listing of customers and customer groups ++ Uses new repository loading mechanism
This commit is contained in:
@@ -1,5 +1,43 @@
|
||||
import { BaseFilterable } from "../dal"
|
||||
import { OperatorMap } from "../dal/utils"
|
||||
import { AddressDTO } from "../address"
|
||||
|
||||
export interface CustomerGroupDTO {
|
||||
id: string
|
||||
name: string
|
||||
customers?: Partial<CustomerDTO>[]
|
||||
metadata?: Record<string, unknown>
|
||||
created_by?: string | null
|
||||
deleted_at?: Date | string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
}
|
||||
|
||||
export interface FilterableCustomerGroupProps
|
||||
extends BaseFilterable<FilterableCustomerGroupProps> {
|
||||
id?: string | string[]
|
||||
name?: OperatorMap<string>
|
||||
customers?: FilterableCustomerProps | string | string[]
|
||||
created_by?: string | string[] | null
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface FilterableCustomerProps
|
||||
extends BaseFilterable<FilterableCustomerProps> {
|
||||
id?: string | string[]
|
||||
email?: string | string[] | OperatorMap<string>
|
||||
groups?: FilterableCustomerGroupProps | string | string[]
|
||||
default_billing_address_id?: string | string[] | null
|
||||
default_shipping_address_id?: string | string[] | null
|
||||
company_name?: string | string[] | OperatorMap<string> | null
|
||||
first_name?: string | string[] | OperatorMap<string> | null
|
||||
last_name?: string | string[] | OperatorMap<string> | null
|
||||
created_by?: string | string[] | null
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface CustomerDTO {
|
||||
id: string
|
||||
email: string
|
||||
@@ -14,11 +52,16 @@ export interface CustomerDTO {
|
||||
phone?: string | null
|
||||
groups?: { id: string }[]
|
||||
metadata?: Record<string, unknown>
|
||||
deleted_at?: Date | string
|
||||
deleted_at?: Date | string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
}
|
||||
|
||||
export type GroupCustomerPair = {
|
||||
customer_id: string
|
||||
customer_group_id: string
|
||||
}
|
||||
|
||||
export type legacy_CustomerDTO = {
|
||||
id: string
|
||||
email: string
|
||||
|
||||
@@ -4,6 +4,7 @@ export interface CreateCustomerDTO {
|
||||
last_name?: string
|
||||
email?: string
|
||||
phone?: string
|
||||
created_by?: string
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -15,3 +16,20 @@ export interface UpdateCustomerDTO {
|
||||
phone?: string
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface CreateCustomerGroupDTO {
|
||||
name: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
created_by?: string
|
||||
}
|
||||
|
||||
export interface CustomerGroupUpdatableFileds {
|
||||
name?: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface UpdateCustomerGroupDTO {
|
||||
id?: string
|
||||
name?: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { FindConfig } from "../common"
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import { CustomerDTO } from "./common"
|
||||
import { CreateCustomerDTO } from "./mutations"
|
||||
import {
|
||||
CustomerDTO,
|
||||
CustomerGroupDTO,
|
||||
FilterableCustomerProps,
|
||||
FilterableCustomerGroupProps,
|
||||
GroupCustomerPair,
|
||||
} from "./common"
|
||||
import { CreateCustomerDTO, CreateCustomerGroupDTO } from "./mutations"
|
||||
|
||||
export interface ICustomerModuleService extends IModuleService {
|
||||
retrieve(
|
||||
@@ -11,5 +17,54 @@ export interface ICustomerModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerDTO>
|
||||
|
||||
create(
|
||||
data: CreateCustomerDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerDTO[]>
|
||||
|
||||
create(data: CreateCustomerDTO, sharedContext?: Context): Promise<CustomerDTO>
|
||||
|
||||
createCustomerGroup(
|
||||
data: CreateCustomerGroupDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerGroupDTO[]>
|
||||
|
||||
createCustomerGroup(
|
||||
data: CreateCustomerGroupDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerGroupDTO>
|
||||
|
||||
addCustomerToGroup(
|
||||
groupCustomerPair: GroupCustomerPair,
|
||||
sharedContext?: Context
|
||||
): Promise<{ id: string }>
|
||||
|
||||
addCustomerToGroup(
|
||||
groupCustomerPairs: GroupCustomerPair[],
|
||||
sharedContext?: Context
|
||||
): Promise<{ id: string }[]>
|
||||
|
||||
list(
|
||||
filters?: FilterableCustomerProps,
|
||||
config?: FindConfig<CustomerDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerDTO[]>
|
||||
|
||||
listAndCount(
|
||||
filters?: FilterableCustomerProps,
|
||||
config?: FindConfig<CustomerDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[CustomerDTO[], number]>
|
||||
|
||||
listCustomerGroups(
|
||||
filters?: FilterableCustomerGroupProps,
|
||||
config?: FindConfig<CustomerGroupDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerGroupDTO[]>
|
||||
|
||||
listAndCountCustomerGroups(
|
||||
filters?: FilterableCustomerGroupProps,
|
||||
config?: FindConfig<CustomerGroupDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[CustomerGroupDTO[], number]>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user