feat: deprecate remoteQueryConfig in favor of queryConfig (#10773)
Fixes: FRMW-2783
This commit is contained in:
@@ -107,7 +107,7 @@ describe("validateAndTransformQuery", () => {
|
||||
],
|
||||
order: transformedOrder,
|
||||
})
|
||||
expect(mockRequest.remoteQueryConfig).toEqual({
|
||||
expect(mockRequest.queryConfig).toEqual({
|
||||
fields: [
|
||||
"id",
|
||||
"created_at",
|
||||
@@ -387,7 +387,7 @@ describe("validateAndTransformQuery", () => {
|
||||
],
|
||||
})
|
||||
)
|
||||
expect(mockRequest.remoteQueryConfig).toEqual(
|
||||
expect(mockRequest.queryConfig).toEqual(
|
||||
expect.objectContaining({
|
||||
fields: [
|
||||
"id",
|
||||
@@ -447,7 +447,7 @@ describe("validateAndTransformQuery", () => {
|
||||
relations: ["store"],
|
||||
})
|
||||
)
|
||||
expect(mockRequest.remoteQueryConfig).toEqual(
|
||||
expect(mockRequest.queryConfig).toEqual(
|
||||
expect.objectContaining({
|
||||
fields: ["store.name", "id"],
|
||||
})
|
||||
|
||||
@@ -15,10 +15,7 @@ export function applyDefaultFilters<TFilter extends object>(
|
||||
// Currently we only need it to delete filter keys from the request filter object, but this could
|
||||
// be used for other purposes. If we can't find other purposes, we can refactor to accept an array
|
||||
// of strings to delete after filters have been applied.
|
||||
valueToApply = filterValue(
|
||||
req.filterableFields,
|
||||
req.remoteQueryConfig.fields
|
||||
)
|
||||
valueToApply = filterValue(req.filterableFields, req.queryConfig.fields)
|
||||
}
|
||||
|
||||
// If the value to apply is an object, we add it to any existing filters thats already applied
|
||||
|
||||
@@ -108,13 +108,20 @@ export interface MedusaRequest<
|
||||
* An object containing the select, relation to be used with medusa internal services
|
||||
*/
|
||||
retrieveConfig: FindConfig<unknown>
|
||||
|
||||
/**
|
||||
* An object containing fields and variables to be used with the remoteQuery
|
||||
*/
|
||||
remoteQueryConfig: {
|
||||
queryConfig: {
|
||||
fields: string[]
|
||||
pagination: { order?: Record<string, string>; skip: number; take?: number }
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated. Instead use "req.queryConfig"
|
||||
*/
|
||||
remoteQueryConfig: MedusaRequest["queryConfig"]
|
||||
|
||||
/**
|
||||
* An object containing the fields that are filterable e.g `{ id: Any<String> }`
|
||||
*/
|
||||
@@ -163,14 +170,18 @@ export interface PublishableKeyContext {
|
||||
sales_channel_ids: string[]
|
||||
}
|
||||
|
||||
export interface AuthenticatedMedusaRequest<Body = unknown, QueryFields = Record<string, unknown>>
|
||||
extends MedusaRequest<Body, QueryFields> {
|
||||
export interface AuthenticatedMedusaRequest<
|
||||
Body = unknown,
|
||||
QueryFields = Record<string, unknown>
|
||||
> extends MedusaRequest<Body, QueryFields> {
|
||||
auth_context: AuthContext
|
||||
publishable_key_context?: PublishableKeyContext
|
||||
}
|
||||
|
||||
export interface MedusaStoreRequest<Body = unknown, QueryFields = Record<string, unknown>>
|
||||
extends MedusaRequest<Body, QueryFields> {
|
||||
export interface MedusaStoreRequest<
|
||||
Body = unknown,
|
||||
QueryFields = Record<string, unknown>
|
||||
> extends MedusaRequest<Body, QueryFields> {
|
||||
auth_context?: AuthContext
|
||||
publishable_key_context: PublishableKeyContext
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export const refetchEntities = async (
|
||||
idOrFilter: string | object,
|
||||
scope: MedusaContainer,
|
||||
fields: string[],
|
||||
pagination?: MedusaRequest["remoteQueryConfig"]["pagination"]
|
||||
pagination?: MedusaRequest["queryConfig"]["pagination"]
|
||||
) => {
|
||||
const remoteQuery = scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
const filters = isString(idOrFilter) ? { id: idOrFilter } : idOrFilter
|
||||
|
||||
@@ -90,7 +90,8 @@ export function validateAndTransformQuery<TEntity extends BaseEntity>(
|
||||
|
||||
req.validatedQuery = validated
|
||||
req.filterableFields = getFilterableFields(req.validatedQuery)
|
||||
req.remoteQueryConfig = cnf.remoteQueryConfig as any
|
||||
req.queryConfig = cnf.remoteQueryConfig as any
|
||||
req.remoteQueryConfig = req.queryConfig
|
||||
req.listConfig = (cnf as any).listConfig
|
||||
req.retrieveConfig = (cnf as any).retrieveConfig
|
||||
|
||||
|
||||
Reference in New Issue
Block a user