refactor: migrate store module to DML (#10467)

This commit is contained in:
Harminder Virk
2024-12-06 17:38:15 +05:30
committed by GitHub
parent 7e04091b49
commit f3c91c908a
6 changed files with 79 additions and 175 deletions

View File

@@ -1,6 +1,7 @@
import {
Context,
DAL,
InferEntityType,
InternalModuleDeclaration,
IStoreModuleService,
ModulesSdkTypes,
@@ -34,7 +35,9 @@ export default class StoreModuleService
implements IStoreModuleService
{
protected baseRepository_: DAL.RepositoryService
protected readonly storeService_: ModulesSdkTypes.IMedusaInternalService<Store>
protected readonly storeService_: ModulesSdkTypes.IMedusaInternalService<
InferEntityType<typeof Store>
>
constructor(
{ baseRepository, storeService }: InjectedDependencies,
@@ -73,7 +76,7 @@ export default class StoreModuleService
async create_(
data: StoreTypes.CreateStoreDTO[],
@MedusaContext() sharedContext: Context = {}
): Promise<Store[]> {
): Promise<InferEntityType<typeof Store>[]> {
let normalizedInput = StoreModuleService.normalizeInput(data)
StoreModuleService.validateCreateRequest(normalizedInput)
@@ -107,7 +110,7 @@ export default class StoreModuleService
(store): store is StoreTypes.CreateStoreDTO => !store.id
)
const operations: Promise<Store[]>[] = []
const operations: Promise<InferEntityType<typeof Store>[]>[] = []
if (forCreate.length) {
operations.push(this.create_(forCreate, sharedContext))
@@ -168,7 +171,7 @@ export default class StoreModuleService
protected async update_(
data: UpdateStoreInput[],
@MedusaContext() sharedContext: Context = {}
): Promise<Store[]> {
): Promise<InferEntityType<typeof Store>[]> {
const normalizedInput = StoreModuleService.normalizeInput(data)
StoreModuleService.validateUpdateRequest(normalizedInput)