feat(utils): Support free text configuration (#6942)

**What**
- Add support for searchable entity properties to configure default free text search when providing a `q` filter
- `@Searchable` decorator to mark a property or relation to be searchable form the current entity

FIXES CORE-1910
This commit is contained in:
Adrien de Peretti
2024-04-05 13:59:40 +00:00
committed by GitHub
parent a0005faa14
commit 21990fcd4b
19 changed files with 424 additions and 205 deletions
@@ -1,21 +1,20 @@
import {
BeforeCreate,
Cascade,
Collection,
Entity,
Filter,
Formula,
OnInit,
OnLoad,
OneToMany,
OnInit,
OptionalProps,
PrimaryKey,
Property,
} from "@mikro-orm/core"
import {
DALUtils,
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
Searchable,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
@@ -64,6 +63,7 @@ export class InventoryItem {
deleted_at: Date | null = null
@InventoryItemSkuIndex.MikroORMIndex()
@Searchable()
@Property({ columnType: "text", nullable: true })
sku: string | null = null
@@ -94,9 +94,11 @@ export class InventoryItem {
@Property({ columnType: "boolean" })
requires_shipping: boolean = true
@Searchable()
@Property({ columnType: "text", nullable: true })
description: string | null = null
@Searchable()
@Property({ columnType: "text", nullable: true })
title: string | null = null