fix(medusa,types,js-sdk): fix request query parameter types for store product routes (#10707)
* fix(medusa,types): fix request query parameter types for store product routes * fix test errors
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/types": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"@medusajs/js-sdk": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa,types,js-sdk): fix request query parameter types for store product routes
|
||||||
@@ -401,7 +401,7 @@ export class Store {
|
|||||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
||||||
*/
|
*/
|
||||||
list: async (
|
list: async (
|
||||||
query?: HttpTypes.StoreProductParams,
|
query?: HttpTypes.StoreProductListParams,
|
||||||
headers?: ClientHeaders
|
headers?: ClientHeaders
|
||||||
) => {
|
) => {
|
||||||
return this.client.fetch<HttpTypes.StoreProductListResponse>(
|
return this.client.fetch<HttpTypes.StoreProductListResponse>(
|
||||||
@@ -451,7 +451,7 @@ export class Store {
|
|||||||
*/
|
*/
|
||||||
retrieve: async (
|
retrieve: async (
|
||||||
id: string,
|
id: string,
|
||||||
query?: SelectParams,
|
query?: HttpTypes.StoreProductParams,
|
||||||
headers?: ClientHeaders
|
headers?: ClientHeaders
|
||||||
) => {
|
) => {
|
||||||
return this.client.fetch<HttpTypes.StoreProductResponse>(
|
return this.client.fetch<HttpTypes.StoreProductResponse>(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { FindParams } from "../../common"
|
||||||
import {
|
import {
|
||||||
BaseProductListParams,
|
BaseProductListParams,
|
||||||
BaseProductOptionParams,
|
BaseProductOptionParams,
|
||||||
@@ -6,29 +7,34 @@ import {
|
|||||||
|
|
||||||
export interface StoreProductOptionParams extends BaseProductOptionParams {}
|
export interface StoreProductOptionParams extends BaseProductOptionParams {}
|
||||||
export interface StoreProductVariantParams extends BaseProductVariantParams {}
|
export interface StoreProductVariantParams extends BaseProductVariantParams {}
|
||||||
export interface StoreProductParams
|
export interface StoreProductPricingContext {
|
||||||
extends Omit<BaseProductListParams, "tags" | "status" | "categories" | "deleted_at"> {
|
/**
|
||||||
|
* The ID of the customer's region. This parameter must be included if you want to apply taxes on the product variant's price.
|
||||||
|
*/
|
||||||
|
region_id?: string
|
||||||
|
/**
|
||||||
|
* The customer's country code. This parameter must be included if you want to apply taxes on the product variant's price.
|
||||||
|
*/
|
||||||
|
country_code?: string
|
||||||
|
/**
|
||||||
|
* The province, which can be taken from a customer's address. This parameter helps further narrowing down the taxes applied on a the product variant's prices.
|
||||||
|
*/
|
||||||
|
province?: string
|
||||||
|
/**
|
||||||
|
* The ID of the customer's cart, if available. If set, the cart's region and shipping address's country code and province are used instead of the `region_id`, `country_code`, and `province` parameters.
|
||||||
|
*/
|
||||||
|
cart_id?: string
|
||||||
|
}
|
||||||
|
export interface StoreProductParams extends FindParams, StoreProductPricingContext {}
|
||||||
|
|
||||||
|
export interface StoreProductListParams
|
||||||
|
extends Omit<BaseProductListParams, "tags" | "status" | "categories" | "deleted_at">, StoreProductPricingContext {
|
||||||
/**
|
/**
|
||||||
* Filter by the product's tag(s).
|
* Filter by the product's tag(s).
|
||||||
*/
|
*/
|
||||||
tag_id?: string | string[]
|
tag_id?: string | string[]
|
||||||
/**
|
|
||||||
* The ID of the region the products are being viewed from. This is required if you're retrieving product variant prices with taxes.
|
|
||||||
*
|
|
||||||
* @privateRemarks
|
|
||||||
* 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
|
|
||||||
/**
|
|
||||||
* The currency code to retrieve prices in.
|
|
||||||
*/
|
|
||||||
currency_code?: string
|
|
||||||
/**
|
/**
|
||||||
* Filter by the product's variants.
|
* Filter by the product's variants.
|
||||||
*/
|
*/
|
||||||
variants?: Pick<StoreProductVariantParams, "options">
|
variants?: Pick<StoreProductVariantParams, "options">
|
||||||
/**
|
|
||||||
* The province the products are being viewed from. This is useful to narrow down the tax context when calculating product variant prices with taxes.
|
|
||||||
*/
|
|
||||||
province?: string
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,10 @@ import {
|
|||||||
RequestWithContext,
|
RequestWithContext,
|
||||||
wrapProductsWithTaxPrices,
|
wrapProductsWithTaxPrices,
|
||||||
} from "../helpers"
|
} from "../helpers"
|
||||||
import { StoreGetProductParamsType } from "../validators"
|
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: RequestWithContext<StoreGetProductParamsType>,
|
req: RequestWithContext<HttpTypes.StoreProductParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreProductResponse>
|
res: MedusaResponse<HttpTypes.StoreProductResponse>
|
||||||
) => {
|
) => {
|
||||||
const withInventoryQuantity = req.remoteQueryConfig.fields.some((field) =>
|
const withInventoryQuantity = req.remoteQueryConfig.fields.some((field) =>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { RequestWithContext, wrapProductsWithTaxPrices } from "./helpers"
|
|||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: RequestWithContext<HttpTypes.StoreProductParams>,
|
req: RequestWithContext<HttpTypes.StoreProductListParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreProductListResponse>
|
res: MedusaResponse<HttpTypes.StoreProductListResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|||||||
Reference in New Issue
Block a user