feat: refactor module joiner config and links generation (#7859)

* feat: refactor module joiner config and links generation

* improve typings

* WIP

* WIP

* WIP

* rename type file

* create link config

* finish typings and add utils

* improve links

* WIP typings

* finalize ExportModule utils

* finalize ExportModule utils

* fix: dml tests

* improve and fixes

* simplify typings with id changes

* add toJSON

* multiple fixes and entity builder fixes

* fix currency searchable

* fix tests

* medusa service refactoring

* cleanup

* cleanup and fixes

* make module name optional

* renaming

---------

Co-authored-by: Harminder Virk <virk.officials@gmail.com>
This commit is contained in:
Adrien de Peretti
2024-07-03 13:12:49 +02:00
committed by GitHub
parent 5aa62e59e4
commit 617a5972bf
89 changed files with 1706 additions and 950 deletions

View File

@@ -1,9 +1,4 @@
import {
buildEntitiesNameToLinkableKeysMap,
defineJoinerConfig,
MapToConfig,
Modules,
} from "@medusajs/utils"
import { defineJoinerConfig, Modules } from "@medusajs/utils"
import {
Payment,
PaymentCollection,
@@ -12,18 +7,10 @@ import {
} from "@models"
export const joinerConfig = defineJoinerConfig(Modules.PAYMENT, {
entityQueryingConfig: [
Payment,
PaymentCollection,
PaymentProvider,
PaymentSession,
],
models: [Payment, PaymentCollection, PaymentProvider, PaymentSession],
linkableKeys: {
payment_id: Payment.name,
payment_collection_id: PaymentCollection.name,
payment_provider_id: PaymentProvider.name,
},
})
export const entityNameToLinkableKeysMap: MapToConfig =
buildEntitiesNameToLinkableKeysMap(joinerConfig.linkableKeys)

View File

@@ -48,7 +48,7 @@ import {
PaymentSession,
Refund,
} from "@models"
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
import { joinerConfig } from "../joiner-config"
import PaymentProviderService from "./payment-provider"
type InjectedDependencies = {
@@ -76,7 +76,7 @@ export default class PaymentModuleService
Payment: { dto: PaymentDTO }
Capture: { dto: CaptureDTO }
Refund: { dto: RefundDTO }
}>(generateMethodForModels, entityNameToLinkableKeysMap)
}>(generateMethodForModels)
implements IPaymentModuleService
{
protected baseRepository_: DAL.RepositoryService