Remove unused QueryBuilderService (#2104)
**Issue number:** #2068 **What:** - removed unused query-builder service files - medusa/src/services/query-builder.js - medusa/src/services/__mocks__/query-builder.js - deleted export from medusa/src/services/index.ts - (extra) deleted documentation files related to QueryBuilderService (QueryBuilderService.md)
This commit is contained in:
1 parent
cbb7dd9787
commit
f5b41288f4
5 files changed
-144
No files matched your search
@@ -1,79 +0,0 @@
|
|||||||
# Class: QueryBuilderService
|
|
||||||
|
|
||||||
## Hierarchy
|
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
|
||||||
|
|
||||||
↳ **`QueryBuilderService`**
|
|
||||||
|
|
||||||
## Constructors
|
|
||||||
|
|
||||||
### constructor
|
|
||||||
|
|
||||||
• **new QueryBuilderService**()
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
BaseService.constructor
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
### buildFilterQuery
|
|
||||||
|
|
||||||
▸ **buildFilterQuery**(`filters`): `undefined` \| {}
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type |
|
|
||||||
| :------ | :------ |
|
|
||||||
| `filters` | `any` |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`undefined` \| {}
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
[packages/medusa/src/services/query-builder.js:25](https://github.com/medusajs/medusa/blob/f7a63f178/packages/medusa/src/services/query-builder.js#L25)
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### buildQuery
|
|
||||||
|
|
||||||
▸ **buildQuery**(`params`, `properties`): `Object`
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type |
|
|
||||||
| :------ | :------ |
|
|
||||||
| `params` | `any` |
|
|
||||||
| `properties` | `any` |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Object`
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
[packages/medusa/src/services/query-builder.js:5](https://github.com/medusajs/medusa/blob/f7a63f178/packages/medusa/src/services/query-builder.js#L5)
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### buildTextSearchQuery
|
|
||||||
|
|
||||||
▸ **buildTextSearchQuery**(`search`, `searchProperties`): `undefined` \| { `$or`: `any` = searchQuery }
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type |
|
|
||||||
| :------ | :------ |
|
|
||||||
| `search` | `any` |
|
|
||||||
| `searchProperties` | `any` |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`undefined` \| { `$or`: `any` = searchQuery }
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
[packages/medusa/src/services/query-builder.js:39](https://github.com/medusajs/medusa/blob/f7a63f178/packages/medusa/src/services/query-builder.js#L39)
|
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
- [ProductService](classes/ProductService.md)
|
- [ProductService](classes/ProductService.md)
|
||||||
- [ProductTypeService](classes/ProductTypeService.md)
|
- [ProductTypeService](classes/ProductTypeService.md)
|
||||||
- [ProductVariantService](classes/ProductVariantService.md)
|
- [ProductVariantService](classes/ProductVariantService.md)
|
||||||
- [QueryBuilderService](classes/QueryBuilderService.md)
|
|
||||||
- [RegionService](classes/RegionService.md)
|
- [RegionService](classes/RegionService.md)
|
||||||
- [ReturnReasonService](classes/ReturnReasonService.md)
|
- [ReturnReasonService](classes/ReturnReasonService.md)
|
||||||
- [ReturnService](classes/ReturnService.md)
|
- [ReturnService](classes/ReturnService.md)
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
export const QueryBuilderServiceMock = {
|
|
||||||
buildQuery: jest.fn().mockImplementation(data => {
|
|
||||||
return Promise.resolve()
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
|
|
||||||
const mock = jest.fn().mockImplementation(() => {
|
|
||||||
return QueryBuilderServiceMock
|
|
||||||
})
|
|
||||||
|
|
||||||
export default mock
|
|
||||||
@@ -27,7 +27,6 @@ export { default as ProductCollectionService } from "./product-collection"
|
|||||||
export { default as ProductService } from "./product"
|
export { default as ProductService } from "./product"
|
||||||
export { default as ProductTypeService } from "./product-type"
|
export { default as ProductTypeService } from "./product-type"
|
||||||
export { default as ProductVariantService } from "./product-variant"
|
export { default as ProductVariantService } from "./product-variant"
|
||||||
export { default as QueryBuilderService } from "./query-builder"
|
|
||||||
export { default as RegionService } from "./region"
|
export { default as RegionService } from "./region"
|
||||||
export { default as ReturnReasonService } from "./return-reason"
|
export { default as ReturnReasonService } from "./return-reason"
|
||||||
export { default as ReturnService } from "./return"
|
export { default as ReturnService } from "./return"
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import { BaseService } from "medusa-interfaces"
|
|
||||||
import _ from "lodash"
|
|
||||||
|
|
||||||
class QueryBuilderService extends BaseService {
|
|
||||||
buildQuery(params, properties) {
|
|
||||||
const textSearch = _.pick(params, ["q"])
|
|
||||||
const filters = _.pick(params, properties)
|
|
||||||
|
|
||||||
const textQuery = this.buildTextSearchQuery(textSearch, properties)
|
|
||||||
const filterQuery = this.buildFilterQuery(filters)
|
|
||||||
|
|
||||||
if (textQuery && filterQuery) {
|
|
||||||
return {
|
|
||||||
$and: [textQuery, filterQuery],
|
|
||||||
}
|
|
||||||
} else if (!textQuery && filterQuery) {
|
|
||||||
return filterQuery
|
|
||||||
} else if (textQuery && !filterQuery) {
|
|
||||||
return textQuery
|
|
||||||
} else {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildFilterQuery(filters) {
|
|
||||||
if (_.isEmpty(filters)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const filterQuery = {}
|
|
||||||
|
|
||||||
Object.keys(filters).map((filter) => {
|
|
||||||
filterQuery[filter] = filters[filter]
|
|
||||||
})
|
|
||||||
|
|
||||||
return filterQuery
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTextSearchQuery(search, searchProperties) {
|
|
||||||
if (_.isEmpty(search)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchQuery = searchProperties.map((s) => ({
|
|
||||||
[s]: new RegExp(search.q, "i"),
|
|
||||||
}))
|
|
||||||
|
|
||||||
return { $or: searchQuery }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default QueryBuilderService
|
|
||||||
Reference in new issue
Block a user