feat: Use tag ids instead of values wherever possible (#8394)

This commit is contained in:
Stevche Radevski
2024-08-02 09:22:03 +02:00
committed by GitHub
parent 71f0d24359
commit 3a068c6b27
26 changed files with 259 additions and 229 deletions
@@ -2,6 +2,7 @@ import { z } from "zod"
import {
GetProductsParams,
ProductStatusEnum,
transformProductParams,
} from "../../utils/common-validators"
import {
createFindParams,
@@ -45,28 +46,30 @@ export type StoreGetProductsParamsType = z.infer<typeof StoreGetProductsParams>
export const StoreGetProductsParams = createFindParams({
offset: 0,
limit: 50,
}).merge(
z
.object({
// These are used to populate the tax and pricing context
region_id: z.string().optional(),
country_code: z.string().optional(),
province: z.string().optional(),
cart_id: z.string().optional(),
})
.merge(
z
.object({
// These are used to populate the tax and pricing context
region_id: z.string().optional(),
country_code: z.string().optional(),
province: z.string().optional(),
cart_id: z.string().optional(),
variants: z
.object({
status: ProductStatusEnum.array().optional(),
options: z
.object({ value: z.string(), option_id: z.string() })
.optional(),
$and: z.lazy(() => StoreGetProductsParams.array()).optional(),
$or: z.lazy(() => StoreGetProductsParams.array()).optional(),
})
.optional(),
$and: z.lazy(() => StoreGetProductsParams.array()).optional(),
$or: z.lazy(() => StoreGetProductsParams.array()).optional(),
})
.merge(GetProductsParams)
.strict()
)
variants: z
.object({
status: ProductStatusEnum.array().optional(),
options: z
.object({ value: z.string(), option_id: z.string() })
.optional(),
$and: z.lazy(() => StoreGetProductsParams.array()).optional(),
$or: z.lazy(() => StoreGetProductsParams.array()).optional(),
})
.optional(),
$and: z.lazy(() => StoreGetProductsParams.array()).optional(),
$or: z.lazy(() => StoreGetProductsParams.array()).optional(),
})
.merge(GetProductsParams)
.strict()
)
.transform(transformProductParams)