feat(medusa, stock-location-next): add list-stock-locations endpoint to api-v2 (#6788)
* initial create * add list for stock locations * add changeset * redo changes for stock locatino module' * add changeset * naming * prep for pr * move integration tests * fix pr feedback * add changeset * update changeset --------- Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
1 parent
a6562d2a41
commit
18438a695a
10 files changed
+288
-1
No files matched your search
@@ -1 +1,2 @@
|
||||
export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils"
|
||||
export { StockLocationRepository } from "./stock-location"
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Context, DAL } from "@medusajs/types"
|
||||
|
||||
import { StockLocation } from "@models"
|
||||
import { mikroOrmBaseRepositoryFactory } from "@medusajs/utils"
|
||||
|
||||
export class StockLocationRepository extends mikroOrmBaseRepositoryFactory<StockLocation>(
|
||||
StockLocation
|
||||
) {
|
||||
async find(
|
||||
findOptions: DAL.FindOptions<StockLocation & { q?: string }> = {
|
||||
where: {},
|
||||
},
|
||||
context: Context
|
||||
): Promise<StockLocation[]> {
|
||||
const findOptions_ = { ...findOptions }
|
||||
findOptions_.options ??= {}
|
||||
|
||||
this.applyFreeTextSearchFilters<StockLocation>(
|
||||
findOptions_,
|
||||
this.getFreeTextSearchConstraints
|
||||
)
|
||||
|
||||
return await super.find(findOptions_, context)
|
||||
}
|
||||
|
||||
async findAndCount(
|
||||
findOptions: DAL.FindOptions<StockLocation & { q?: string }> = {
|
||||
where: {},
|
||||
},
|
||||
context: Context
|
||||
): Promise<[StockLocation[], number]> {
|
||||
const findOptions_ = { ...findOptions }
|
||||
findOptions_.options ??= {}
|
||||
|
||||
this.applyFreeTextSearchFilters<StockLocation>(
|
||||
findOptions_,
|
||||
this.getFreeTextSearchConstraints
|
||||
)
|
||||
|
||||
return await super.findAndCount(findOptions_, context)
|
||||
}
|
||||
|
||||
protected getFreeTextSearchConstraints(q: string) {
|
||||
return [
|
||||
{
|
||||
name: {
|
||||
$ilike: `%${q}%`,
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
export { default as StockLocationModuleService } from "./stock-location"
|
||||
export { default as StockLocationModuleService } from "./stock-location-module"
|
||||
Reference in new issue
Block a user