feat(medusa,types): added store apis for products (#7144)
what: - adds products list api - adds products retrieve api RESOLVES CORE-2016
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { z } from "zod"
|
||||
import { optionalBooleanMapper } from "../../../utils/validators/is-boolean"
|
||||
|
||||
export const AddressPayload = z
|
||||
.object({
|
||||
first_name: z.string().optional(),
|
||||
last_name: z.string().optional(),
|
||||
phone: z.string().optional(),
|
||||
company: z.string().optional(),
|
||||
address_1: z.string().optional(),
|
||||
address_2: z.string().optional(),
|
||||
city: z.string().optional(),
|
||||
country_code: z.string().optional(),
|
||||
province: z.string().optional(),
|
||||
postal_code: z.string().optional(),
|
||||
metadata: z.record(z.string()).optional().nullable(),
|
||||
})
|
||||
.strict()
|
||||
|
||||
export const BigNumberInput = z.union([
|
||||
z.number(),
|
||||
z.string(),
|
||||
z.object({
|
||||
value: z.string(),
|
||||
precision: z.number(),
|
||||
}),
|
||||
])
|
||||
|
||||
export const OptionalBooleanValidator = z.preprocess(
|
||||
(val: any) => optionalBooleanMapper.get(val?.toLowerCase()),
|
||||
z.boolean().optional()
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./common"
|
||||
export * from "./products"
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ProductStatus } from "@medusajs/utils"
|
||||
import { z } from "zod"
|
||||
import { createOperatorMap } from "../../validators"
|
||||
import { OptionalBooleanValidator } from "../common"
|
||||
|
||||
export const ProductStatusEnum = z.nativeEnum(ProductStatus)
|
||||
|
||||
export const GetProductsParams = z.object({
|
||||
q: z.string().optional(),
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
title: z.string().optional(),
|
||||
handle: z.string().optional(),
|
||||
is_giftcard: OptionalBooleanValidator,
|
||||
category_id: z.string().array().optional(),
|
||||
sales_channel_id: z.string().array().optional(),
|
||||
collection_id: z.string().array().optional(),
|
||||
tags: z.string().array().optional(),
|
||||
type_id: z.string().array().optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
deleted_at: createOperatorMap().optional(),
|
||||
})
|
||||
Reference in New Issue
Block a user