fix(medusa): import and use RequestQueryFields from types package (#7275)
Noticed that `RequestQueryFields` is defined in both the `medusa` and `types` package. Within the `medusa` package sometimes it uses the local type definition or the definition in `types`. This PR removes the type definition of `RequestQueryFields` in `medusa` and uses that in `types` instead.
This commit is contained in:
5
.changeset/gorgeous-fireants-share.md
Normal file
5
.changeset/gorgeous-fireants-share.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): import and use `RequestQueryFields` from types package
|
||||
@@ -201,11 +201,14 @@ export type QueryConfig<TEntity extends BaseEntity> = {
|
||||
export type RequestQueryFields = {
|
||||
/**
|
||||
* Comma-separated relations that should be expanded in the returned data.
|
||||
* @deprecated Use `fields` instead and the relations will be inferred
|
||||
*/
|
||||
expand?: string
|
||||
|
||||
/**
|
||||
* Comma-separated fields that should be included in the returned data.
|
||||
* if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.
|
||||
* without prefix it will replace the entire default fields.
|
||||
*/
|
||||
fields?: string
|
||||
|
||||
@@ -220,7 +223,7 @@ export type RequestQueryFields = {
|
||||
limit?: number
|
||||
|
||||
/**
|
||||
* Field to sort items in the list by.
|
||||
* The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
|
||||
*/
|
||||
order?: string
|
||||
}
|
||||
|
||||
@@ -132,37 +132,6 @@ export type QueryConfig<TEntity extends BaseEntity> = {
|
||||
isList?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
* Request parameters used to configure and paginate retrieved data.
|
||||
*/
|
||||
export type RequestQueryFields = {
|
||||
/**
|
||||
* Comma-separated relations that should be expanded in the returned data.
|
||||
* @deprecated Use `fields` instead and the relations will be inferred
|
||||
*/
|
||||
expand?: string
|
||||
/**
|
||||
* Comma-separated fields that should be included in the returned data.
|
||||
* if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.
|
||||
* without prefix it will replace the entire default fields.
|
||||
*/
|
||||
fields?: string
|
||||
/**
|
||||
* The number of items to skip when retrieving a list.
|
||||
*/
|
||||
offset?: number
|
||||
/**
|
||||
* Limit the number of items returned in the list.
|
||||
*/
|
||||
limit?: number
|
||||
/**
|
||||
* The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
|
||||
*/
|
||||
order?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CommonTypes } from "@medusajs/types"
|
||||
import { CommonTypes, RequestQueryFields } from "@medusajs/types"
|
||||
import { Request } from "express"
|
||||
import { MedusaContainer as coreMedusaContainer } from "medusa-core-utils"
|
||||
import { FindConfig, RequestQueryFields } from "./common"
|
||||
import { FindConfig } from "./common"
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
|
||||
@@ -5,10 +5,11 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { pick } from "lodash"
|
||||
import { MedusaError, isDefined } from "medusa-core-utils"
|
||||
import { RequestQueryFields } from "@medusajs/types"
|
||||
import { BaseEntity } from "../interfaces"
|
||||
import { featureFlagRouter } from "../loaders/feature-flags"
|
||||
import MedusaV2 from "../loaders/feature-flags/medusa-v2"
|
||||
import { FindConfig, QueryConfig, RequestQueryFields } from "../types/common"
|
||||
import { FindConfig, QueryConfig } from "../types/common"
|
||||
|
||||
export function pickByConfig<TModel extends BaseEntity>(
|
||||
obj: TModel | TModel[],
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { ValidatorOptions } from "class-validator"
|
||||
import { NextFunction, Request, Response } from "express"
|
||||
import { omit } from "lodash"
|
||||
import { RequestQueryFields } from "@medusajs/types"
|
||||
import { BaseEntity } from "../../interfaces"
|
||||
import { FindConfig, QueryConfig, RequestQueryFields } from "../../types/common"
|
||||
import { FindConfig, QueryConfig } from "../../types/common"
|
||||
import { ClassConstructor } from "../../types/global"
|
||||
import { removeUndefinedProperties } from "../../utils"
|
||||
import {
|
||||
|
||||
Reference in New Issue
Block a user