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:
@@ -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 = {
|
export type RequestQueryFields = {
|
||||||
/**
|
/**
|
||||||
* Comma-separated relations that should be expanded in the returned data.
|
* Comma-separated relations that should be expanded in the returned data.
|
||||||
|
* @deprecated Use `fields` instead and the relations will be inferred
|
||||||
*/
|
*/
|
||||||
expand?: string
|
expand?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comma-separated fields that should be included in the returned data.
|
* 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
|
fields?: string
|
||||||
|
|
||||||
@@ -220,7 +223,7 @@ export type RequestQueryFields = {
|
|||||||
limit?: number
|
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
|
order?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,37 +132,6 @@ export type QueryConfig<TEntity extends BaseEntity> = {
|
|||||||
isList?: boolean
|
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
|
* @interface
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CommonTypes } from "@medusajs/types"
|
import { CommonTypes, RequestQueryFields } from "@medusajs/types"
|
||||||
import { Request } from "express"
|
import { Request } from "express"
|
||||||
import { MedusaContainer as coreMedusaContainer } from "medusa-core-utils"
|
import { MedusaContainer as coreMedusaContainer } from "medusa-core-utils"
|
||||||
import { FindConfig, RequestQueryFields } from "./common"
|
import { FindConfig } from "./common"
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { pick } from "lodash"
|
import { pick } from "lodash"
|
||||||
import { MedusaError, isDefined } from "medusa-core-utils"
|
import { MedusaError, isDefined } from "medusa-core-utils"
|
||||||
|
import { RequestQueryFields } from "@medusajs/types"
|
||||||
import { BaseEntity } from "../interfaces"
|
import { BaseEntity } from "../interfaces"
|
||||||
import { featureFlagRouter } from "../loaders/feature-flags"
|
import { featureFlagRouter } from "../loaders/feature-flags"
|
||||||
import MedusaV2 from "../loaders/feature-flags/medusa-v2"
|
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>(
|
export function pickByConfig<TModel extends BaseEntity>(
|
||||||
obj: TModel | TModel[],
|
obj: TModel | TModel[],
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { ValidatorOptions } from "class-validator"
|
import { ValidatorOptions } from "class-validator"
|
||||||
import { NextFunction, Request, Response } from "express"
|
import { NextFunction, Request, Response } from "express"
|
||||||
import { omit } from "lodash"
|
import { omit } from "lodash"
|
||||||
|
import { RequestQueryFields } from "@medusajs/types"
|
||||||
import { BaseEntity } from "../../interfaces"
|
import { BaseEntity } from "../../interfaces"
|
||||||
import { FindConfig, QueryConfig, RequestQueryFields } from "../../types/common"
|
import { FindConfig, QueryConfig } from "../../types/common"
|
||||||
import { ClassConstructor } from "../../types/global"
|
import { ClassConstructor } from "../../types/global"
|
||||||
import { removeUndefinedProperties } from "../../utils"
|
import { removeUndefinedProperties } from "../../utils"
|
||||||
import {
|
import {
|
||||||
|
|||||||
Reference in New Issue
Block a user