chore: Refactor and improve abstract module service factory (#7688)
* chore: Refactor and improve abstract module service factory * align naming * clean up some template args and tests * partially migrate modules * partially migrate modules * migrate more modules * migrate last modules * fix typings * rename interface * rename interface * fixes * fixes * rm local plain tests
This commit is contained in:
committed by
GitHub
parent
c57223a3a2
commit
d2a5201eeb
@@ -62,7 +62,7 @@ async function syncDatabaseProviders({
|
||||
const providerServiceRegistrationKey = lowerCaseFirst(
|
||||
NotificationProviderService.name
|
||||
)
|
||||
const providerService: ModulesSdkTypes.InternalModuleService<NotificationProvider> =
|
||||
const providerService: ModulesSdkTypes.IMedusaInternalService<NotificationProvider> =
|
||||
container.resolve(providerServiceRegistrationKey)
|
||||
|
||||
const logger = container.resolve(ContainerRegistrationKeys.LOGGER) ?? console
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
import {
|
||||
Context,
|
||||
DAL,
|
||||
NotificationTypes,
|
||||
INotificationModuleService,
|
||||
InternalModuleDeclaration,
|
||||
ModuleJoinerConfig,
|
||||
ModulesSdkTypes,
|
||||
NotificationTypes,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
InjectManager,
|
||||
InjectTransactionManager,
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
ModulesSdkUtils,
|
||||
promiseAll,
|
||||
MedusaError,
|
||||
} from "@medusajs/utils"
|
||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||
import NotificationProviderService from "./notification-provider"
|
||||
import { NotificationModel, NotificationProvider } from "@models"
|
||||
|
||||
const generateMethodForModels = [NotificationProvider]
|
||||
const generateMethodForModels = { NotificationProvider }
|
||||
|
||||
type InjectedDependencies = {
|
||||
baseRepository: DAL.RepositoryService
|
||||
notificationModelService: ModulesSdkTypes.InternalModuleService<any>
|
||||
notificationModelService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||
notificationProviderService: NotificationProviderService
|
||||
}
|
||||
|
||||
export default class NotificationModuleService<
|
||||
TEntity extends NotificationModel = NotificationModel
|
||||
>
|
||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
||||
InjectedDependencies,
|
||||
extends ModulesSdkUtils.MedusaService<
|
||||
NotificationTypes.NotificationDTO,
|
||||
{
|
||||
NotificationProvider: { dto: NotificationTypes.NotificationProviderDTO }
|
||||
@@ -40,7 +39,7 @@ export default class NotificationModuleService<
|
||||
implements INotificationModuleService
|
||||
{
|
||||
protected baseRepository_: DAL.RepositoryService
|
||||
protected readonly notificationService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
||||
protected readonly notificationService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||
protected readonly notificationProviderService_: NotificationProviderService
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Constructor, DAL, NotificationTypes } from "@medusajs/types"
|
||||
import { ModulesSdkUtils, MedusaError } from "@medusajs/utils"
|
||||
import { DAL, NotificationTypes } from "@medusajs/types"
|
||||
import { MedusaError, ModulesSdkUtils } from "@medusajs/utils"
|
||||
import { NotificationProvider } from "@models"
|
||||
import { NotificationProviderRegistrationPrefix } from "@types"
|
||||
|
||||
@@ -10,7 +10,7 @@ type InjectedDependencies = {
|
||||
]: NotificationTypes.INotificationProvider
|
||||
}
|
||||
|
||||
export default class NotificationProviderService extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
||||
export default class NotificationProviderService extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||
NotificationProvider
|
||||
) {
|
||||
protected readonly notificationProviderRepository_: DAL.RepositoryService<NotificationProvider>
|
||||
|
||||
Reference in New Issue
Block a user