chore: fixes to http and request types for customers (#13825)
This commit is contained in:
1 parent
db777dc3d5
commit
faea42316a
14 files changed
+60
-29
No files matched your search
@@ -23,6 +23,10 @@ export interface FindParams extends SelectParams {
|
|||||||
* -created_at
|
* -created_at
|
||||||
*/
|
*/
|
||||||
order?: string
|
order?: string
|
||||||
|
/**
|
||||||
|
* Whether to include soft-deleted items in the results.
|
||||||
|
*/
|
||||||
|
with_deleted?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminBatchLink {
|
export interface AdminBatchLink {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { FindParams } from "../../common"
|
||||||
import {
|
import {
|
||||||
BaseCustomerAddressFilters,
|
BaseCustomerAddressFilters,
|
||||||
BaseCustomerFilters,
|
BaseCustomerFilters,
|
||||||
@@ -15,4 +16,4 @@ export interface AdminCustomerFilters extends BaseCustomerFilters {
|
|||||||
has_account?: boolean
|
has_account?: boolean
|
||||||
}
|
}
|
||||||
export interface AdminCustomerAddressFilters
|
export interface AdminCustomerAddressFilters
|
||||||
extends BaseCustomerAddressFilters {}
|
extends BaseCustomerAddressFilters, FindParams {}
|
||||||
@@ -4,11 +4,14 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
|
||||||
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { refetchCustomerGroup } from "../../helpers"
|
import { refetchCustomerGroup } from "../../helpers"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminBatchLink,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ import {
|
|||||||
|
|
||||||
import { MedusaError } from "@medusajs/framework/utils"
|
import { MedusaError } from "@medusajs/framework/utils"
|
||||||
import { refetchCustomerGroup } from "../helpers"
|
import { refetchCustomerGroup } from "../helpers"
|
||||||
import { AdminUpdateCustomerGroupType } from "../validators"
|
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
||||||
) => {
|
) => {
|
||||||
const customerGroup = await refetchCustomerGroup(
|
const customerGroup = await refetchCustomerGroup(
|
||||||
@@ -33,7 +32,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminUpdateCustomerGroupType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminUpdateCustomerGroup,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
||||||
) => {
|
) => {
|
||||||
const existingCustomerGroup = await refetchCustomerGroup(
|
const existingCustomerGroup = await refetchCustomerGroup(
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/framework/utils"
|
} from "@medusajs/framework/utils"
|
||||||
import { AdminCreateCustomerGroupType } from "./validators"
|
|
||||||
import { refetchCustomerGroup } from "./helpers"
|
import { refetchCustomerGroup } from "./helpers"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
@@ -37,7 +36,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreateCustomerGroupType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCreateCustomerGroup,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerGroupResponse>
|
||||||
) => {
|
) => {
|
||||||
const createGroups = createCustomerGroupsWorkflow(req.scope)
|
const createGroups = createCustomerGroupsWorkflow(req.scope)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { refetchCustomer } from "../../../helpers"
|
|||||||
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"
|
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerAddressResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerAddressResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
@@ -35,7 +35,8 @@ export const GET = async (
|
|||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<
|
req: AuthenticatedMedusaRequest<
|
||||||
AdminCreateCustomerAddressType & AdditionalData
|
AdminCreateCustomerAddressType & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
>,
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
@@ -60,7 +61,7 @@ export const POST = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DELETE = async (
|
export const DELETE = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerAddressDeleteResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerAddressDeleteResponse>
|
||||||
) => {
|
) => {
|
||||||
const id = req.params.address_id
|
const id = req.params.address_id
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ export const GET = async (
|
|||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<
|
req: AuthenticatedMedusaRequest<
|
||||||
AdminCreateCustomerAddressType & AdditionalData
|
AdminCreateCustomerAddressType & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
>,
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
|
||||||
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
import { refetchCustomer } from "../../helpers"
|
import { refetchCustomer } from "../../helpers"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminBatchLink,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { refetchCustomer } from "../helpers"
|
|||||||
import { AdminUpdateCustomerType } from "../validators"
|
import { AdminUpdateCustomerType } from "../validators"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
const customer = await refetchCustomer(
|
const customer = await refetchCustomer(
|
||||||
@@ -32,7 +32,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminUpdateCustomerType & AdditionalData>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
AdminUpdateCustomerType & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
const existingCustomer = await refetchCustomer(req.params.id, req.scope, [
|
const existingCustomer = await refetchCustomer(req.params.id, req.scope, [
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreateCustomerType & AdditionalData>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
AdminCreateCustomerType & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
res: MedusaResponse<HttpTypes.AdminCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
const { additional_data, ...rest } = req.validatedBody
|
const { additional_data, ...rest } = req.validatedBody
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
import { refetchCustomer } from "../../../helpers"
|
import { refetchCustomer } from "../../../helpers"
|
||||||
import {
|
import {
|
||||||
StoreGetCustomerAddressParamsType,
|
StoreGetCustomerAddressParamsType,
|
||||||
StoreUpdateCustomerAddressType,
|
|
||||||
} from "../../../validators"
|
} from "../../../validators"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
@@ -45,7 +44,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<StoreUpdateCustomerAddressType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreUpdateCustomerAddress,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
const id = req.auth_context.actor_id!
|
const id = req.auth_context.actor_id!
|
||||||
@@ -65,7 +67,7 @@ export const POST = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DELETE = async (
|
export const DELETE = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCustomerAddressDeleteResponse>
|
res: MedusaResponse<HttpTypes.StoreCustomerAddressDeleteResponse>
|
||||||
) => {
|
) => {
|
||||||
const id = req.auth_context.actor_id
|
const id = req.auth_context.actor_id
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import {
|
|||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
|
||||||
import { createCustomerAddressesWorkflow } from "@medusajs/core-flows"
|
import { createCustomerAddressesWorkflow } from "@medusajs/core-flows"
|
||||||
import {
|
|
||||||
StoreCreateCustomerAddressType,
|
|
||||||
StoreGetCustomerAddressesParamsType,
|
|
||||||
} from "../../validators"
|
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
@@ -16,7 +12,9 @@ import { refetchCustomer } from "../../helpers"
|
|||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<StoreGetCustomerAddressesParamsType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreCustomerAddressFilters
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCustomerAddressListResponse>
|
res: MedusaResponse<HttpTypes.StoreCustomerAddressListResponse>
|
||||||
) => {
|
) => {
|
||||||
const customerId = req.auth_context.actor_id
|
const customerId = req.auth_context.actor_id
|
||||||
@@ -42,7 +40,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<StoreCreateCustomerAddressType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreCreateCustomerAddress,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
const customerId = req.auth_context.actor_id
|
const customerId = req.auth_context.actor_id
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
StoreGetCustomerParamsType,
|
StoreGetCustomerParamsType,
|
||||||
StoreUpdateCustomerType,
|
|
||||||
} from "../validators"
|
} from "../validators"
|
||||||
import { refetchCustomer } from "../helpers"
|
import { refetchCustomer } from "../helpers"
|
||||||
import { MedusaError } from "@medusajs/framework/utils"
|
import { MedusaError } from "@medusajs/framework/utils"
|
||||||
@@ -30,7 +29,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<StoreUpdateCustomerType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreUpdateCustomer,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
const customerId = req.auth_context.actor_id
|
const customerId = req.auth_context.actor_id
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import { HttpTypes } from "@medusajs/framework/types"
|
|||||||
import { refetchCustomer } from "./helpers"
|
import { refetchCustomer } from "./helpers"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.StoreCreateCustomer>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreCreateCustomer,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
|
||||||
) => {
|
) => {
|
||||||
// If `actor_id` is present, the request carries authentication for an existing customer
|
// If `actor_id` is present, the request carries authentication for an existing customer
|
||||||
|
|||||||
Reference in new issue
Block a user