fix(medusa): Admin validator filtering and pagination (#9748)
**What** Fix usage of $and and $or operator and pagination inclusion
This commit is contained in:
committed by
GitHub
parent
e087073121
commit
471f7e4a10
@@ -1,5 +1,9 @@
|
||||
import { z } from "zod"
|
||||
import { AddressPayload, BigNumberInput } from "../../utils/common-validators"
|
||||
import {
|
||||
AddressPayload,
|
||||
applyAndAndOrOperators,
|
||||
BigNumberInput,
|
||||
} from "../../utils/common-validators"
|
||||
import {
|
||||
createFindParams,
|
||||
createSelectParams,
|
||||
@@ -9,17 +13,17 @@ import {
|
||||
export type AdminGetOrderParamsType = z.infer<typeof AdminGetOrderParams>
|
||||
export const AdminGetOrderParams = createSelectParams()
|
||||
|
||||
export const AdminGetOrdersParamsFields = z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
})
|
||||
|
||||
export type AdminGetOrdersParamsType = z.infer<typeof AdminGetOrdersParams>
|
||||
export const AdminGetOrdersParams = createFindParams({
|
||||
limit: 50,
|
||||
offset: 0,
|
||||
}).merge(
|
||||
z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
$and: z.lazy(() => AdminGetOrdersParams.array()).optional(),
|
||||
$or: z.lazy(() => AdminGetOrdersParams.array()).optional(),
|
||||
})
|
||||
)
|
||||
})
|
||||
.merge(AdminGetOrdersParamsFields)
|
||||
.merge(applyAndAndOrOperators(AdminGetOrdersParamsFields))
|
||||
|
||||
enum Status {
|
||||
completed = "completed",
|
||||
|
||||
Reference in New Issue
Block a user