Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 10 commits into from
Sep 11, 2023
6 changes: 6 additions & 0 deletions .changeset/stupid-terms-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/link-modules": patch
"@medusajs/types": patch
---

fix(link-modules): Fix link module initialization
1 change: 1 addition & 0 deletions packages/link-modules/src/definitions/index.ts
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ export const ProductShippingProfile: ModuleJoinerConfig = {
},
{
serviceName: "shippingProfileService",
isInternalService: true,
primaryKey: "id",
foreignKey: "profile_id",
alias: "shipping_profile",
alias: "profile",
},
],
extends: [
Expand Down
12 changes: 8 additions & 4 deletions packages/link-modules/src/initialize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/modules-sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
deleteCascade?: boolean // If true, the link joiner will cascade deleting the relationship
}

Expand Down