chore(medusa, interfaces): Uniformise class checks (#5869)
**What** One problem with local development can be the dependencies management. To mitigate that, transform checks from an instance of to value check as well as harmonize utils function to be part of the class as a static method instead of separate utilities. By using this approach we are not dependent of the origin of the class and therefore it should ease the user experience. **NOTE** As a next step to discuss, we should probably move the interfaces from the interfaces/medusa package to the utils package. Then we can deprecate the interfaces package and remove it at a later time
This commit is contained in:
@@ -3,6 +3,12 @@ import { SearchTypes } from "@medusajs/types"
|
||||
export abstract class AbstractSearchService
|
||||
implements SearchTypes.ISearchService
|
||||
{
|
||||
static _isSearchService = true
|
||||
|
||||
static isSearchService(obj) {
|
||||
return obj?.constructor?._isSearchService
|
||||
}
|
||||
|
||||
abstract readonly isDefault
|
||||
protected readonly options_: Record<string, unknown>
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
export * from "./abstract-service"
|
||||
export * from "./is-search-service"
|
||||
export * from "./search-relations"
|
||||
export * from "./index-types"
|
||||
export * from "./variant-keys"
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import { AbstractSearchService } from "./abstract-service"
|
||||
|
||||
export function isSearchService(obj: unknown): boolean {
|
||||
return obj instanceof AbstractSearchService
|
||||
}
|
||||
Reference in New Issue
Block a user