fix(types,medusa): fix query types for some store routes (#8994)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { BaseFilterable } from "../../../dal";
|
||||
import { OrderStatus } from "../../../order";
|
||||
import { FindParams } from "../../common";
|
||||
|
||||
export interface StoreOrderFilters extends
|
||||
FindParams, BaseFilterable<StoreOrderFilters> {
|
||||
id?: string | string[]
|
||||
name?: string | string[]
|
||||
status?: OrderStatus | OrderStatus[]
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ import {
|
||||
BasePaymentSessionFilters,
|
||||
} from "../common"
|
||||
|
||||
export interface StorePaymentProviderFilters
|
||||
extends BasePaymentProviderFilters {
|
||||
is_enabled?: boolean
|
||||
}
|
||||
export interface StorePaymentProviderFilters {
|
||||
region_id: string
|
||||
}
|
||||
export interface StorePaymentCollectionFilters
|
||||
extends BasePaymentCollectionFilters {}
|
||||
export interface StorePaymentSessionFilters extends BasePaymentSessionFilters {}
|
||||
|
||||
@@ -4,6 +4,6 @@ import {
|
||||
} from "../common"
|
||||
|
||||
export interface StoreProductCategoryListParams
|
||||
extends BaseProductCategoryListParams {}
|
||||
extends Omit<BaseProductCategoryListParams, "is_internal" | "is_active"> {}
|
||||
|
||||
export interface StoreProductCategoryParams extends BaseProductCategoryParams {}
|
||||
|
||||
@@ -6,7 +6,8 @@ import {
|
||||
|
||||
export interface StoreProductOptionParams extends BaseProductOptionParams {}
|
||||
export interface StoreProductVariantParams extends BaseProductVariantParams {}
|
||||
export interface StoreProductParams extends BaseProductListParams {
|
||||
export interface StoreProductParams extends Omit<BaseProductListParams, "tags" | "status" | "categories"> {
|
||||
tag_id?: string | string[]
|
||||
// The region ID and currency_code are not params, but are used for the pricing context. Maybe move to separate type definition.
|
||||
region_id?: string
|
||||
currency_code?: string
|
||||
|
||||
@@ -5,10 +5,10 @@ import {
|
||||
BaseRegionFilters,
|
||||
} from "../common"
|
||||
|
||||
export interface AdminRegionFilters extends FindParams, BaseFilterable<BaseRegionFilters> {
|
||||
export interface AdminRegionFilters extends FindParams, BaseFilterable<AdminRegionFilters> {
|
||||
q?: string
|
||||
id?: string | string[]
|
||||
code?: string | string[]
|
||||
currency_code?: string | string[]
|
||||
name?: string | string[]
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface BaseRegionFilters extends BaseFilterable<BaseRegionFilters> {
|
||||
q?: string
|
||||
id?: string[] | string | OperatorMap<string | string[]>
|
||||
name?: string | string[]
|
||||
code?: string | string[]
|
||||
currency_code?: string | string[]
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ import {
|
||||
BaseRegionFilters,
|
||||
} from "../common"
|
||||
|
||||
export interface StoreRegionFilters extends BaseRegionFilters {}
|
||||
export interface StoreRegionFilters extends Omit<BaseRegionFilters, "created_at" | "updated_at"> {}
|
||||
export interface StoreRegionCountryFilters extends BaseRegionCountryFilters {}
|
||||
|
||||
@@ -968,7 +968,7 @@ export interface OrderItemDTO {
|
||||
/**
|
||||
* The order's status.
|
||||
*/
|
||||
type OrderStatus =
|
||||
export type OrderStatus =
|
||||
| "pending"
|
||||
| "completed"
|
||||
| "draft"
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user