diff --git a/packages/core/core-flows/src/stock-location/workflows/update-stock-locations.ts b/packages/core/core-flows/src/stock-location/workflows/update-stock-locations.ts index a8cf12b4ce..4e368f0d90 100644 --- a/packages/core/core-flows/src/stock-location/workflows/update-stock-locations.ts +++ b/packages/core/core-flows/src/stock-location/workflows/update-stock-locations.ts @@ -1,5 +1,6 @@ import { FilterableStockLocationProps, + RemoteQueryFilters, StockLocationDTO, UpdateStockLocationInput, UpsertStockLocationAddressInput, @@ -32,10 +33,10 @@ export const updateStockLocationsWorkflowId = "update-stock-locations-workflow" /** * This workflow updates stock locations matching the specified filters. It's used by the * [Update Stock Location Admin API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsid). - * + * * You can use this workflow within your own customizations or custom workflows, allowing you * to update stock locations in your custom flows. - * + * * @example * const { result } = await updateStockLocationsWorkflow(container) * .run({ @@ -48,9 +49,9 @@ export const updateStockLocationsWorkflowId = "update-stock-locations-workflow" * } * } * }) - * + * * @summary - * + * * Update stock locations. */ export const updateStockLocationsWorkflow = createWorkflow( @@ -60,7 +61,7 @@ export const updateStockLocationsWorkflow = createWorkflow( ): WorkflowResponse => { const stockLocationsQuery = useQueryGraphStep({ entity: "stock_location", - filters: input.selector, + filters: input.selector as RemoteQueryFilters<"stock_location">, fields: ["id", "address.id"], }).config({ name: "get-stock-location" }) diff --git a/packages/core/types/src/modules-sdk/to-remote-query.ts b/packages/core/types/src/modules-sdk/to-remote-query.ts index dc78e0b7fc..18014a351e 100644 --- a/packages/core/types/src/modules-sdk/to-remote-query.ts +++ b/packages/core/types/src/modules-sdk/to-remote-query.ts @@ -45,10 +45,16 @@ type ExtractFiltersOperators< : never } +type RemoteQueryFilterOperators = { + $or?: (T & RemoteQueryFilterOperators)[] + $and?: (T & RemoteQueryFilterOperators)[] + $not?: T & RemoteQueryFilterOperators +} + /** * Extract all available filters from a remote entry point deeply */ -export type RemoteQueryFilters< +export type InternalRemoteQueryFilters< TEntry extends string, RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints, Exclusion extends string[] = [], @@ -70,3 +76,23 @@ export type RemoteQueryFilters< > : Record : never + +export type RemoteQueryFilters< + TEntry extends string, + RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints, + Exclusion extends string[] = [], + Lim extends number = Depth[3] +> = RemoteQueryFilterOperators< + InternalRemoteQueryFilters< + TEntry, + RemoteQueryEntryPointsLevel, + Exclusion, + Lim + > +> & + InternalRemoteQueryFilters< + TEntry, + RemoteQueryEntryPointsLevel, + Exclusion, + Lim + >