Chore/rm main entity concept (#7709)

**What**
Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate.
This pr also includes various fixes in different modules

Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2024-06-19 15:02:16 +02:00
committed by GitHub
parent 2895ccfba8
commit 48963f55ef
533 changed files with 6469 additions and 9769 deletions

View File

@@ -41,20 +41,20 @@ medusaIntegrationTestRunner({
})
it("should query carts, sales channels, customers, regions with remote query", async () => {
const region = await regionModule.create({
const region = await regionModule.createRegions({
name: "Region",
currency_code: "usd",
})
const customer = await customerModule.create({
const customer = await customerModule.createCustomers({
email: "tony@stark.com",
})
const salesChannel = await scModuleService.create({
const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop",
})
const cart = await cartModuleService.create({
const cart = await cartModuleService.createCarts({
email: "tony@stark.com",
currency_code: "usd",
region_id: region.id,

View File

@@ -23,12 +23,12 @@ medusaIntegrationTestRunner({
})
it("should query carts and regions with remote query", async () => {
const region = await regionModule.create({
const region = await regionModule.createRegions({
name: "Region",
currency_code: "usd",
})
const cart = await cartModuleService.create({
const cart = await cartModuleService.createCarts({
email: "tony@stark.com",
currency_code: "usd",
region_id: region.id,

View File

@@ -1,8 +1,7 @@
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
import {
IFulfillmentModuleService,
ISalesChannelModuleService,
IStockLocationServiceNext,
IStockLocationService,
} from "@medusajs/types"
import {
ContainerRegistrationKeys,
@@ -20,8 +19,7 @@ medusaIntegrationTestRunner({
describe("FulfillmentSet and Location", () => {
let appContainer
let fulfillmentModule: IFulfillmentModuleService
let locationModule: IStockLocationServiceNext
let scService: ISalesChannelModuleService
let locationModule: IStockLocationService
let remoteQuery
let remoteLink
@@ -33,7 +31,6 @@ medusaIntegrationTestRunner({
locationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
scService = appContainer.resolve(ModuleRegistrationName.SALES_CHANNEL)
remoteQuery = appContainer.resolve(
ContainerRegistrationKeys.REMOTE_QUERY
)
@@ -41,12 +38,12 @@ medusaIntegrationTestRunner({
})
it("should query fulfillment set and location link with remote query", async () => {
const fulfillmentSet = await fulfillmentModule.create({
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test fulfillment set",
type: "delivery",
})
const euWarehouse = await locationModule.create({
const euWarehouse = await locationModule.createStockLocations({
name: "EU Warehouse",
})

View File

@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
})
it("should query product variants and price set link with remote query", async () => {
const [product] = await productModule.create([
const [product] = await productModule.createProducts([
{
title: "Test product",
variants: [
@@ -52,7 +52,7 @@ medusaIntegrationTestRunner({
},
])
const [priceSet1, priceSet2] = await pricingModule.create([
const [priceSet1, priceSet2] = await pricingModule.createPriceSets([
{
rules: [{ rule_attribute: "customer_group_id" }],
prices: [

View File

@@ -31,11 +31,11 @@ medusaIntegrationTestRunner({
})
it("should query api key and sales channels link with remote query", async () => {
const salesChannel = await scModuleService.create({
const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop",
})
const apiKeys = await apiKeyModule.create([
const apiKeys = await apiKeyModule.createApiKeys([
{
title: "Api key",
type: "publishable",

View File

@@ -1,7 +1,7 @@
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
import { IPaymentModuleService, IRegionModuleService } from "@medusajs/types"
import { IRegionModuleService } from "@medusajs/types"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import {ContainerRegistrationKeys} from "@medusajs/utils";
import { ContainerRegistrationKeys } from "@medusajs/utils"
jest.setTimeout(50000)
@@ -13,20 +13,20 @@ medusaIntegrationTestRunner({
describe("Region and Payment Providers", () => {
let appContainer
let regionModule: IRegionModuleService
let paymentModule: IPaymentModuleService
let remoteQuery
let remoteLink
beforeAll(async () => {
appContainer = getContainer()
regionModule = appContainer.resolve(ModuleRegistrationName.REGION)
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
remoteQuery = appContainer.resolve(
ContainerRegistrationKeys.REMOTE_QUERY
)
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
})
it("should query region and payment provider link with remote query", async () => {
const region = await regionModule.create({
const region = await regionModule.createRegions({
name: "North America",
currency_code: "usd",
})
@@ -87,7 +87,7 @@ medusaIntegrationTestRunner({
}),
expect.objectContaining({
id: "pp_system_default_2",
regions: []
regions: [],
}),
])
)

View File

@@ -30,23 +30,23 @@ medusaIntegrationTestRunner({
})
it("should query carts, sales channels, customers, regions with remote query", async () => {
const scWebshop = await scService.create({
const scWebshop = await scService.createSalesChannels({
name: "Webshop",
})
const scCphStore = await scService.create({
const scCphStore = await scService.createSalesChannels({
name: "CPH store",
})
const scNycStore = await scService.create({
const scNycStore = await scService.createSalesChannels({
name: "NYC store",
})
const euWarehouse = await locationService.create({
const euWarehouse = await locationService.createStockLocations({
name: "EU Warehouse",
})
const usWarehouse = await locationService.create({
const usWarehouse = await locationService.createStockLocations({
name: "US Warehouse",
})

View File

@@ -37,7 +37,7 @@ medusaIntegrationTestRunner({
name: "Test",
type: "default",
})
const fulfillmentSet = await fulfillmentModule.create({
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test",
type: "test-type",
})
@@ -65,7 +65,7 @@ medusaIntegrationTestRunner({
},
})
const priceSet = await pricingModule.create({
const priceSet = await pricingModule.createPriceSets({
prices: [
{
amount: 3000,

View File

@@ -25,7 +25,7 @@ medusaIntegrationTestRunner({
})
it("should query store and default currency with remote query", async () => {
const store = await storeModuleService.create({
const store = await storeModuleService.createStores({
name: "Store",
default_currency_code: "usd",
supported_currency_codes: ["usd"],