fix(utils): Query filters API should have nested optional props (#13583)
This commit is contained in:
@@ -2,10 +2,19 @@ export interface SimpleProduct {
|
|||||||
id: string
|
id: string
|
||||||
title: string
|
title: string
|
||||||
description: string
|
description: string
|
||||||
|
variants: Variant[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Variant {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
sku: string
|
||||||
|
product_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FixtureEntryPoints {
|
export interface FixtureEntryPoints {
|
||||||
simple_product: SimpleProduct
|
simple_product: SimpleProduct
|
||||||
|
variant: Variant
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "@medusajs/types/dist/modules-sdk/remote-query-entry-points" {
|
declare module "@medusajs/types/dist/modules-sdk/remote-query-entry-points" {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import { MedusaContainer } from "@medusajs/framework"
|
||||||
|
import { asFunction, createContainer } from "@medusajs/framework/awilix"
|
||||||
|
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||||
import { createWorkflow, WorkflowResponse } from "@medusajs/workflows-sdk"
|
import { createWorkflow, WorkflowResponse } from "@medusajs/workflows-sdk"
|
||||||
import { expectTypeOf } from "expect-type"
|
import { expectTypeOf } from "expect-type"
|
||||||
import { FixtureEntryPoints } from "../__fixtures__/remote-query"
|
import { FixtureEntryPoints } from "../__fixtures__/remote-query"
|
||||||
import { useQueryGraphStep } from "../use-query-graph"
|
import { useQueryGraphStep } from "../use-query-graph"
|
||||||
import { MedusaContainer } from "@medusajs/framework"
|
|
||||||
import { asFunction, createContainer } from "@medusajs/framework/awilix"
|
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
|
||||||
|
|
||||||
describe("useQueryGraphStep", () => {
|
describe("useQueryGraphStep", () => {
|
||||||
let container!: MedusaContainer
|
let container!: MedusaContainer
|
||||||
@@ -28,6 +28,9 @@ describe("useQueryGraphStep", () => {
|
|||||||
fields: ["*"],
|
fields: ["*"],
|
||||||
filters: {
|
filters: {
|
||||||
id: "123",
|
id: "123",
|
||||||
|
variants: {
|
||||||
|
id: "123",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
isList: false,
|
isList: false,
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import { Prettify } from "../common"
|
import { Prettify as CorePrettify } from "../common"
|
||||||
import { OperatorMap } from "../dal"
|
import { OperatorMap } from "../dal"
|
||||||
import { RemoteQueryEntryPoints } from "./remote-query-entry-points"
|
import { RemoteQueryEntryPoints } from "./remote-query-entry-points"
|
||||||
|
|
||||||
|
type DeepPartial<T> = {
|
||||||
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
|
||||||
|
}
|
||||||
|
|
||||||
|
type Prettify<T> = DeepPartial<CorePrettify<T>>
|
||||||
type ExcludedProps = "__typename"
|
type ExcludedProps = "__typename"
|
||||||
type Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
type Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
type CleanupObject<T> = Prettify<Omit<Exclude<T, symbol>, ExcludedProps>>
|
type CleanupObject<T> = Prettify<Omit<Exclude<T, symbol>, ExcludedProps>>
|
||||||
@@ -83,16 +88,20 @@ export type RemoteQueryFilters<
|
|||||||
Exclusion extends string[] = [],
|
Exclusion extends string[] = [],
|
||||||
Lim extends number = Depth[3]
|
Lim extends number = Depth[3]
|
||||||
> = RemoteQueryFilterOperators<
|
> = RemoteQueryFilterOperators<
|
||||||
InternalRemoteQueryFilters<
|
DeepPartial<
|
||||||
TEntry,
|
InternalRemoteQueryFilters<
|
||||||
RemoteQueryEntryPointsLevel,
|
TEntry,
|
||||||
Exclusion,
|
RemoteQueryEntryPointsLevel,
|
||||||
Lim
|
Exclusion,
|
||||||
|
Lim
|
||||||
|
>
|
||||||
>
|
>
|
||||||
> &
|
> &
|
||||||
InternalRemoteQueryFilters<
|
DeepPartial<
|
||||||
TEntry,
|
InternalRemoteQueryFilters<
|
||||||
RemoteQueryEntryPointsLevel,
|
TEntry,
|
||||||
Exclusion,
|
RemoteQueryEntryPointsLevel,
|
||||||
Lim
|
Exclusion,
|
||||||
|
Lim
|
||||||
|
>
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user