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:
committed by
GitHub
parent
2895ccfba8
commit
48963f55ef
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
})
|
||||
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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: [],
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
@@ -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",
|
||||
})
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user