refactor(modules-sdk): Align configuration and fixes (#9239)
* refactor(modules-sdk): Align configuration and fixes * typo * fix configuration
This commit is contained in:
@@ -129,7 +129,7 @@ describe("Medusa Modules", () => {
|
||||
} as InternalModuleDeclaration,
|
||||
})
|
||||
|
||||
const moduleB = await MedusaModule.bootstrap({
|
||||
await MedusaModule.bootstrap({
|
||||
moduleKey: "moduleKey",
|
||||
defaultPath: "@path",
|
||||
declaration: {
|
||||
@@ -146,7 +146,7 @@ describe("Medusa Modules", () => {
|
||||
})
|
||||
|
||||
it("should return the module flagged as 'main' when multiple instances are available", async () => {
|
||||
const moduleA = await MedusaModule.bootstrap({
|
||||
await MedusaModule.bootstrap({
|
||||
moduleKey: "moduleKey",
|
||||
defaultPath: "@path",
|
||||
declaration: {
|
||||
|
||||
@@ -2,11 +2,6 @@ import { createMedusaContainer } from "@medusajs/utils"
|
||||
import { asFunction, Lifetime } from "awilix"
|
||||
import { moduleProviderLoader } from "../module-provider-loader"
|
||||
|
||||
const logger = {
|
||||
warn: jest.fn(),
|
||||
error: jest.fn(),
|
||||
} as any
|
||||
|
||||
describe("modules loader", () => {
|
||||
let container
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -141,7 +141,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -221,7 +221,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual({
|
||||
serviceName: "module-without-joiner-config",
|
||||
@@ -296,7 +296,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual({
|
||||
serviceName: "module-service",
|
||||
|
||||
@@ -472,8 +472,7 @@ export class RemoteLink {
|
||||
|
||||
for (const link of allLinks) {
|
||||
const service = this.getLinkModuleOrThrow(link)
|
||||
const { moduleA, moduleB, moduleBKey, primaryKeys } =
|
||||
this.getLinkDataConfig(link)
|
||||
const { moduleA, moduleB } = this.getLinkDataConfig(link)
|
||||
|
||||
if (!serviceLinks.has(service.__definition.key)) {
|
||||
serviceLinks.set(service.__definition.key, [])
|
||||
|
||||
@@ -51,6 +51,16 @@ export type Product = {
|
||||
sales_channels_link?: Array<LinkProductSalesChannel>
|
||||
sales_channels?: Array<SalesChannel>
|
||||
metadata?: Maybe<Scalars["JSON"]["output"]>
|
||||
translation?: Maybe<ProductTranslation>
|
||||
categories?: Array<ProductCategory>
|
||||
}
|
||||
|
||||
export type ProductTranslation = {
|
||||
__typename?: "ProductTranslation"
|
||||
id: Scalars["ID"]["output"]
|
||||
title: Scalars["String"]["output"]
|
||||
description: Scalars["String"]["output"]
|
||||
product?: Maybe<Product>
|
||||
}
|
||||
|
||||
export type ProductVariant = {
|
||||
@@ -60,6 +70,16 @@ export type ProductVariant = {
|
||||
title: Scalars["String"]["output"]
|
||||
sku: Scalars["String"]["output"]
|
||||
product?: Maybe<Product>
|
||||
calculated_price?: Maybe<Scalars["JSON"]["output"]>
|
||||
translation?: Maybe<ProductVariantTranslation>
|
||||
}
|
||||
|
||||
export type ProductVariantTranslation = {
|
||||
__typename?: "ProductVariantTranslation"
|
||||
id: Scalars["ID"]["output"]
|
||||
title: Scalars["String"]["output"]
|
||||
description: Scalars["String"]["output"]
|
||||
variant?: Maybe<ProductVariant>
|
||||
}
|
||||
|
||||
export type ProductCategory = {
|
||||
@@ -67,6 +87,15 @@ export type ProductCategory = {
|
||||
id: Scalars["ID"]["output"]
|
||||
handle: Scalars["String"]["output"]
|
||||
title?: Maybe<Scalars["String"]["output"]>
|
||||
translation?: Maybe<ProductCategoryTranslation>
|
||||
}
|
||||
|
||||
export type ProductCategoryTranslation = {
|
||||
__typename?: "ProductCategoryTranslation"
|
||||
id: Scalars["ID"]["output"]
|
||||
title: Scalars["String"]["output"]
|
||||
description: Scalars["String"]["output"]
|
||||
category?: Maybe<ProductCategory>
|
||||
}
|
||||
|
||||
export type SalesChannel = {
|
||||
|
||||
@@ -107,7 +107,6 @@ describe("toRemoteQuery", () => {
|
||||
"description",
|
||||
"variants.title",
|
||||
"variants.calculated_price",
|
||||
"variants.options.*",
|
||||
],
|
||||
filters: {
|
||||
variants: {
|
||||
@@ -150,9 +149,6 @@ describe("toRemoteQuery", () => {
|
||||
},
|
||||
},
|
||||
__fields: ["title", "calculated_price"],
|
||||
options: {
|
||||
__fields: ["*"],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -172,22 +168,22 @@ describe("toRemoteQuery", () => {
|
||||
"id",
|
||||
"title",
|
||||
"description",
|
||||
"product_translation.*",
|
||||
"translation.*",
|
||||
"categories.*",
|
||||
"categories.category_translation.*",
|
||||
"categories.translation.*",
|
||||
"variants.*",
|
||||
"variants.variant_translation.*",
|
||||
"variants.translation.*",
|
||||
],
|
||||
filters: {
|
||||
id: "prod_01J742X0QPFW3R2ZFRTRC34FS8",
|
||||
},
|
||||
context: {
|
||||
product_translation: langContext,
|
||||
translation: langContext,
|
||||
categories: {
|
||||
category_translation: langContext,
|
||||
translation: langContext,
|
||||
},
|
||||
variants: {
|
||||
variant_translation: langContext,
|
||||
translation: langContext,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -202,7 +198,7 @@ describe("toRemoteQuery", () => {
|
||||
id: "prod_01J742X0QPFW3R2ZFRTRC34FS8",
|
||||
},
|
||||
},
|
||||
product_translation: {
|
||||
translation: {
|
||||
__args: {
|
||||
context: {
|
||||
context: {
|
||||
@@ -213,7 +209,7 @@ describe("toRemoteQuery", () => {
|
||||
__fields: ["*"],
|
||||
},
|
||||
categories: {
|
||||
category_translation: {
|
||||
translation: {
|
||||
__args: {
|
||||
context: {
|
||||
context: {
|
||||
@@ -226,7 +222,7 @@ describe("toRemoteQuery", () => {
|
||||
__fields: ["*"],
|
||||
},
|
||||
variants: {
|
||||
variant_translation: {
|
||||
translation: {
|
||||
__args: {
|
||||
context: {
|
||||
context: {
|
||||
|
||||
Reference in New Issue
Block a user