feat(customer): admin CRUD endpoints (#6232)
**What** - GET /customers/:id - POST /customers/:id - DELETE /customers/:id - POST /customers Including workflows for each.
This commit is contained in:
@@ -6,6 +6,7 @@ export class Migration20240124154000 extends Migration {
|
||||
this.addSql(
|
||||
'create table if not exists "customer" ("id" text not null, "company_name" text null, "first_name" text null, "last_name" text null, "email" text null, "phone" text null, "has_account" boolean not null default false, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "created_by" text null, constraint "customer_pkey" primary key ("id"));'
|
||||
)
|
||||
this.addSql('alter table "customer" alter column "email" drop not null;')
|
||||
this.addSql(
|
||||
'alter table "customer" add column if not exists "company_name" text null;'
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
CustomerTypes,
|
||||
SoftDeleteReturn,
|
||||
RestoreReturn,
|
||||
CustomerUpdatableFields,
|
||||
} from "@medusajs/types"
|
||||
|
||||
import {
|
||||
@@ -110,24 +111,24 @@ export default class CustomerModuleService implements ICustomerModuleService {
|
||||
|
||||
update(
|
||||
customerId: string,
|
||||
data: Partial<CustomerTypes.CreateCustomerDTO>,
|
||||
data: CustomerUpdatableFields,
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerTypes.CustomerDTO>
|
||||
update(
|
||||
customerIds: string[],
|
||||
data: Partial<CustomerTypes.CreateCustomerDTO>,
|
||||
data: CustomerUpdatableFields,
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerTypes.CustomerDTO[]>
|
||||
update(
|
||||
selector: CustomerTypes.FilterableCustomerProps,
|
||||
data: Partial<CustomerTypes.CreateCustomerDTO>,
|
||||
data: CustomerUpdatableFields,
|
||||
sharedContext?: Context
|
||||
): Promise<CustomerTypes.CustomerDTO[]>
|
||||
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async update(
|
||||
idsOrSelector: string | string[] | CustomerTypes.FilterableCustomerProps,
|
||||
data: Partial<CustomerTypes.CreateCustomerDTO>,
|
||||
data: CustomerUpdatableFields,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
) {
|
||||
let updateData: CustomerTypes.UpdateCustomerDTO[] = []
|
||||
|
||||
Reference in New Issue
Block a user