feat(medusa): Add support for filtering with gt, lt, gte and lte (#190)
- Add support for filtering with lt, gt, lte, gte in the following format: created_at[gt]=01-26-1997 - Add middleware for cleaning request queries - Add order query validation - Temp. disables tags in claim integration tests
This commit is contained in:
@@ -17,4 +17,72 @@ Joi.address = () => {
|
||||
})
|
||||
}
|
||||
|
||||
Joi.dateFilter = () => {
|
||||
return Joi.object({
|
||||
lt: Joi.alternatives(Joi.date().timestamp("unix"), Joi.date()),
|
||||
gt: Joi.alternatives(Joi.date().timestamp("unix"), Joi.date()),
|
||||
gte: Joi.alternatives(Joi.date().timestamp("unix"), Joi.date()),
|
||||
lte: Joi.alternatives(Joi.date().timestamp("unix"), Joi.date()),
|
||||
})
|
||||
}
|
||||
|
||||
Joi.orderFilter = () => {
|
||||
return Joi.object().keys({
|
||||
id: Joi.string(),
|
||||
status: Joi.array()
|
||||
.items(
|
||||
Joi.string().valid(
|
||||
"pending",
|
||||
"completed",
|
||||
"archived",
|
||||
"canceled",
|
||||
"requires_action"
|
||||
)
|
||||
)
|
||||
.single(),
|
||||
fulfillment_status: Joi.array()
|
||||
.items(
|
||||
Joi.string().valid(
|
||||
"not_fulfilled",
|
||||
"fulfilled",
|
||||
"partially_fulfilled",
|
||||
"shipped",
|
||||
"partially_shipped",
|
||||
"canceled",
|
||||
"returned",
|
||||
"partially_returned",
|
||||
"requires_action"
|
||||
)
|
||||
)
|
||||
.single(),
|
||||
payment_status: Joi.array()
|
||||
.items(
|
||||
Joi.string().valid(
|
||||
"captured",
|
||||
"awaiting",
|
||||
"not_paid",
|
||||
"refunded",
|
||||
"partially_refunded",
|
||||
"canceled",
|
||||
"requires_action"
|
||||
)
|
||||
)
|
||||
.single(),
|
||||
display_id: Joi.string(),
|
||||
cart_id: Joi.string(),
|
||||
offset: Joi.string(),
|
||||
limit: Joi.string(),
|
||||
expand: Joi.string(),
|
||||
fields: Joi.string(),
|
||||
customer_id: Joi.string(),
|
||||
email: Joi.string(),
|
||||
region_id: Joi.string(),
|
||||
currency_code: Joi.string(),
|
||||
tax_rate: Joi.string(),
|
||||
canceled_at: Joi.dateFilter(),
|
||||
created_at: Joi.dateFilter(),
|
||||
updated_at: Joi.dateFilter(),
|
||||
})
|
||||
}
|
||||
|
||||
export default Joi
|
||||
|
||||
Reference in New Issue
Block a user