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:
Adrien de Peretti
2023-12-19 13:26:57 +00:00
committed by GitHub
parent 496dcf10c4
commit 45996d58a2
27 changed files with 187 additions and 178 deletions
@@ -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>
-2
View File
@@ -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
}