fix(types,medusa): fix query types for some store routes (#8994)
This commit is contained in:
1 parent
c424d397f6
commit
4b1827ed48
15 files changed
+19
-23
No files matched your search
@@ -1,8 +1,9 @@
|
|||||||
import { BaseFilterable } from "../../../dal";
|
import { BaseFilterable } from "../../../dal";
|
||||||
|
import { OrderStatus } from "../../../order";
|
||||||
import { FindParams } from "../../common";
|
import { FindParams } from "../../common";
|
||||||
|
|
||||||
export interface StoreOrderFilters extends
|
export interface StoreOrderFilters extends
|
||||||
FindParams, BaseFilterable<StoreOrderFilters> {
|
FindParams, BaseFilterable<StoreOrderFilters> {
|
||||||
id?: string | string[]
|
id?: string | string[]
|
||||||
name?: string | string[]
|
status?: OrderStatus | OrderStatus[]
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,9 @@ import {
|
|||||||
BasePaymentSessionFilters,
|
BasePaymentSessionFilters,
|
||||||
} from "../common"
|
} from "../common"
|
||||||
|
|
||||||
export interface StorePaymentProviderFilters
|
export interface StorePaymentProviderFilters {
|
||||||
extends BasePaymentProviderFilters {
|
region_id: string
|
||||||
is_enabled?: boolean
|
}
|
||||||
}
|
|
||||||
export interface StorePaymentCollectionFilters
|
export interface StorePaymentCollectionFilters
|
||||||
extends BasePaymentCollectionFilters {}
|
extends BasePaymentCollectionFilters {}
|
||||||
export interface StorePaymentSessionFilters extends BasePaymentSessionFilters {}
|
export interface StorePaymentSessionFilters extends BasePaymentSessionFilters {}
|
||||||
@@ -4,6 +4,6 @@ import {
|
|||||||
} from "../common"
|
} from "../common"
|
||||||
|
|
||||||
export interface StoreProductCategoryListParams
|
export interface StoreProductCategoryListParams
|
||||||
extends BaseProductCategoryListParams {}
|
extends Omit<BaseProductCategoryListParams, "is_internal" | "is_active"> {}
|
||||||
|
|
||||||
export interface StoreProductCategoryParams extends BaseProductCategoryParams {}
|
export interface StoreProductCategoryParams extends BaseProductCategoryParams {}
|
||||||
@@ -6,7 +6,8 @@ import {
|
|||||||
|
|
||||||
export interface StoreProductOptionParams extends BaseProductOptionParams {}
|
export interface StoreProductOptionParams extends BaseProductOptionParams {}
|
||||||
export interface StoreProductVariantParams extends BaseProductVariantParams {}
|
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.
|
// 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
|
region_id?: string
|
||||||
currency_code?: string
|
currency_code?: string
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import {
|
|||||||
BaseRegionFilters,
|
BaseRegionFilters,
|
||||||
} from "../common"
|
} from "../common"
|
||||||
|
|
||||||
export interface AdminRegionFilters extends FindParams, BaseFilterable<BaseRegionFilters> {
|
export interface AdminRegionFilters extends FindParams, BaseFilterable<AdminRegionFilters> {
|
||||||
q?: string
|
q?: string
|
||||||
id?: string | string[]
|
id?: string | string[]
|
||||||
code?: string | string[]
|
currency_code?: string | string[]
|
||||||
name?: string | string[]
|
name?: string | string[]
|
||||||
created_at?: OperatorMap<string>
|
created_at?: OperatorMap<string>
|
||||||
updated_at?: OperatorMap<string>
|
updated_at?: OperatorMap<string>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export interface BaseRegionFilters extends BaseFilterable<BaseRegionFilters> {
|
|||||||
q?: string
|
q?: string
|
||||||
id?: string[] | string | OperatorMap<string | string[]>
|
id?: string[] | string | OperatorMap<string | string[]>
|
||||||
name?: string | string[]
|
name?: string | string[]
|
||||||
code?: string | string[]
|
currency_code?: string | string[]
|
||||||
created_at?: OperatorMap<string>
|
created_at?: OperatorMap<string>
|
||||||
updated_at?: OperatorMap<string>
|
updated_at?: OperatorMap<string>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ import {
|
|||||||
BaseRegionFilters,
|
BaseRegionFilters,
|
||||||
} from "../common"
|
} from "../common"
|
||||||
|
|
||||||
export interface StoreRegionFilters extends BaseRegionFilters {}
|
export interface StoreRegionFilters extends Omit<BaseRegionFilters, "created_at" | "updated_at"> {}
|
||||||
export interface StoreRegionCountryFilters extends BaseRegionCountryFilters {}
|
export interface StoreRegionCountryFilters extends BaseRegionCountryFilters {}
|
||||||
@@ -968,7 +968,7 @@ export interface OrderItemDTO {
|
|||||||
/**
|
/**
|
||||||
* The order's status.
|
* The order's status.
|
||||||
*/
|
*/
|
||||||
type OrderStatus =
|
export type OrderStatus =
|
||||||
| "pending"
|
| "pending"
|
||||||
| "completed"
|
| "completed"
|
||||||
| "draft"
|
| "draft"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const AdminGetRegionsParams = createFindParams({
|
|||||||
z.object({
|
z.object({
|
||||||
q: z.string().optional(),
|
q: z.string().optional(),
|
||||||
id: z.union([z.string(), z.array(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(),
|
name: z.union([z.string(), z.array(z.string())]).optional(),
|
||||||
created_at: createOperatorMap().optional(),
|
created_at: createOperatorMap().optional(),
|
||||||
updated_at: createOperatorMap().optional(),
|
updated_at: createOperatorMap().optional(),
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export type StoreGetCustomerAddressParamsType = z.infer<
|
|||||||
typeof StoreGetCustomerAddressParams
|
typeof StoreGetCustomerAddressParams
|
||||||
>
|
>
|
||||||
export type StoreGetCustomerAddressesParamsType = z.infer<
|
export type StoreGetCustomerAddressesParamsType = z.infer<
|
||||||
typeof StoreCreateCustomerAddress
|
typeof StoreGetCustomerAddressesParams
|
||||||
>
|
>
|
||||||
export type StoreCreateCustomerAddressType = z.infer<
|
export type StoreCreateCustomerAddressType = z.infer<
|
||||||
typeof StoreCreateCustomerAddress
|
typeof StoreCreateCustomerAddress
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { HttpTypes } from "@medusajs/types"
|
import { HttpTypes } from "@medusajs/types"
|
||||||
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
||||||
import { refetchOrder } from "../helpers"
|
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
|
// TODO: Do we want to apply some sort of authentication here? My suggestion is that we do
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest<StoreGetOrdersParamsType>,
|
req: MedusaRequest,
|
||||||
res: MedusaResponse<HttpTypes.StoreOrderResponse>
|
res: MedusaResponse<HttpTypes.StoreOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const order = await refetchOrder(
|
const order = await refetchOrder(
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { booleanString } from "../../utils/common-validators"
|
|
||||||
import { createFindParams } from "../../utils/validators"
|
import { createFindParams } from "../../utils/validators"
|
||||||
|
|
||||||
export type StoreGetPaymentProvidersParamsType = z.infer<
|
export type StoreGetPaymentProvidersParamsType = z.infer<
|
||||||
@@ -11,9 +10,5 @@ export const StoreGetPaymentProvidersParams = createFindParams({
|
|||||||
}).merge(
|
}).merge(
|
||||||
z.object({
|
z.object({
|
||||||
region_id: z.string(),
|
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(
|
const category = await refetchEntity(
|
||||||
"product_category",
|
"product_category",
|
||||||
req.params.id,
|
{ id: req.params.id, ...req.filterableFields },
|
||||||
req.scope,
|
req.scope,
|
||||||
req.remoteQueryConfig.fields
|
req.remoteQueryConfig.fields
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export const StoreProductCategoriesParams = createFindParams({
|
|||||||
z.object({
|
z.object({
|
||||||
q: z.string().optional(),
|
q: z.string().optional(),
|
||||||
id: z.union([z.string(), z.array(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(),
|
description: z.union([z.string(), z.array(z.string())]).optional(),
|
||||||
handle: 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(),
|
parent_category_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const StoreGetRegionsParams = createFindParams({
|
|||||||
z.object({
|
z.object({
|
||||||
q: z.string().optional(),
|
q: z.string().optional(),
|
||||||
id: z.union([z.string(), z.array(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(),
|
name: z.union([z.string(), z.array(z.string())]).optional(),
|
||||||
$and: z.lazy(() => StoreGetRegionsParams.array()).optional(),
|
$and: z.lazy(() => StoreGetRegionsParams.array()).optional(),
|
||||||
$or: z.lazy(() => StoreGetRegionsParams.array()).optional(),
|
$or: z.lazy(() => StoreGetRegionsParams.array()).optional(),
|
||||||
|
|||||||
Reference in new issue
Block a user