Feat(medusa): convert customer service to typescript (#1653)
* centralize common knowledge and checks for list-customers in repository * convert customer service to typescript * fix typing error in update-address * add await * add atomic phases * update types for customerservice * update api and model types * pr feedback * remove Promise.resolve * typing of buildQuery * remove atomic phase from private method
This commit is contained in:
@@ -53,5 +53,5 @@ export class AdminPostCustomersReq {
|
||||
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
metadata?: object
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ export class AdminPostCustomersCustomerReq {
|
||||
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
metadata?: object
|
||||
metadata?: Record<string, unknown>
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
|
||||
@@ -64,7 +64,7 @@ export const defaultStoreCustomersRelations = [
|
||||
"billing_address",
|
||||
]
|
||||
|
||||
export const defaultStoreCustomersFields = [
|
||||
export const defaultStoreCustomersFields: (keyof Customer)[] = [
|
||||
"id",
|
||||
"email",
|
||||
"first_name",
|
||||
|
||||
@@ -45,9 +45,9 @@ export default async (req, res) => {
|
||||
"customerService"
|
||||
) as CustomerService
|
||||
|
||||
let customer = await customerService.updateAddress(id, address_id, validated)
|
||||
await customerService.updateAddress(id, address_id, validated)
|
||||
|
||||
customer = await customerService.retrieve(id, {
|
||||
const customer = await customerService.retrieve(id, {
|
||||
relations: defaultStoreCustomersRelations,
|
||||
select: defaultStoreCustomersFields,
|
||||
})
|
||||
|
||||
@@ -93,5 +93,5 @@ export class StorePostCustomersCustomerReq {
|
||||
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
metadata?: object
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user