fix(types,medusa): fix query types for some store routes (#8994)

This commit is contained in:
Shahed Nasser
2024-09-04 19:36:55 +03:00
committed by GitHub
parent c424d397f6
commit 4b1827ed48
15 changed files with 19 additions and 23 deletions
@@ -16,7 +16,7 @@ export const AdminGetRegionsParams = createFindParams({
z.object({
q: z.string().optional(),
id: z.union([z.string(), z.array(z.string())]).optional(),
code: z.union([z.string(), z.array(z.string())]).optional(),
currency_code: z.union([z.string(), z.array(z.string())]).optional(),
name: z.union([z.string(), z.array(z.string())]).optional(),
created_at: createOperatorMap().optional(),
updated_at: createOperatorMap().optional(),
@@ -50,7 +50,7 @@ export type StoreGetCustomerAddressParamsType = z.infer<
typeof StoreGetCustomerAddressParams
>
export type StoreGetCustomerAddressesParamsType = z.infer<
typeof StoreCreateCustomerAddress
typeof StoreGetCustomerAddressesParams
>
export type StoreCreateCustomerAddressType = z.infer<
typeof StoreCreateCustomerAddress
@@ -1,11 +1,10 @@
import { HttpTypes } from "@medusajs/types"
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
import { refetchOrder } from "../helpers"
import { StoreGetOrdersParamsType } from "../validators"
// TODO: Do we want to apply some sort of authentication here? My suggestion is that we do
export const GET = async (
req: MedusaRequest<StoreGetOrdersParamsType>,
req: MedusaRequest,
res: MedusaResponse<HttpTypes.StoreOrderResponse>
) => {
const order = await refetchOrder(
@@ -1,5 +1,4 @@
import { z } from "zod"
import { booleanString } from "../../utils/common-validators"
import { createFindParams } from "../../utils/validators"
export type StoreGetPaymentProvidersParamsType = z.infer<
@@ -11,9 +10,5 @@ export const StoreGetPaymentProvidersParams = createFindParams({
}).merge(
z.object({
region_id: z.string(),
id: z.union([z.string(), z.array(z.string())]).optional(),
is_enabled: booleanString().optional(),
$and: z.lazy(() => StoreGetPaymentProvidersParams.array()).optional(),
$or: z.lazy(() => StoreGetPaymentProvidersParams.array()).optional(),
})
)
@@ -13,7 +13,7 @@ export const GET = async (
) => {
const category = await refetchEntity(
"product_category",
req.params.id,
{ id: req.params.id, ...req.filterableFields },
req.scope,
req.remoteQueryConfig.fields
)
@@ -26,6 +26,7 @@ export const StoreProductCategoriesParams = createFindParams({
z.object({
q: z.string().optional(),
id: z.union([z.string(), z.array(z.string())]).optional(),
name: z.union([z.string(), z.array(z.string())]).optional(),
description: z.union([z.string(), z.array(z.string())]).optional(),
handle: z.union([z.string(), z.array(z.string())]).optional(),
parent_category_id: z.union([z.string(), z.array(z.string())]).optional(),
@@ -12,7 +12,7 @@ export const StoreGetRegionsParams = createFindParams({
z.object({
q: z.string().optional(),
id: z.union([z.string(), z.array(z.string())]).optional(),
code: z.union([z.string(), z.array(z.string())]).optional(),
currency_code: z.union([z.string(), z.array(z.string())]).optional(),
name: z.union([z.string(), z.array(z.string())]).optional(),
$and: z.lazy(() => StoreGetRegionsParams.array()).optional(),
$or: z.lazy(() => StoreGetRegionsParams.array()).optional(),