fix(link-modules): Fix link module initialization (#4990)

**What**
Add a new configuration on the relationship to specify if the relation is consumed from an internal service (from medusa core). In that case do not check if the service is part of the loaded modules
This commit is contained in:
Adrien de Peretti
2023-09-11 10:49:23 +02:00
committed by GitHub
parent d971d5cf91
commit a87d07655b
5 changed files with 18 additions and 5 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"@medusajs/link-modules": patch
"@medusajs/types": patch
---
fix(link-modules): Fix link module initialization
@@ -1,3 +1,4 @@
export * from "./inventory-level-stock-location"
export * from "./product-variant-inventory-item"
export * from "./product-variant-money-amount"
export * from "./product-shipping-profile"
@@ -24,9 +24,10 @@ export const ProductShippingProfile: ModuleJoinerConfig = {
},
{
serviceName: "shippingProfileService",
isInternalService: true,
primaryKey: "id",
foreignKey: "profile_id",
alias: "shipping_profile",
alias: "profile",
},
],
extends: [
@@ -90,8 +90,10 @@ export const initialize = async (
continue
}
} else if (
!modulesLoadedKeys.includes(primary.serviceName) ||
!modulesLoadedKeys.includes(foreign.serviceName)
(!primary.isInternalService &&
!modulesLoadedKeys.includes(primary.serviceName)) ||
(!foreign.isInternalService &&
!modulesLoadedKeys.includes(foreign.serviceName))
) {
continue
}
@@ -176,8 +178,10 @@ export async function runMigrations(
allLinks.add(serviceKey)
if (
!modulesLoadedKeys.includes(primary.serviceName) ||
!modulesLoadedKeys.includes(foreign.serviceName)
(!primary.isInternalService &&
!modulesLoadedKeys.includes(primary.serviceName)) ||
(!foreign.isInternalService &&
!modulesLoadedKeys.includes(foreign.serviceName))
) {
continue
}
+1
View File
@@ -168,6 +168,7 @@ export type ModuleJoinerConfig = Omit<
}
export declare type ModuleJoinerRelationship = JoinerRelationship & {
isInternalService?: boolean // If true, the relationship is an internal service from the medusa core TODO: Remove when there are no more "internal" services
deleteCascade?: boolean // If true, the link joiner will cascade deleting the relationship
}