chore(modules-sdk): Custom Module definition (#7315)

This commit is contained in:
Carlos R. L. Rodrigues
2024-05-14 06:59:14 -03:00
committed by GitHub
parent bf83d1cfe6
commit e2dfe91071
6 changed files with 35 additions and 80 deletions
@@ -16,7 +16,6 @@ describe("module definitions loader", () => {
registrationName: "testService",
defaultPackage: "@medusajs/test-service",
label: "TestService",
isLegacy: true,
isRequired: false,
defaultModuleDeclaration: {
scope: MODULE_SCOPE.INTERNAL,
@@ -55,6 +55,13 @@ async function loadModule(
loaderOnly?: boolean
): Promise<{ error?: Error } | void> {
const modDefinition = resolution.definition
if (!modDefinition.key) {
throw new Error(`Module definition is missing property "key"`)
}
modDefinition.registrationName ??= modDefinition.key
const registrationName = modDefinition.registrationName
const { scope, resources } = resolution.moduleDeclaration ?? ({} as any)