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:
1 parent
496dcf10c4
commit
45996d58a2
27 files changed
+187
-178
No files matched your search
@@ -3,8 +3,15 @@ import BaseService from "./base-service"
|
||||
/**
|
||||
* Interface for file connectors
|
||||
* @interface
|
||||
* @deprecated use AbstractFileService from @medusajs/medusa instead
|
||||
*/
|
||||
class BaseFileService extends BaseService {
|
||||
static _isFileService = true
|
||||
|
||||
static isFileService(obj) {
|
||||
return obj?.constructor?._isFileService
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
@@ -5,8 +5,15 @@ import BaseService from "./base-service"
|
||||
* provides the necessary methods for creating, authorizing and managing
|
||||
* fulfillment orders.
|
||||
* @interface
|
||||
* @deprecated use AbstractFulfillmentService from @medusajs/medusa instead
|
||||
*/
|
||||
class BaseFulfillmentService extends BaseService {
|
||||
static _isFulfillmentService = true
|
||||
|
||||
static isFulfillmentService(obj) {
|
||||
return obj?.constructor?._isFulfillmentService
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
@@ -102,7 +109,7 @@ class BaseFulfillmentService extends BaseService {
|
||||
return []
|
||||
}
|
||||
|
||||
retrieveDocuments(fulfillmentData, documentType) {
|
||||
retrieveDocuments(fulfillmentData, documentType) {
|
||||
throw Error("retrieveDocuments must be overridden by the child class")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,15 @@ import BaseService from "./base-service"
|
||||
/**
|
||||
* Interface for Notification Providers
|
||||
* @interface
|
||||
* @deprecated use AbstractNotificationService from @medusajs/medusa instead
|
||||
*/
|
||||
class BaseNotificationService extends BaseService {
|
||||
static _isNotificationService = true
|
||||
|
||||
static isNotificationService(obj) {
|
||||
return obj?.constructor?._isNotificationService
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@ import BaseService from "./base-service"
|
||||
* @interface
|
||||
*/
|
||||
class BaseOauthService extends BaseService {
|
||||
static _isOauthService = true
|
||||
|
||||
static isOauthService(obj) {
|
||||
return obj?.constructor?._isOauthService
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
@@ -5,8 +5,15 @@ import BaseService from "./base-service"
|
||||
* provides the necessary methods for creating, authorizing and managing
|
||||
* payments.
|
||||
* @interface
|
||||
* @deprecated use AbstractPaymentProcessor from @medusajs/medusa instead
|
||||
*/
|
||||
class BasePaymentService extends BaseService {
|
||||
static _isPaymentService = true
|
||||
|
||||
static isPaymentService(obj) {
|
||||
return obj?.constructor?._isPaymentService
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
@@ -3,8 +3,15 @@ import BaseService from "./base-service"
|
||||
/**
|
||||
* The interface that all search services must implement.
|
||||
* @interface
|
||||
* @deprecated use AbstractSearchService from @medusajs/utils instead
|
||||
*/
|
||||
class SearchService extends BaseService {
|
||||
static _isSearchService = true
|
||||
|
||||
static isSearchService(obj) {
|
||||
return obj?.constructor?._isSearchService
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user