feat(customer): add softdelete/restore (#6203)

This commit is contained in:
Sebastian Rindom authored and GitHub committed 2024-01-25 12:38:02 +00:00
1 parent e84847be36
commit e9435a8680
8 files changed
+519 -21

No files matched your search

+36 -12
View File
@@ -2,27 +2,28 @@ 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>
name?: string | OperatorMap<string>
customers?: FilterableCustomerProps | string | string[]
created_by?: string | string[] | null
created_at?: OperatorMap<string>
updated_at?: OperatorMap<string>
}
export interface FilterableCustomerGroupCustomerProps
extends BaseFilterable<FilterableCustomerGroupCustomerProps> {
id?: string | string[]
customer_id?: string | string[]
customer_group_id?: string | string[]
customer?: FilterableCustomerProps | string | string[]
group?: FilterableCustomerGroupProps | string | string[]
created_by?: string | string[] | null
created_at?: OperatorMap<string>
updated_at?: OperatorMap<string>
}
export interface FilterableCustomerProps
extends BaseFilterable<FilterableCustomerProps> {
id?: string | string[]
@@ -38,6 +39,28 @@ export interface FilterableCustomerProps
updated_at?: OperatorMap<string>
}
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 CustomerGroupCustomerDTO {
id: string
customer_id: string
customer_group_id: string
customer?: Partial<CustomerDTO>
group?: Partial<CustomerGroupDTO>
created_by?: string | null
created_at?: Date | string
updated_at?: Date | string
}
export interface CustomerDTO {
id: string
email: string
@@ -52,6 +75,7 @@ export interface CustomerDTO {
phone?: string | null
groups?: { id: string }[]
metadata?: Record<string, unknown>
created_by?: string | null
deleted_at?: Date | string | null
created_at?: Date | string
updated_at?: Date | string
+51 -3
View File
@@ -1,9 +1,12 @@
import { FindConfig } from "../common"
import { RestoreReturn, SoftDeleteReturn } from "../dal"
import { IModuleService } from "../modules-sdk"
import { Context } from "../shared-context"
import {
CustomerDTO,
CustomerGroupDTO,
CustomerGroupCustomerDTO,
FilterableCustomerGroupCustomerProps,
FilterableCustomerProps,
FilterableCustomerGroupProps,
GroupCustomerPair,
@@ -21,7 +24,6 @@ export interface ICustomerModuleService extends IModuleService {
data: CreateCustomerDTO[],
sharedContext?: Context
): Promise<CustomerDTO[]>
create(data: CreateCustomerDTO, sharedContext?: Context): Promise<CustomerDTO>
update(
@@ -57,6 +59,12 @@ export interface ICustomerModuleService extends IModuleService {
sharedContext?: Context
): Promise<CustomerGroupDTO>
retrieveCustomerGroup(
groupId: string,
config?: FindConfig<CustomerGroupDTO>,
sharedContext?: Context
): Promise<CustomerGroupDTO>
updateCustomerGroup(
groupId: string,
data: Partial<CreateCustomerGroupDTO>,
@@ -73,6 +81,16 @@ export interface ICustomerModuleService extends IModuleService {
sharedContext?: Context
): Promise<CustomerGroupDTO[]>
deleteCustomerGroup(groupId: string, sharedContext?: Context): Promise<void>
deleteCustomerGroup(
groupIds: string[],
sharedContext?: Context
): Promise<void>
deleteCustomerGroup(
selector: FilterableCustomerGroupProps,
sharedContext?: Context
): Promise<void>
addCustomerToGroup(
groupCustomerPair: GroupCustomerPair,
sharedContext?: Context
@@ -84,14 +102,20 @@ export interface ICustomerModuleService extends IModuleService {
): Promise<{ id: string }[]>
removeCustomerFromGroup(
groupCustomerPair: { customer_id: string; customer_group_id: string },
groupCustomerPair: GroupCustomerPair,
sharedContext?: Context
): Promise<void>
removeCustomerFromGroup(
groupCustomerPairs: { customer_id: string; customer_group_id: string }[],
groupCustomerPairs: GroupCustomerPair[],
sharedContext?: Context
): Promise<void>
listCustomerGroupRelations(
filters?: FilterableCustomerGroupCustomerProps,
config?: FindConfig<CustomerGroupCustomerDTO>,
sharedContext?: Context
): Promise<CustomerGroupCustomerDTO[]>
list(
filters?: FilterableCustomerProps,
config?: FindConfig<CustomerDTO>,
@@ -115,4 +139,28 @@ export interface ICustomerModuleService extends IModuleService {
config?: FindConfig<CustomerGroupDTO>,
sharedContext?: Context
): Promise<[CustomerGroupDTO[], number]>
softDelete<TReturnableLinkableKeys extends string = string>(
customerIds: string[],
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
restore<TReturnableLinkableKeys extends string = string>(
customerIds: string[],
config?: RestoreReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
softDeleteCustomerGroup<TReturnableLinkableKeys extends string = string>(
groupIds: string[],
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
restoreCustomerGroup<TReturnableLinkableKeys extends string = string>(
groupIds: string[],
config?: RestoreReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
}