feat(medusa,inventory,types): Expand list-reservation capabilities (#3979)

**What**
- Add filter capabilities to reservation items based on: 
  - description query: "contains", "startsWith", "endsWith", "equals"
  - date querying

**How**
- Introducing a new filtering primitive: "StringSearchOperator" resembling the "dateComparisonOperator"

Fixes CORE-1373
This commit is contained in:
Philip Korsholm
2023-05-24 10:54:25 +01:00
committed by GitHub
parent 3d1eb3f4d4
commit 3a38c84f88
11 changed files with 386 additions and 17 deletions

View File

@@ -1,4 +1,3 @@
import { ExtendedFindConfig, FindConfig } from "@medusajs/types"
import {
And,
FindManyOptions,
@@ -6,6 +5,7 @@ import {
FindOptionsRelations,
FindOptionsSelect,
FindOptionsWhere,
ILike,
In,
IsNull,
LessThan,
@@ -13,6 +13,8 @@ import {
MoreThan,
MoreThanOrEqual,
} from "typeorm"
import { ExtendedFindConfig, FindConfig } from "@medusajs/types"
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
import { isObject } from "./is-object"
@@ -120,6 +122,15 @@ function buildWhere<TWhereKeys extends object, TEntity>(
case "gte":
where[key].push(MoreThanOrEqual(objectValue))
break
case "contains":
where[key].push(ILike(`%${objectValue}%`))
break
case "starts_with":
where[key].push(ILike(`${objectValue}%`))
break
case "ends_with":
where[key].push(ILike(`%${objectValue}`))
break
default:
if (objectValue != undefined && typeof objectValue === "object") {
where[key] = buildWhere<any, TEntity>(objectValue)