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:
authored and GitHub committed 2024-06-19 13:02:16 +00:00
1 parent 2895ccfba8
commit 48963f55ef
533 files changed
+5819 -9119

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ inputs:
node-version: node-version:
description: "Node version" description: "Node version"
required: false required: false
default: "16.10.0" default: "20.0.0"
cache-extension: cache-extension:
description: "Extension for fetching cached dependencies" description: "Extension for fetching cached dependencies"
required: true required: true
@@ -20,18 +20,22 @@ export const createAdminUser = async (
const authModule: IAuthModuleService = appContainer.resolve( const authModule: IAuthModuleService = appContainer.resolve(
ModuleRegistrationName.AUTH ModuleRegistrationName.AUTH
) )
const user = await userModule.create({ const user = await userModule.createUsers({
first_name: "Admin", first_name: "Admin",
last_name: "User", last_name: "User",
email: "admin@medusa.js", email: "admin@medusa.js",
}) })
const authIdentity = await authModule.create({ const authIdentity = await authModule.createAuthIdentities({
provider_identities: [
{
provider: "emailpass", provider: "emailpass",
entity_id: "admin@medusa.js", entity_id: "admin@medusa.js",
provider_metadata: { provider_metadata: {
password: "somepassword", password: "somepassword",
}, },
},
],
app_metadata: { app_metadata: {
user_id: user.id, user_id: user.id,
}, },
@@ -20,14 +20,14 @@ export const seedStorefrontDefaults = async (
// Creates the stores & default sales channel // Creates the stores & default sales channel
await createDefaultsWorkflow(container).run() await createDefaultsWorkflow(container).run()
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "Default Region", name: "Default Region",
currency_code: defaultCurrency, currency_code: defaultCurrency,
}) })
let [store] = await storeModule.list({}) let [store] = await storeModule.listStores({})
store = await storeModule.update(store.id, { store = await storeModule.updateStores(store.id, {
default_region_id: region.id, default_region_id: region.id,
supported_currency_codes: [region.currency_code], supported_currency_codes: [region.currency_code],
default_currency_code: region.currency_code, default_currency_code: region.currency_code,
@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
const fulfillmentModule: IFulfillmentModuleService = const fulfillmentModule: IFulfillmentModuleService =
getContainer().resolve(ModuleRegistrationName.FULFILLMENT) getContainer().resolve(ModuleRegistrationName.FULFILLMENT)
fulfillmentSet1 = await fulfillmentModule.create({ fulfillmentSet1 = await fulfillmentModule.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "pickup", type: "pickup",
}) })
@@ -91,10 +91,10 @@ medusaIntegrationTestRunner({
const defaultId = (await api.get("/admin/stores", adminHeaders)).data const defaultId = (await api.get("/admin/stores", adminHeaders)).data
.stores?.[0]?.id .stores?.[0]?.id
if (defaultId) { if (defaultId) {
storeModule.delete(defaultId) storeModule.deleteStores(defaultId)
} }
store = await storeModule.create({ store = await storeModule.createStores({
name: "New store", name: "New store",
supported_currency_codes: ["usd", "dkk"], supported_currency_codes: ["usd", "dkk"],
default_currency_code: "usd", default_currency_code: "usd",
@@ -532,13 +532,13 @@ medusaIntegrationTestRunner({
) )
const service = appContainer.resolve(ModuleRegistrationName.STORE) const service = appContainer.resolve(ModuleRegistrationName.STORE)
const [store] = await service.list() const [store] = await service.listStores()
if (store) { if (store) {
await service.delete(store.id) await service.deleteStores(store.id)
} }
await service.create({ await service.createStores({
supported_currency_codes: ["usd", "dkk"], supported_currency_codes: ["usd", "dkk"],
default_currency_code: "usd", default_currency_code: "usd",
default_sales_channel_id: defaultSalesChannel.id, default_sales_channel_id: defaultSalesChannel.id,
@@ -969,13 +969,13 @@ medusaIntegrationTestRunner({
) )
const service = appContainer.resolve(ModuleRegistrationName.STORE) const service = appContainer.resolve(ModuleRegistrationName.STORE)
const [store] = await service.list() const [store] = await service.listStores()
if (store) { if (store) {
await service.delete(store.id) await service.deleteStores(store.id)
} }
await service.create({ await service.createStores({
supported_currency_codes: ["usd", "dkk"], supported_currency_codes: ["usd", "dkk"],
default_currency_code: "usd", default_currency_code: "usd",
default_sales_channel_id: defaultSalesChannel.id, default_sales_channel_id: defaultSalesChannel.id,
@@ -301,7 +301,7 @@ medusaIntegrationTestRunner({
const fulfillmentModule = getContainer().resolve( const fulfillmentModule = getContainer().resolve(
ModuleRegistrationName.FULFILLMENT ModuleRegistrationName.FULFILLMENT
) )
const sets = await fulfillmentModule.list() const sets = await fulfillmentModule.listFulfillmentSets()
expect(sets).toHaveLength(0) expect(sets).toHaveLength(0)
}) })
@@ -25,10 +25,10 @@ medusaIntegrationTestRunner({
const defaultId = (await api.get("/admin/stores", adminHeaders)).data const defaultId = (await api.get("/admin/stores", adminHeaders)).data
.stores?.[0]?.id .stores?.[0]?.id
if (defaultId) { if (defaultId) {
storeModule.delete(defaultId) await storeModule.deleteStores(defaultId)
} }
store = await storeModule.create({ store = await storeModule.createStores({
name: "New store", name: "New store",
supported_currency_codes: ["usd", "dkk"], supported_currency_codes: ["usd", "dkk"],
default_currency_code: "usd", default_currency_code: "usd",
@@ -1,5 +1,5 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk" import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { IAuthModuleService, ICustomerModuleService } from "@medusajs/types" import { IAuthModuleService } from "@medusajs/types"
import Scrypt from "scrypt-kdf" import Scrypt from "scrypt-kdf"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
import { import {
@@ -16,13 +16,8 @@ medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => { testSuite: ({ dbConnection, getContainer, api }) => {
describe("POST /auth/emailpass", () => { describe("POST /auth/emailpass", () => {
let appContainer let appContainer
let customerModuleService: ICustomerModuleService
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
customerModuleService = appContainer.resolve(
ModuleRegistrationName.CUSTOMER
)
}) })
beforeEach(async () => { beforeEach(async () => {
@@ -40,7 +35,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.AUTH ModuleRegistrationName.AUTH
) )
await authService.create({ await authService.createAuthIdentities({
provider_identities: [ provider_identities: [
{ {
provider: "emailpass", provider: "emailpass",
@@ -75,7 +70,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.AUTH ModuleRegistrationName.AUTH
) )
await authService.create({ await authService.createAuthIdentities({
provider_identities: [ provider_identities: [
{ {
provider: "emailpass", provider: "emailpass",
@@ -40,7 +40,8 @@ medusaIntegrationTestRunner({
describe("POST /store/carts/:id/promotions", () => { describe("POST /store/carts/:id/promotions", () => {
it("should add line item adjustments to a cart based on promotions", async () => { it("should add line item adjustments to a cart based on promotions", async () => {
const appliedPromotion = await promotionModuleService.create({ const appliedPromotion =
await promotionModuleService.createPromotions({
code: "PROMOTION_APPLIED", code: "PROMOTION_APPLIED",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -61,7 +62,8 @@ medusaIntegrationTestRunner({
}, },
}) })
const createdPromotion = await promotionModuleService.create({ const createdPromotion =
await promotionModuleService.createPromotions({
code: "PROMOTION_TEST", code: "PROMOTION_TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -81,7 +83,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
items: [ items: [
// Adjustment to add // Adjustment to add
@@ -152,7 +154,8 @@ medusaIntegrationTestRunner({
}) })
it("should add shipping method adjustments to a cart based on promotions", async () => { it("should add shipping method adjustments to a cart based on promotions", async () => {
const [appliedPromotion] = await promotionModuleService.create([ const [appliedPromotion] =
await promotionModuleService.createPromotions([
{ {
code: "PROMOTION_APPLIED", code: "PROMOTION_APPLIED",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
@@ -186,7 +189,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const [newPromotion] = await promotionModuleService.create([ const [newPromotion] = await promotionModuleService.createPromotions([
{ {
code: "PROMOTION_NEW", code: "PROMOTION_NEW",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
@@ -220,7 +223,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "eur", currency_code: "eur",
customer_id: "cus_test", customer_id: "cus_test",
items: [ items: [
@@ -18,13 +18,13 @@ import {
ICartModuleService, ICartModuleService,
ICustomerModuleService, ICustomerModuleService,
IFulfillmentModuleService, IFulfillmentModuleService,
IInventoryServiceNext, IInventoryService,
IPaymentModuleService, IPaymentModuleService,
IPricingModuleService, IPricingModuleService,
IProductModuleService, IProductModuleService,
IRegionModuleService, IRegionModuleService,
ISalesChannelModuleService, ISalesChannelModuleService,
IStockLocationServiceNext, IStockLocationService,
} from "@medusajs/types" } from "@medusajs/types"
import { ContainerRegistrationKeys, RuleOperator } from "@medusajs/utils" import { ContainerRegistrationKeys, RuleOperator } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
@@ -50,10 +50,9 @@ medusaIntegrationTestRunner({
let productModule: IProductModuleService let productModule: IProductModuleService
let pricingModule: IPricingModuleService let pricingModule: IPricingModuleService
let paymentModule: IPaymentModuleService let paymentModule: IPaymentModuleService
let inventoryModule: IInventoryServiceNext let stockLocationModule: IStockLocationService
let stockLocationModule: IStockLocationServiceNext let inventoryModule: IInventoryService
let fulfillmentModule: IFulfillmentModuleService let fulfillmentModule: IFulfillmentModuleService
let locationModule: IStockLocationServiceNext
let remoteLink, remoteQuery let remoteLink, remoteQuery
let defaultRegion let defaultRegion
@@ -78,9 +77,6 @@ medusaIntegrationTestRunner({
fulfillmentModule = appContainer.resolve( fulfillmentModule = appContainer.resolve(
ModuleRegistrationName.FULFILLMENT ModuleRegistrationName.FULFILLMENT
) )
locationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK) remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
remoteQuery = appContainer.resolve( remoteQuery = appContainer.resolve(
ContainerRegistrationKeys.REMOTE_QUERY ContainerRegistrationKeys.REMOTE_QUERY
@@ -97,20 +93,20 @@ medusaIntegrationTestRunner({
describe("CreateCartWorkflow", () => { describe("CreateCartWorkflow", () => {
it("should create a cart", async () => { it("should create a cart", async () => {
const region = await regionModuleService.create({ const region = await regionModuleService.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -121,7 +117,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -134,7 +130,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -185,7 +181,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const cart = await cartModuleService.retrieve(result.id, { const cart = await cartModuleService.retrieveCart(result.id, {
relations: ["items"], relations: ["items"],
}) })
@@ -207,20 +203,20 @@ medusaIntegrationTestRunner({
}) })
it("should revert if the cart creation fails", async () => { it("should revert if the cart creation fails", async () => {
const region = await regionModuleService.create({ const region = await regionModuleService.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -231,7 +227,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -244,7 +240,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -314,7 +310,7 @@ medusaIntegrationTestRunner({
}) })
it("should throw when no regions exist", async () => { it("should throw when no regions exist", async () => {
await regionModuleService.delete(defaultRegion.id) await regionModuleService.deleteRegions(defaultRegion.id)
const { errors } = await createCartWorkflow(appContainer).run({ const { errors } = await createCartWorkflow(appContainer).run({
input: { input: {
@@ -332,15 +328,15 @@ medusaIntegrationTestRunner({
}) })
it("should throw if variants are out of stock", async () => { it("should throw if variants are out of stock", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -379,12 +375,12 @@ medusaIntegrationTestRunner({
adminHeaders adminHeaders
) )
const region = await regionModuleService.create({ const region = await regionModuleService.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -448,7 +444,7 @@ medusaIntegrationTestRunner({
}) })
it("should throw if sales channel is disabled", async () => { it("should throw if sales channel is disabled", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
is_disabled: true, is_disabled: true,
}) })
@@ -500,7 +496,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const customers = await customerModule.list({ const customers = await customerModule.listCustomers({
email: "tony@stark-industries.com", email: "tony@stark-industries.com",
}) })
@@ -517,7 +513,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const customer = await customerModule.create({ const customer = await customerModule.createCustomers({
email: "tony@stark-industries.com", email: "tony@stark-industries.com",
}) })
@@ -539,7 +535,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const customers = await customerModule.list({ const customers = await customerModule.listCustomers({
email: "tony@stark-industries.com", email: "tony@stark-industries.com",
}) })
@@ -550,20 +546,20 @@ medusaIntegrationTestRunner({
describe("AddToCartWorkflow", () => { describe("AddToCartWorkflow", () => {
it("should add item to cart", async () => { it("should add item to cart", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
let cart = await cartModuleService.create({ let cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
sales_channel_id: salesChannel.id, sales_channel_id: salesChannel.id,
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -574,7 +570,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -587,7 +583,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -623,7 +619,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
select: ["id", "region_id", "currency_code", "sales_channel_id"], select: ["id", "region_id", "currency_code", "sales_channel_id"],
}) })
@@ -639,7 +635,7 @@ medusaIntegrationTestRunner({
}, },
}) })
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
relations: ["items"], relations: ["items"],
}) })
@@ -659,20 +655,20 @@ medusaIntegrationTestRunner({
}) })
it("should throw if no price sets for variant exist", async () => { it("should throw if no price sets for variant exist", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
let cart = await cartModuleService.create({ let cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
sales_channel_id: salesChannel.id, sales_channel_id: salesChannel.id,
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -683,7 +679,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -742,7 +738,7 @@ medusaIntegrationTestRunner({
}) })
it("should throw if variant does not exist", async () => { it("should throw if variant does not exist", async () => {
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
}) })
@@ -774,15 +770,15 @@ medusaIntegrationTestRunner({
describe("updateLineItemInCartWorkflow", () => { describe("updateLineItemInCartWorkflow", () => {
it("should update item in cart", async () => { it("should update item in cart", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -793,7 +789,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -806,7 +802,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -842,7 +838,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
let cart = await cartModuleService.create({ let cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
sales_channel_id: salesChannel.id, sales_channel_id: salesChannel.id,
items: [ items: [
@@ -855,7 +851,7 @@ medusaIntegrationTestRunner({
], ],
}) })
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
select: ["id", "region_id", "currency_code"], select: ["id", "region_id", "currency_code"],
relations: ["items", "items.variant_id", "items.metadata"], relations: ["items", "items.variant_id", "items.metadata"],
}) })
@@ -901,15 +897,15 @@ medusaIntegrationTestRunner({
}, },
}) })
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -920,7 +916,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -933,7 +929,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -969,7 +965,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
let cart = await cartModuleService.create({ let cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
items: [ items: [
{ {
@@ -981,7 +977,7 @@ medusaIntegrationTestRunner({
], ],
}) })
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
select: ["id", "region_id", "currency_code"], select: ["id", "region_id", "currency_code"],
relations: ["items", "items.variant_id", "items.metadata"], relations: ["items", "items.variant_id", "items.metadata"],
}) })
@@ -1031,7 +1027,7 @@ medusaIntegrationTestRunner({
describe("deleteLineItems", () => { describe("deleteLineItems", () => {
it("should delete items in cart", async () => { it("should delete items in cart", async () => {
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
items: [ items: [
{ {
@@ -1072,7 +1068,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
items: [ items: [
{ {
@@ -1115,7 +1111,7 @@ medusaIntegrationTestRunner({
describe("createPaymentCollectionForCart", () => { describe("createPaymentCollectionForCart", () => {
it("should create a payment collection and link it to cart", async () => { it("should create a payment collection and link it to cart", async () => {
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "dkk", currency_code: "dkk",
region_id: defaultRegion.id, region_id: defaultRegion.id,
items: [ items: [
@@ -1181,12 +1177,12 @@ medusaIntegrationTestRunner({
} }
) )
const region = await regionModuleService.create({ const region = await regionModuleService.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
items: [ items: [
@@ -1253,7 +1249,7 @@ medusaIntegrationTestRunner({
describe("refreshPaymentCollectionForCart", () => { describe("refreshPaymentCollectionForCart", () => {
it("should refresh a payment collection for a cart", async () => { it("should refresh a payment collection for a cart", async () => {
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "dkk", currency_code: "dkk",
region_id: defaultRegion.id, region_id: defaultRegion.id,
items: [ items: [
@@ -1320,12 +1316,12 @@ medusaIntegrationTestRunner({
describe("compensation", () => { describe("compensation", () => {
it("should revert payment collection amount and create a new payment session", async () => { it("should revert payment collection amount and create a new payment session", async () => {
const region = await regionModuleService.create({ const region = await regionModuleService.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const testCart = await cartModuleService.create({ const testCart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
items: [ items: [
@@ -1431,7 +1427,7 @@ medusaIntegrationTestRunner({
let priceSet let priceSet
beforeEach(async () => { beforeEach(async () => {
cart = await cartModuleService.create({ cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
shipping_address: { shipping_address: {
country_code: "us", country_code: "us",
@@ -1444,7 +1440,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
fulfillmentSet = await fulfillmentModule.create({ fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -1455,7 +1451,7 @@ medusaIntegrationTestRunner({
], ],
}) })
priceSet = await pricingModule.create({ priceSet = await pricingModule.createPriceSets({
prices: [{ amount: 3000, currency_code: "usd" }], prices: [{ amount: 3000, currency_code: "usd" }],
}) })
}) })
@@ -1500,7 +1496,7 @@ medusaIntegrationTestRunner({
}, },
}) })
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
relations: ["shipping_methods"], relations: ["shipping_methods"],
}) })
@@ -1592,15 +1588,15 @@ medusaIntegrationTestRunner({
describe("listShippingOptionsForCartWorkflow", () => { describe("listShippingOptionsForCartWorkflow", () => {
it("should list shipping options for cart", async () => { it("should list shipping options for cart", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await locationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Europe", name: "Europe",
}) })
let cart = await cartModuleService.create({ let cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
sales_channel_id: salesChannel.id, sales_channel_id: salesChannel.id,
shipping_address: { shipping_address: {
@@ -1616,7 +1612,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentModule.create({ const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -1645,7 +1641,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -1681,7 +1677,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
select: ["id"], select: ["id"],
relations: ["shipping_address"], relations: ["shipping_address"],
}) })
@@ -1711,15 +1707,15 @@ medusaIntegrationTestRunner({
}) })
it("should list no shipping options for cart, if sales channel is not associated with location", async () => { it("should list no shipping options for cart, if sales channel is not associated with location", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await locationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Europe", name: "Europe",
}) })
let cart = await cartModuleService.create({ let cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
sales_channel_id: salesChannel.id, sales_channel_id: salesChannel.id,
shipping_address: { shipping_address: {
@@ -1735,7 +1731,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentModule.create({ const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -1764,7 +1760,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -1792,7 +1788,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
select: ["id"], select: ["id"],
relations: ["shipping_address"], relations: ["shipping_address"],
}) })
@@ -1816,15 +1812,15 @@ medusaIntegrationTestRunner({
}) })
it("should throw when shipping options are missing prices", async () => { it("should throw when shipping options are missing prices", async () => {
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await locationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Europe", name: "Europe",
}) })
let cart = await cartModuleService.create({ let cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
sales_channel_id: salesChannel.id, sales_channel_id: salesChannel.id,
shipping_address: { shipping_address: {
@@ -1840,7 +1836,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentModule.create({ const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -1888,7 +1884,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
cart = await cartModuleService.retrieve(cart.id, { cart = await cartModuleService.retrieveCart(cart.id, {
select: ["id"], select: ["id"],
relations: ["shipping_address"], relations: ["shipping_address"],
}) })
@@ -98,16 +98,16 @@ medusaIntegrationTestRunner({
describe("POST /store/carts", () => { describe("POST /store/carts", () => {
it("should create a cart", async () => { it("should create a cart", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -123,7 +123,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const [priceSet, priceSetTwo] = await pricingModule.create([ const [priceSet, priceSetTwo] = await pricingModule.createPriceSets([
{ {
prices: [ prices: [
{ {
@@ -209,7 +209,7 @@ medusaIntegrationTestRunner({
it("should create cart with customer from email and tax lines", async () => { it("should create cart with customer from email and tax lines", async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product default tax", title: "Test product default tax",
variants: [ variants: [
@@ -218,11 +218,11 @@ medusaIntegrationTestRunner({
}, },
]) ])
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const [priceSet] = await pricingModule.create([ const [priceSet] = await pricingModule.createPriceSets([
{ prices: [{ amount: 3000, currency_code: "usd" }] }, { prices: [{ amount: 3000, currency_code: "usd" }] },
]) ])
@@ -281,7 +281,7 @@ medusaIntegrationTestRunner({
}) })
it("should create cart with any region", async () => { it("should create cart with any region", async () => {
await regionModule.create({ await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
@@ -305,11 +305,11 @@ medusaIntegrationTestRunner({
}) })
it("should create cart with default store sales channel", async () => { it("should create cart with default store sales channel", async () => {
const sc = await scModule.create({ const sc = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
await storeService.update(store.id, { await storeService.updateStores(store.id, {
default_sales_channel_id: sc.id, default_sales_channel_id: sc.id,
}) })
@@ -330,7 +330,7 @@ medusaIntegrationTestRunner({
}) })
it("should create cart with region currency code", async () => { it("should create cart with region currency code", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
@@ -381,15 +381,15 @@ medusaIntegrationTestRunner({
}) })
it("throws if publishable key is not associated with sales channel", async () => { it("throws if publishable key is not associated with sales channel", async () => {
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Retail Store", name: "Retail Store",
}) })
const salesChannel2 = await scModule.create({ const salesChannel2 = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const pubKey = await apiKeyModule.create({ const pubKey = await apiKeyModule.createApiKeys({
title: "Test key", title: "Test key",
type: "publishable", type: "publishable",
created_by: "test", created_by: "test",
@@ -426,15 +426,15 @@ medusaIntegrationTestRunner({
}) })
it("throws if publishable key has multiple associated sales channels", async () => { it("throws if publishable key has multiple associated sales channels", async () => {
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Retail Store", name: "Retail Store",
}) })
const salesChannel2 = await scModule.create({ const salesChannel2 = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const pubKey = await apiKeyModule.create({ const pubKey = await apiKeyModule.createApiKeys({
title: "Test key", title: "Test key",
type: "publishable", type: "publishable",
created_by: "test", created_by: "test",
@@ -469,11 +469,11 @@ medusaIntegrationTestRunner({
}) })
it("should create cart with sales channel if pub key does not have any scopes defined", async () => { it("should create cart with sales channel if pub key does not have any scopes defined", async () => {
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Retail Store", name: "Retail Store",
}) })
const pubKey = await apiKeyModule.create({ const pubKey = await apiKeyModule.createApiKeys({
title: "Test key", title: "Test key",
type: "publishable", type: "publishable",
created_by: "test", created_by: "test",
@@ -498,11 +498,11 @@ medusaIntegrationTestRunner({
}) })
it("should create cart with sales channel associated with pub key", async () => { it("should create cart with sales channel associated with pub key", async () => {
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Retail Store", name: "Retail Store",
}) })
const pubKey = await apiKeyModule.create({ const pubKey = await apiKeyModule.createApiKeys({
title: "Test key", title: "Test key",
type: "publishable", type: "publishable",
created_by: "test", created_by: "test",
@@ -545,7 +545,7 @@ medusaIntegrationTestRunner({
it("should update a cart with promo codes with a replace action", async () => { it("should update a cart with promo codes with a replace action", async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
@@ -558,7 +558,7 @@ medusaIntegrationTestRunner({
}, },
] ]
const appliedPromotion = await promotionModule.create({ const appliedPromotion = await promotionModule.createPromotions({
code: "PROMOTION_APPLIED", code: "PROMOTION_APPLIED",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -573,7 +573,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const createdPromotion = await promotionModule.create({ const createdPromotion = await promotionModule.createPromotions({
code: "PROMOTION_TEST", code: "PROMOTION_TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -587,7 +587,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
email: "tony@stark.com", email: "tony@stark.com",
region_id: region.id, region_id: region.id,
@@ -686,13 +686,13 @@ medusaIntegrationTestRunner({
it("should not generate tax lines if region is not present or automatic taxes is false", async () => { it("should not generate tax lines if region is not present or automatic taxes is false", async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
automatic_taxes: false, automatic_taxes: false,
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
email: "tony@stark.com", email: "tony@stark.com",
shipping_address: { shipping_address: {
@@ -732,7 +732,7 @@ medusaIntegrationTestRunner({
}) })
) )
await cartModule.update(cart.id, { await cartModule.updateCarts(cart.id, {
region_id: region.id, region_id: region.id,
}) })
@@ -758,16 +758,16 @@ medusaIntegrationTestRunner({
it("should update a cart's region, sales channel, customer data and tax lines", async () => { it("should update a cart's region, sales channel, customer data and tax lines", async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "us", name: "us",
currency_code: "usd", currency_code: "usd",
}) })
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "eur", currency_code: "eur",
email: "tony@stark.com", email: "tony@stark.com",
shipping_address: { shipping_address: {
@@ -795,7 +795,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentModule.create({ const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -967,12 +967,12 @@ medusaIntegrationTestRunner({
it("should remove invalid shipping methods", async () => { it("should remove invalid shipping methods", async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
region_id: region.id, region_id: region.id,
currency_code: "eur", currency_code: "eur",
email: "tony@stark.com", email: "tony@stark.com",
@@ -992,7 +992,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentModule.create({ const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -1101,12 +1101,12 @@ medusaIntegrationTestRunner({
describe("POST /store/carts/:id", () => { describe("POST /store/carts/:id", () => {
it("should create and update a cart", async () => { it("should create and update a cart", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
@@ -1151,16 +1151,16 @@ medusaIntegrationTestRunner({
describe("GET /store/carts", () => { describe("GET /store/carts", () => {
it("should get cart", async () => { it("should get cart", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
items: [ items: [
{ {
@@ -1250,22 +1250,22 @@ medusaIntegrationTestRunner({
beforeEach(async () => { beforeEach(async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
region = await regionModule.create({ region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
}) })
it("should add item to cart", async () => { it("should add item to cart", async () => {
const customer = await customerModule.create({ const customer = await customerModule.createCustomers({
email: "tony@stark-industries.com", email: "tony@stark-industries.com",
}) })
const salesChannel = await scModule.create({ const salesChannel = await scModule.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const [productWithSpecialTax] = await productModule.create([ const [productWithSpecialTax] = await productModule.createProducts([
{ {
// This product ID is setup in the tax structure fixture (setupTaxStructure) // This product ID is setup in the tax structure fixture (setupTaxStructure)
id: "product_id_1", id: "product_id_1",
@@ -1274,7 +1274,7 @@ medusaIntegrationTestRunner({
} as any, } as any,
]) ])
const [productWithDefaultTax] = await productModule.create([ const [productWithDefaultTax] = await productModule.createProducts([
{ {
title: "Test product default tax", title: "Test product default tax",
variants: [ variants: [
@@ -1283,7 +1283,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
customer_id: customer.id, customer_id: customer.id,
sales_channel_id: salesChannel.id, sales_channel_id: salesChannel.id,
@@ -1308,7 +1308,7 @@ medusaIntegrationTestRunner({
], ],
}) })
const appliedPromotion = await promotionModule.create({ const appliedPromotion = await promotionModule.createPromotions({
code: "PROMOTION_APPLIED", code: "PROMOTION_APPLIED",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -1337,7 +1337,8 @@ medusaIntegrationTestRunner({
}, },
]) ])
const [priceSet, priceSetDefaultTax] = await pricingModule.create([ const [priceSet, priceSetDefaultTax] =
await pricingModule.createPriceSets([
{ {
prices: [{ amount: 3000, currency_code: "usd" }], prices: [{ amount: 3000, currency_code: "usd" }],
}, },
@@ -1520,12 +1521,12 @@ medusaIntegrationTestRunner({
describe("POST /store/payment-collections", () => { describe("POST /store/payment-collections", () => {
it("should create a payment collection for the cart", async () => { it("should create a payment collection for the cart", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
}) })
@@ -1547,12 +1548,12 @@ medusaIntegrationTestRunner({
}) })
it("should return an existing payment collection for the cart", async () => { it("should return an existing payment collection for the cart", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
}) })
@@ -1580,17 +1581,17 @@ medusaIntegrationTestRunner({
}) })
it("should create a new payment collection for a new cart", async () => { it("should create a new payment collection for a new cart", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const firstCart = await cartModule.create({ const firstCart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
}) })
const secondCart = await cartModule.create({ const secondCart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
}) })
@@ -1622,13 +1623,13 @@ medusaIntegrationTestRunner({
it("should update a carts tax lines when region.automatic_taxes is false", async () => { it("should update a carts tax lines when region.automatic_taxes is false", async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
automatic_taxes: false, automatic_taxes: false,
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
shipping_address: { shipping_address: {
@@ -1679,13 +1680,13 @@ medusaIntegrationTestRunner({
it("should throw error when shipping is not present", async () => { it("should throw error when shipping is not present", async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
automatic_taxes: false, automatic_taxes: false,
}) })
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
items: [ items: [
@@ -1713,7 +1714,7 @@ medusaIntegrationTestRunner({
describe("POST /store/carts/:id/shipping-methods", () => { describe("POST /store/carts/:id/shipping-methods", () => {
it("should add a shipping methods to a cart", async () => { it("should add a shipping methods to a cart", async () => {
const cart = await cartModule.create({ const cart = await cartModule.createCarts({
currency_code: "usd", currency_code: "usd",
shipping_address: { country_code: "us" }, shipping_address: { country_code: "us" },
items: [], items: [],
@@ -1725,7 +1726,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentModule.create({ const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -1736,7 +1737,7 @@ medusaIntegrationTestRunner({
], ],
}) })
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [{ amount: 3000, currency_code: "usd" }], prices: [{ amount: 3000, currency_code: "usd" }],
}) })
@@ -1809,7 +1810,7 @@ medusaIntegrationTestRunner({
beforeEach(async () => { beforeEach(async () => {
await setupTaxStructure(taxModule) await setupTaxStructure(taxModule)
region = await regionService.create({ region = await regionService.createRegions({
name: "Test region", name: "Test region",
countries: ["US"], countries: ["US"],
currency_code: "usd", currency_code: "usd",
@@ -1861,7 +1862,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
fulfillmentSet = await fulfillmentModule.create({ fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -40,7 +40,8 @@ medusaIntegrationTestRunner({
describe("DELETE /store/carts/:id/promotions", () => { describe("DELETE /store/carts/:id/promotions", () => {
it("should remove line item adjustments from a cart based on promotions", async () => { it("should remove line item adjustments from a cart based on promotions", async () => {
const appliedPromotion = await promotionModuleService.create({ const appliedPromotion =
await promotionModuleService.createPromotions({
code: "PROMOTION_APPLIED", code: "PROMOTION_APPLIED",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -61,7 +62,8 @@ medusaIntegrationTestRunner({
}, },
}) })
const appliedPromotionToRemove = await promotionModuleService.create({ const appliedPromotionToRemove =
await promotionModuleService.createPromotions({
code: "PROMOTION_APPLIED_TO_REMOVE", code: "PROMOTION_APPLIED_TO_REMOVE",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -82,7 +84,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "usd", currency_code: "usd",
items: [ items: [
{ {
@@ -170,7 +172,8 @@ medusaIntegrationTestRunner({
}) })
it("should add shipping method adjustments to a cart based on promotions", async () => { it("should add shipping method adjustments to a cart based on promotions", async () => {
const appliedPromotion = await promotionModuleService.create({ const appliedPromotion =
await promotionModuleService.createPromotions({
code: "PROMOTION_APPLIED", code: "PROMOTION_APPLIED",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
rules: [ rules: [
@@ -202,7 +205,8 @@ medusaIntegrationTestRunner({
}, },
}) })
const appliedPromotionToRemove = await promotionModuleService.create({ const appliedPromotionToRemove =
await promotionModuleService.createPromotions({
code: "PROMOTION_APPLIED_TO_REMOVE", code: "PROMOTION_APPLIED_TO_REMOVE",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
rules: [ rules: [
@@ -234,7 +238,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
currency_code: "eur", currency_code: "eur",
customer_id: "cus_test", customer_id: "cus_test",
items: [ items: [
@@ -29,10 +29,10 @@ medusaIntegrationTestRunner({
}) })
it("should batch add customers to a group", async () => { it("should batch add customers to a group", async () => {
const group = await customerModuleService.createCustomerGroup({ const group = await customerModuleService.createCustomerGroups({
name: "VIP", name: "VIP",
}) })
const customers = await customerModuleService.create([ const customers = await customerModuleService.createCustomers([
{ {
first_name: "Test", first_name: "Test",
last_name: "Test", last_name: "Test",
@@ -29,10 +29,10 @@ medusaIntegrationTestRunner({
}) })
it("should batch delete customers from a group", async () => { it("should batch delete customers from a group", async () => {
const group = await customerModuleService.createCustomerGroup({ const group = await customerModuleService.createCustomerGroups({
name: "VIP", name: "VIP",
}) })
const customers = await customerModuleService.create([ const customers = await customerModuleService.createCustomers([
{ {
first_name: "Test", first_name: "Test",
last_name: "Test", last_name: "Test",
@@ -1,5 +1,3 @@
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { createAdminUser } from "../../../../helpers/create-admin-user" import { createAdminUser } from "../../../../helpers/create-admin-user"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
@@ -15,13 +13,9 @@ medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => { testSuite: ({ dbConnection, getContainer, api }) => {
describe("POST /admin/customer-groups", () => { describe("POST /admin/customer-groups", () => {
let appContainer let appContainer
let customerModuleService: ICustomerModuleService
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
customerModuleService = appContainer.resolve(
ModuleRegistrationName.CUSTOMER
)
}) })
beforeEach(async () => { beforeEach(async () => {
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should delete a group", async () => { it("should delete a group", async () => {
const group = await customerModuleService.createCustomerGroup({ const group = await customerModuleService.createCustomerGroups({
name: "VIP", name: "VIP",
}) })
@@ -29,11 +29,11 @@ medusaIntegrationTestRunner({
}) })
it("should get all customer groups and its count", async () => { it("should get all customer groups and its count", async () => {
const group = await customerModuleService.createCustomerGroup({ const group = await customerModuleService.createCustomerGroups({
name: "Test", name: "Test",
}) })
const customers = await customerModuleService.create([ const customers = await customerModuleService.createCustomers([
{ {
first_name: "Test", first_name: "Test",
last_name: "Test", last_name: "Test",
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should get all customer groups and its count", async () => { it("should get all customer groups and its count", async () => {
await customerModuleService.createCustomerGroup({ await customerModuleService.createCustomerGroups({
name: "Test", name: "Test",
}) })
@@ -46,7 +46,7 @@ medusaIntegrationTestRunner({
}) })
it("should support searching of customer groups", async () => { it("should support searching of customer groups", async () => {
await customerModuleService.createCustomerGroup([ await customerModuleService.createCustomerGroups([
{ {
name: "First group", name: "First group",
}, },
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should retrieve customer group", async () => { it("should retrieve customer group", async () => {
const group = await customerModuleService.createCustomerGroup({ const group = await customerModuleService.createCustomerGroups({
name: "Test", name: "Test",
}) })
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should update a customer group", async () => { it("should update a customer group", async () => {
const customer = await customerModuleService.createCustomerGroup({ const customer = await customerModuleService.createCustomerGroups({
name: "VIP", name: "VIP",
}) })
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should create a customer address", async () => { it("should create a customer address", async () => {
// Create a customer // Create a customer
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
}) })
@@ -56,16 +56,16 @@ medusaIntegrationTestRunner({
]) ])
) )
const customerWithAddresses = await customerModuleService.retrieve( const customerWithAddresses =
customer.id, await customerModuleService.retrieveCustomer(customer.id, {
{ relations: ["addresses"] } relations: ["addresses"],
) })
expect(customerWithAddresses.addresses?.length).toEqual(1) expect(customerWithAddresses.addresses?.length).toEqual(1)
}) })
it("sets new shipping address as default and unsets the old one", async () => { it("sets new shipping address as default and unsets the old one", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
addresses: [ addresses: [
@@ -100,7 +100,7 @@ medusaIntegrationTestRunner({
}) })
it("sets new billing address as default and unsets the old one", async () => { it("sets new billing address as default and unsets the old one", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
addresses: [ addresses: [
@@ -1,5 +1,3 @@
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { createAdminUser } from "../../../../helpers/create-admin-user" import { createAdminUser } from "../../../../helpers/create-admin-user"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
@@ -15,13 +13,8 @@ medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => { testSuite: ({ dbConnection, getContainer, api }) => {
describe("POST /admin/customers", () => { describe("POST /admin/customers", () => {
let appContainer let appContainer
let customerModuleService: ICustomerModuleService
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
customerModuleService = appContainer.resolve(
ModuleRegistrationName.CUSTOMER
)
}) })
beforeEach(async () => { beforeEach(async () => {
@@ -29,12 +29,12 @@ medusaIntegrationTestRunner({
}) })
it("should update a customer address", async () => { it("should update a customer address", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
}) })
const address = await customerModuleService.addAddresses({ const address = await customerModuleService.createAddresses({
customer_id: customer.id, customer_id: customer.id,
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
@@ -48,7 +48,7 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200) expect(response.status).toEqual(200)
const updatedCustomer = await customerModuleService.retrieve( const updatedCustomer = await customerModuleService.retrieveCustomer(
customer.id, customer.id,
{ {
relations: ["addresses"], relations: ["addresses"],
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should delete a customer", async () => { it("should delete a customer", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
}) })
@@ -41,7 +41,7 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200) expect(response.status).toEqual(200)
const deletedCustomer = await customerModuleService.retrieve( const deletedCustomer = await customerModuleService.retrieveCustomer(
customer.id, customer.id,
{ {
withDeleted: true, withDeleted: true,
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should get all customer addresses and its count", async () => { it("should get all customer addresses and its count", async () => {
const [customer] = await customerModuleService.create([ const [customer] = await customerModuleService.createCustomers([
{ {
first_name: "Test", first_name: "Test",
last_name: "Test", last_name: "Test",
@@ -94,7 +94,7 @@ medusaIntegrationTestRunner({
}) })
it("should support searching through the addresses", async () => { it("should support searching through the addresses", async () => {
const [customer] = await customerModuleService.create([ const [customer] = await customerModuleService.createCustomers([
{ {
first_name: "Test", first_name: "Test",
last_name: "Test", last_name: "Test",
@@ -32,7 +32,7 @@ medusaIntegrationTestRunner({
}) })
it("should get all customers and its count", async () => { it("should get all customers and its count", async () => {
await customerModuleService.create([ await customerModuleService.createCustomers([
{ {
first_name: "Test", first_name: "Test",
last_name: "Test", last_name: "Test",
@@ -55,11 +55,11 @@ medusaIntegrationTestRunner({
}) })
it("should get all customers in specific customer group and its count", async () => { it("should get all customers in specific customer group and its count", async () => {
const vipGroup = await customerModuleService.createCustomerGroup({ const vipGroup = await customerModuleService.createCustomerGroups({
name: "VIP", name: "VIP",
}) })
const [john] = await customerModuleService.create([ const [john] = await customerModuleService.createCustomers([
{ {
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
@@ -94,7 +94,7 @@ medusaIntegrationTestRunner({
}) })
it("should filter customers by last name", async () => { it("should filter customers by last name", async () => {
await customerModuleService.create([ await customerModuleService.createCustomers([
{ {
first_name: "Jane", first_name: "Jane",
last_name: "Doe", last_name: "Doe",
@@ -143,7 +143,7 @@ medusaIntegrationTestRunner({
}) })
it("should support searching of customers", async () => { it("should support searching of customers", async () => {
await customerModuleService.create([ await customerModuleService.createCustomers([
{ {
first_name: "Jane", first_name: "Jane",
last_name: "Doe", last_name: "Doe",
@@ -29,12 +29,12 @@ medusaIntegrationTestRunner({
}) })
it("should update a customer address", async () => { it("should update a customer address", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
}) })
const address = await customerModuleService.addAddresses({ const address = await customerModuleService.createAddresses({
customer_id: customer.id, customer_id: customer.id,
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
@@ -62,11 +62,11 @@ medusaIntegrationTestRunner({
}) })
it("updates a new address to be default and unsets old one", async () => { it("updates a new address to be default and unsets old one", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
}) })
const [, address] = await customerModuleService.addAddresses([ const [, address] = await customerModuleService.createAddresses([
{ {
customer_id: customer.id, customer_id: customer.id,
first_name: "John", first_name: "John",
@@ -104,11 +104,11 @@ medusaIntegrationTestRunner({
// do the same as above but for billing address // do the same as above but for billing address
it("updates a new address to be default and unsets old one", async () => { it("updates a new address to be default and unsets old one", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
}) })
const [, address] = await customerModuleService.addAddresses([ const [, address] = await customerModuleService.createAddresses([
{ {
customer_id: customer.id, customer_id: customer.id,
first_name: "John", first_name: "John",
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should update a customer", async () => { it("should update a customer", async () => {
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
}) })
@@ -47,10 +47,10 @@ medusaIntegrationTestRunner({
}) })
) )
const customerWithAddresses = await customerModuleService.retrieve( const customerWithAddresses =
customer.id, await customerModuleService.retrieveCustomer(customer.id, {
{ relations: ["addresses"] } relations: ["addresses"],
) })
expect(customerWithAddresses.addresses?.length).toEqual(1) expect(customerWithAddresses.addresses?.length).toEqual(1)
}) })
@@ -35,9 +35,13 @@ medusaIntegrationTestRunner({
const { http } = appContainer.resolve( const { http } = appContainer.resolve(
ContainerRegistrationKeys.CONFIG_MODULE ContainerRegistrationKeys.CONFIG_MODULE
).projectConfig ).projectConfig
const authIdentity = await authService.create({ const authIdentity = await authService.createAuthIdentities({
provider_identities: [
{
entity_id: "store_user", entity_id: "store_user",
provider: "emailpass", provider: "emailpass",
},
],
}) })
const token = jwt.sign(authIdentity, http.jwtSecret) const token = jwt.sign(authIdentity, http.jwtSecret)
@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer appContainer
) )
const address = await customerModuleService.addAddresses({ const address = await customerModuleService.createAddresses({
customer_id: customer.id, customer_id: customer.id,
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
@@ -40,7 +40,7 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200) expect(response.status).toEqual(200)
const updatedCustomer = await customerModuleService.retrieve( const updatedCustomer = await customerModuleService.retrieveCustomer(
customer.id, customer.id,
{ {
relations: ["addresses"], relations: ["addresses"],
@@ -53,11 +53,11 @@ medusaIntegrationTestRunner({
it("should fail to delete another customer's address", async () => { it("should fail to delete another customer's address", async () => {
const { jwt } = await createAuthenticatedCustomer(appContainer) const { jwt } = await createAuthenticatedCustomer(appContainer)
const otherCustomer = await customerModuleService.create({ const otherCustomer = await customerModuleService.createCustomers({
first_name: "Jane", first_name: "Jane",
last_name: "Doe", last_name: "Doe",
}) })
const address = await customerModuleService.addAddresses({ const address = await customerModuleService.createAddresses({
customer_id: otherCustomer.id, customer_id: otherCustomer.id,
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
@@ -1,5 +1,3 @@
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { createAuthenticatedCustomer } from "../../../helpers/create-authenticated-customer" import { createAuthenticatedCustomer } from "../../../helpers/create-authenticated-customer"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
@@ -12,13 +10,8 @@ medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => { testSuite: ({ dbConnection, getContainer, api }) => {
describe("GET /store/customers", () => { describe("GET /store/customers", () => {
let appContainer let appContainer
let customerModuleService: ICustomerModuleService
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
customerModuleService = appContainer.resolve(
ModuleRegistrationName.CUSTOMER
)
}) })
it("should retrieve auth user's customer", async () => { it("should retrieve auth user's customer", async () => {
@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer appContainer
) )
await customerModuleService.addAddresses([ await customerModuleService.createAddresses([
{ {
first_name: "Test", first_name: "Test",
last_name: "Test", last_name: "Test",
@@ -47,7 +47,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
await customerModuleService.create({ await customerModuleService.createCustomers({
first_name: "Test Test", first_name: "Test Test",
last_name: "Test Test", last_name: "Test Test",
addresses: [ addresses: [
@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer appContainer
) )
const address = await customerModuleService.addAddresses({ const address = await customerModuleService.createAddresses({
customer_id: customer.id, customer_id: customer.id,
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
@@ -54,12 +54,12 @@ medusaIntegrationTestRunner({
it("should fail to update another customer's address", async () => { it("should fail to update another customer's address", async () => {
const { jwt } = await createAuthenticatedCustomer(appContainer) const { jwt } = await createAuthenticatedCustomer(appContainer)
const otherCustomer = await customerModuleService.create({ const otherCustomer = await customerModuleService.createCustomers({
first_name: "Jane", first_name: "Jane",
last_name: "Doe", last_name: "Doe",
}) })
const address = await customerModuleService.addAddresses({ const address = await customerModuleService.createAddresses({
customer_id: otherCustomer.id, customer_id: otherCustomer.id,
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
@@ -109,7 +109,7 @@ export async function setupFullDataFulfillmentStructure(
name: "test_" + randomString, name: "test_" + randomString,
type: "default", type: "default",
}) })
const fulfillmentSet = await service.create({ const fulfillmentSet = await service.createFulfillmentSets({
name: "test_" + randomString, name: "test_" + randomString,
type: "test-type", type: "test-type",
}) })
@@ -105,7 +105,7 @@ export const setupTaxStructure = async (service: ITaxModuleService) => {
]) ])
const [calProd, calType, deType, canProd, canType, qcType] = const [calProd, calType, deType, canProd, canType, qcType] =
await service.create([ await service.createTaxRates([
{ {
tax_region_id: cal.id, tax_region_id: cal.id,
name: "CA Reduced Rate for Products", name: "CA Reduced Rate for Products",
@@ -48,7 +48,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await service.create({ const fulfillmentSet = await service.createFulfillmentSets({
name: "test", name: "test",
type: "test-type", type: "test-type",
}) })
@@ -111,7 +111,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await service.create({ const fulfillmentSet = await service.createFulfillmentSets({
name: "test", name: "test",
type: "test-type", type: "test-type",
}) })
@@ -190,7 +190,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await service.create({ const fulfillmentSet = await service.createFulfillmentSets({
name: "test", name: "test",
type: "test-type", type: "test-type",
}) })
@@ -40,7 +40,7 @@ medusaIntegrationTestRunner({
it("should allow to create a full data structure after the backward compatible migration have run on top of the medusa v1 database", async () => { it("should allow to create a full data structure after the backward compatible migration have run on top of the medusa v1 database", async () => {
await setupFullDataFulfillmentStructure(service, { providerId }) await setupFullDataFulfillmentStructure(service, { providerId })
const fulfillmentSets = await service.list( const fulfillmentSets = await service.listFulfillmentSets(
{}, {},
{ {
relations: [ relations: [
@@ -119,7 +119,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
const fulfillmentSet = await service.create({ const fulfillmentSet = await service.createFulfillmentSets({
name: "test", name: "test",
type: "test-type", type: "test-type",
}) })
@@ -41,20 +41,20 @@ medusaIntegrationTestRunner({
}) })
it("should query carts, sales channels, customers, regions with remote query", async () => { it("should query carts, sales channels, customers, regions with remote query", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "Region", name: "Region",
currency_code: "usd", currency_code: "usd",
}) })
const customer = await customerModule.create({ const customer = await customerModule.createCustomers({
email: "tony@stark.com", email: "tony@stark.com",
}) })
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
email: "tony@stark.com", email: "tony@stark.com",
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
@@ -23,12 +23,12 @@ medusaIntegrationTestRunner({
}) })
it("should query carts and regions with remote query", async () => { it("should query carts and regions with remote query", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "Region", name: "Region",
currency_code: "usd", currency_code: "usd",
}) })
const cart = await cartModuleService.create({ const cart = await cartModuleService.createCarts({
email: "tony@stark.com", email: "tony@stark.com",
currency_code: "usd", currency_code: "usd",
region_id: region.id, region_id: region.id,
@@ -1,8 +1,7 @@
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk" import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
import { import {
IFulfillmentModuleService, IFulfillmentModuleService,
ISalesChannelModuleService, IStockLocationService,
IStockLocationServiceNext,
} from "@medusajs/types" } from "@medusajs/types"
import { import {
ContainerRegistrationKeys, ContainerRegistrationKeys,
@@ -20,8 +19,7 @@ medusaIntegrationTestRunner({
describe("FulfillmentSet and Location", () => { describe("FulfillmentSet and Location", () => {
let appContainer let appContainer
let fulfillmentModule: IFulfillmentModuleService let fulfillmentModule: IFulfillmentModuleService
let locationModule: IStockLocationServiceNext let locationModule: IStockLocationService
let scService: ISalesChannelModuleService
let remoteQuery let remoteQuery
let remoteLink let remoteLink
@@ -33,7 +31,6 @@ medusaIntegrationTestRunner({
locationModule = appContainer.resolve( locationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION ModuleRegistrationName.STOCK_LOCATION
) )
scService = appContainer.resolve(ModuleRegistrationName.SALES_CHANNEL)
remoteQuery = appContainer.resolve( remoteQuery = appContainer.resolve(
ContainerRegistrationKeys.REMOTE_QUERY ContainerRegistrationKeys.REMOTE_QUERY
) )
@@ -41,12 +38,12 @@ medusaIntegrationTestRunner({
}) })
it("should query fulfillment set and location link with remote query", async () => { 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", name: "Test fulfillment set",
type: "delivery", type: "delivery",
}) })
const euWarehouse = await locationModule.create({ const euWarehouse = await locationModule.createStockLocations({
name: "EU Warehouse", name: "EU Warehouse",
}) })
@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
}) })
it("should query product variants and price set link with remote query", async () => { 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", title: "Test product",
variants: [ variants: [
@@ -52,7 +52,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const [priceSet1, priceSet2] = await pricingModule.create([ const [priceSet1, priceSet2] = await pricingModule.createPriceSets([
{ {
rules: [{ rule_attribute: "customer_group_id" }], rules: [{ rule_attribute: "customer_group_id" }],
prices: [ prices: [
@@ -31,11 +31,11 @@ medusaIntegrationTestRunner({
}) })
it("should query api key and sales channels link with remote query", async () => { 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", name: "Webshop",
}) })
const apiKeys = await apiKeyModule.create([ const apiKeys = await apiKeyModule.createApiKeys([
{ {
title: "Api key", title: "Api key",
type: "publishable", type: "publishable",
@@ -1,7 +1,7 @@
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk" 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 { medusaIntegrationTestRunner } from "medusa-test-utils"
import {ContainerRegistrationKeys} from "@medusajs/utils"; import { ContainerRegistrationKeys } from "@medusajs/utils"
jest.setTimeout(50000) jest.setTimeout(50000)
@@ -13,20 +13,20 @@ medusaIntegrationTestRunner({
describe("Region and Payment Providers", () => { describe("Region and Payment Providers", () => {
let appContainer let appContainer
let regionModule: IRegionModuleService let regionModule: IRegionModuleService
let paymentModule: IPaymentModuleService
let remoteQuery let remoteQuery
let remoteLink let remoteLink
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
regionModule = appContainer.resolve(ModuleRegistrationName.REGION) regionModule = appContainer.resolve(ModuleRegistrationName.REGION)
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT) remoteQuery = appContainer.resolve(
remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY) ContainerRegistrationKeys.REMOTE_QUERY
)
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK) remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
}) })
it("should query region and payment provider link with remote query", async () => { 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", name: "North America",
currency_code: "usd", currency_code: "usd",
}) })
@@ -87,7 +87,7 @@ medusaIntegrationTestRunner({
}), }),
expect.objectContaining({ expect.objectContaining({
id: "pp_system_default_2", id: "pp_system_default_2",
regions: [] regions: [],
}), }),
]) ])
) )
@@ -30,23 +30,23 @@ medusaIntegrationTestRunner({
}) })
it("should query carts, sales channels, customers, regions with remote query", async () => { it("should query carts, sales channels, customers, regions with remote query", async () => {
const scWebshop = await scService.create({ const scWebshop = await scService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const scCphStore = await scService.create({ const scCphStore = await scService.createSalesChannels({
name: "CPH store", name: "CPH store",
}) })
const scNycStore = await scService.create({ const scNycStore = await scService.createSalesChannels({
name: "NYC store", name: "NYC store",
}) })
const euWarehouse = await locationService.create({ const euWarehouse = await locationService.createStockLocations({
name: "EU Warehouse", name: "EU Warehouse",
}) })
const usWarehouse = await locationService.create({ const usWarehouse = await locationService.createStockLocations({
name: "US Warehouse", name: "US Warehouse",
}) })
@@ -37,7 +37,7 @@ medusaIntegrationTestRunner({
name: "Test", name: "Test",
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentModule.create({ const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
}) })
@@ -65,7 +65,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const priceSet = await pricingModule.create({ const priceSet = await pricingModule.createPriceSets({
prices: [ prices: [
{ {
amount: 3000, amount: 3000,
@@ -25,7 +25,7 @@ medusaIntegrationTestRunner({
}) })
it("should query store and default currency with remote query", async () => { it("should query store and default currency with remote query", async () => {
const store = await storeModuleService.create({ const store = await storeModuleService.createStores({
name: "Store", name: "Store",
default_currency_code: "usd", default_currency_code: "usd",
supported_currency_codes: ["usd"], supported_currency_codes: ["usd"],
@@ -28,7 +28,7 @@ medusaIntegrationTestRunner({
Modules.PRODUCT Modules.PRODUCT
] as unknown as IProductModuleService ] as unknown as IProductModuleService
const productList = await product.list() const productList = await product.listProducts()
expect(productList).toEqual(expect.arrayContaining([])) expect(productList).toEqual(expect.arrayContaining([]))
}) })
@@ -1,5 +1,5 @@
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk" import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
import { IPaymentModuleService, IRegionModuleService } from "@medusajs/types" import { IRegionModuleService } from "@medusajs/types"
import { ContainerRegistrationKeys } from "@medusajs/utils" import { ContainerRegistrationKeys } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
import { createAdminUser } from "../../..//helpers/create-admin-user" import { createAdminUser } from "../../..//helpers/create-admin-user"
@@ -15,14 +15,12 @@ medusaIntegrationTestRunner({
describe("Remote Query", () => { describe("Remote Query", () => {
let appContainer let appContainer
let regionModule: IRegionModuleService let regionModule: IRegionModuleService
let paymentModule: IPaymentModuleService
let remoteQuery let remoteQuery
let remoteLink let remoteLink
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
regionModule = appContainer.resolve(ModuleRegistrationName.REGION) regionModule = appContainer.resolve(ModuleRegistrationName.REGION)
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
remoteQuery = appContainer.resolve( remoteQuery = appContainer.resolve(
ContainerRegistrationKeys.REMOTE_QUERY ContainerRegistrationKeys.REMOTE_QUERY
) )
@@ -34,7 +32,7 @@ medusaIntegrationTestRunner({
}) })
it("should fail to retrieve a single non-existing id", async () => { it("should fail to retrieve a single non-existing id", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "Test Region", name: "Test Region",
currency_code: "usd", currency_code: "usd",
countries: ["us"], countries: ["us"],
@@ -75,19 +73,19 @@ medusaIntegrationTestRunner({
}) })
it("should fail if a expected relation is not found", async () => { it("should fail if a expected relation is not found", async () => {
const region = await regionModule.create({ const region = await regionModule.createRegions({
name: "Test Region", name: "Test Region",
currency_code: "usd", currency_code: "usd",
countries: ["us"], countries: ["us"],
}) })
const regionWithPayment = await regionModule.create({ const regionWithPayment = await regionModule.createRegions({
name: "Test W/ Payment", name: "Test W/ Payment",
currency_code: "brl", currency_code: "brl",
countries: ["br"], countries: ["br"],
}) })
const regionNoLink = await regionModule.create({ const regionNoLink = await regionModule.createRegions({
name: "No link", name: "No link",
currency_code: "eur", currency_code: "eur",
countries: ["dk"], countries: ["dk"],
@@ -40,8 +40,8 @@ medusaIntegrationTestRunner({
resource_type: "order", resource_type: "order",
} as CreateNotificationDTO } as CreateNotificationDTO
const result = await service.create(notification) const result = await service.createNotifications(notification)
const fromDB = await service.retrieve(result.id) const fromDB = await service.retrieveNotification(result.id)
expect(result).toEqual( expect(result).toEqual(
expect.objectContaining({ expect.objectContaining({
@@ -94,7 +94,9 @@ medusaIntegrationTestRunner({
channel: "sms", channel: "sms",
} as CreateNotificationDTO } as CreateNotificationDTO
const error = await service.create(notification).catch((e) => e) const error = await service
.createNotifications(notification)
.catch((e) => e)
expect(error.message).toEqual( expect(error.message).toEqual(
"Could not find a notification provider for channel: sms" "Could not find a notification provider for channel: sms"
) )
@@ -113,9 +115,11 @@ medusaIntegrationTestRunner({
template: "product-created", template: "product-created",
} as CreateNotificationDTO } as CreateNotificationDTO
await service.create([notification1, notification2]) await service.createNotifications([notification1, notification2])
const notifications = await service.list({ channel: "log" }) const notifications = await service.listNotifications({
channel: "log",
})
expect(notifications).toHaveLength(1) expect(notifications).toHaveLength(1)
expect(notifications[0]).toEqual( expect(notifications[0]).toEqual(
expect.objectContaining({ expect.objectContaining({
@@ -139,9 +143,12 @@ medusaIntegrationTestRunner({
template: "product-created", template: "product-created",
} as CreateNotificationDTO } as CreateNotificationDTO
const [first] = await service.create([notification1, notification2]) const [first] = await service.createNotifications([
notification1,
notification2,
])
const notification = await service.retrieve(first.id) const notification = await service.retrieveNotification(first.id)
expect(notification).toEqual( expect(notification).toEqual(
expect.objectContaining({ expect.objectContaining({
to: "test@medusajs.com", to: "test@medusajs.com",
@@ -176,7 +183,7 @@ medusaIntegrationTestRunner({
}) })
await subscriberExecution await subscriberExecution
const notifications = await service.list() const notifications = await service.listNotifications()
expect(logSpy).toHaveBeenLastCalledWith( expect(logSpy).toHaveBeenLastCalledWith(
`Attempting to send a notification to: 'test@medusajs.com' on the channel: 'email' with template: 'order-created-template' and data: '{\"order_id\":\"1234\"}'` `Attempting to send a notification to: 'test@medusajs.com' on the channel: 'email' with template: 'order-created-template' and data: '{\"order_id\":\"1234\"}'`
@@ -1,10 +1,8 @@
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk" import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
import { import {
ICartModuleService, ICartModuleService,
ICustomerModuleService,
IFulfillmentModuleService, IFulfillmentModuleService,
IInventoryServiceNext, IInventoryServiceNext,
IPaymentModuleService,
IPricingModuleService, IPricingModuleService,
IProductModuleService, IProductModuleService,
IRegionModuleService, IRegionModuleService,
@@ -31,14 +29,11 @@ medusaIntegrationTestRunner({
let cartModuleService: ICartModuleService let cartModuleService: ICartModuleService
let regionModuleService: IRegionModuleService let regionModuleService: IRegionModuleService
let scModuleService: ISalesChannelModuleService let scModuleService: ISalesChannelModuleService
let customerModule: ICustomerModuleService
let productModule: IProductModuleService let productModule: IProductModuleService
let pricingModule: IPricingModuleService let pricingModule: IPricingModuleService
let paymentModule: IPaymentModuleService
let inventoryModule: IInventoryServiceNext let inventoryModule: IInventoryServiceNext
let stockLocationModule: IStockLocationServiceNext let stockLocationModule: IStockLocationServiceNext
let fulfillmentModule: IFulfillmentModuleService let fulfillmentModule: IFulfillmentModuleService
let locationModule: IStockLocationServiceNext
let taxModule: ITaxModuleService let taxModule: ITaxModuleService
let remoteLink, remoteQuery let remoteLink, remoteQuery
@@ -49,10 +44,8 @@ medusaIntegrationTestRunner({
scModuleService = appContainer.resolve( scModuleService = appContainer.resolve(
ModuleRegistrationName.SALES_CHANNEL ModuleRegistrationName.SALES_CHANNEL
) )
customerModule = appContainer.resolve(ModuleRegistrationName.CUSTOMER)
productModule = appContainer.resolve(ModuleRegistrationName.PRODUCT) productModule = appContainer.resolve(ModuleRegistrationName.PRODUCT)
pricingModule = appContainer.resolve(ModuleRegistrationName.PRICING) pricingModule = appContainer.resolve(ModuleRegistrationName.PRICING)
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
inventoryModule = appContainer.resolve(ModuleRegistrationName.INVENTORY) inventoryModule = appContainer.resolve(ModuleRegistrationName.INVENTORY)
stockLocationModule = appContainer.resolve( stockLocationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION ModuleRegistrationName.STOCK_LOCATION
@@ -60,9 +53,6 @@ medusaIntegrationTestRunner({
fulfillmentModule = appContainer.resolve( fulfillmentModule = appContainer.resolve(
ModuleRegistrationName.FULFILLMENT ModuleRegistrationName.FULFILLMENT
) )
locationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
taxModule = appContainer.resolve(ModuleRegistrationName.TAX) taxModule = appContainer.resolve(ModuleRegistrationName.TAX)
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK) remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY) remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -74,20 +64,20 @@ medusaIntegrationTestRunner({
describe("Draft Orders - Admin", () => { describe("Draft Orders - Admin", () => {
it("should create a draft order", async () => { it("should create a draft order", async () => {
const region = await regionModuleService.create({ const region = await regionModuleService.createRegions({
name: "US", name: "US",
currency_code: "usd", currency_code: "usd",
}) })
const salesChannel = await scModuleService.create({ const salesChannel = await scModuleService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location = await stockLocationModule.create({ const location = await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
}) })
const [product, product_2] = await productModule.create([ const [product, product_2] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -107,7 +97,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -120,7 +110,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const [priceSet, priceSet_2] = await pricingModule.create([ const [priceSet, priceSet_2] = await pricingModule.createPriceSets([
{ {
prices: [ prices: [
{ {
@@ -1,7 +1,6 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk" import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { import {
ICartModuleService, ICartModuleService,
ICustomerModuleService,
IFulfillmentModuleService, IFulfillmentModuleService,
IInventoryServiceNext, IInventoryServiceNext,
IOrderModuleService, IOrderModuleService,
@@ -9,9 +8,7 @@ import {
IPricingModuleService, IPricingModuleService,
IProductModuleService, IProductModuleService,
IRegionModuleService, IRegionModuleService,
ISalesChannelModuleService,
IStockLocationServiceNext, IStockLocationServiceNext,
ITaxModuleService,
} from "@medusajs/types" } from "@medusajs/types"
import { ContainerRegistrationKeys } from "@medusajs/utils" import { ContainerRegistrationKeys } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
@@ -30,16 +27,12 @@ medusaIntegrationTestRunner({
let appContainer let appContainer
let cartModuleService: ICartModuleService let cartModuleService: ICartModuleService
let regionModuleService: IRegionModuleService let regionModuleService: IRegionModuleService
let scModuleService: ISalesChannelModuleService
let customerModule: ICustomerModuleService
let productModule: IProductModuleService let productModule: IProductModuleService
let pricingModule: IPricingModuleService
let paymentModule: IPaymentModuleService let paymentModule: IPaymentModuleService
let pricingModule: IPricingModuleService
let inventoryModule: IInventoryServiceNext let inventoryModule: IInventoryServiceNext
let stockLocationModule: IStockLocationServiceNext let stockLocationModule: IStockLocationServiceNext
let fulfillmentModule: IFulfillmentModuleService let fulfillmentModule: IFulfillmentModuleService
let locationModule: IStockLocationServiceNext
let taxModule: ITaxModuleService
let orderModule: IOrderModuleService let orderModule: IOrderModuleService
let remoteLink, remoteQuery let remoteLink, remoteQuery
@@ -47,24 +40,12 @@ medusaIntegrationTestRunner({
appContainer = getContainer() appContainer = getContainer()
cartModuleService = appContainer.resolve(ModuleRegistrationName.CART) cartModuleService = appContainer.resolve(ModuleRegistrationName.CART)
regionModuleService = appContainer.resolve(ModuleRegistrationName.REGION) regionModuleService = appContainer.resolve(ModuleRegistrationName.REGION)
scModuleService = appContainer.resolve(
ModuleRegistrationName.SALES_CHANNEL
)
customerModule = appContainer.resolve(ModuleRegistrationName.CUSTOMER)
productModule = appContainer.resolve(ModuleRegistrationName.PRODUCT) productModule = appContainer.resolve(ModuleRegistrationName.PRODUCT)
pricingModule = appContainer.resolve(ModuleRegistrationName.PRICING)
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT) paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
inventoryModule = appContainer.resolve(ModuleRegistrationName.INVENTORY) inventoryModule = appContainer.resolve(ModuleRegistrationName.INVENTORY)
stockLocationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
fulfillmentModule = appContainer.resolve( fulfillmentModule = appContainer.resolve(
ModuleRegistrationName.FULFILLMENT ModuleRegistrationName.FULFILLMENT
) )
locationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
taxModule = appContainer.resolve(ModuleRegistrationName.TAX)
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK) remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY) remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
orderModule = appContainer.resolve(ModuleRegistrationName.ORDER) orderModule = appContainer.resolve(ModuleRegistrationName.ORDER)
@@ -76,7 +57,7 @@ medusaIntegrationTestRunner({
describe("Orders - Admin", () => { describe("Orders - Admin", () => {
it("should get an order", async () => { it("should get an order", async () => {
const created = await orderModule.create({ const created = await orderModule.createOrders({
region_id: "test_region_idclear", region_id: "test_region_idclear",
email: "foo@bar.com", email: "foo@bar.com",
items: [ items: [
@@ -9,7 +9,7 @@ import {
FulfillmentWorkflow, FulfillmentWorkflow,
IOrderModuleService, IOrderModuleService,
IRegionModuleService, IRegionModuleService,
IStockLocationServiceNext, IStockLocationService,
OrderWorkflow, OrderWorkflow,
ProductDTO, ProductDTO,
RegionDTO, RegionDTO,
@@ -35,7 +35,7 @@ async function prepareDataFixtures({ container }) {
const salesChannelService = container.resolve( const salesChannelService = container.resolve(
ModuleRegistrationName.SALES_CHANNEL ModuleRegistrationName.SALES_CHANNEL
) )
const stockLocationModule: IStockLocationServiceNext = container.resolve( const stockLocationModule: IStockLocationService = container.resolve(
ModuleRegistrationName.STOCK_LOCATION ModuleRegistrationName.STOCK_LOCATION
) )
const productModule = container.resolve(ModuleRegistrationName.PRODUCT) const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
@@ -46,7 +46,7 @@ async function prepareDataFixtures({ container }) {
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentService.create({ const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -66,7 +66,7 @@ async function prepareDataFixtures({ container }) {
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -74,11 +74,12 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
const salesChannel = await salesChannelService.create({ const salesChannel = await salesChannelService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location: StockLocationDTO = await stockLocationModule.create({ const location: StockLocationDTO =
await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
address: { address: {
address_1: "Test", address_1: "Test",
@@ -89,7 +90,7 @@ async function prepareDataFixtures({ container }) {
}, },
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -101,7 +102,7 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
inventoryItem = await inventoryModule.create({ inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -210,7 +211,7 @@ async function createOrderFixture({ container, product, location }) {
const orderService: IOrderModuleService = container.resolve( const orderService: IOrderModuleService = container.resolve(
ModuleRegistrationName.ORDER ModuleRegistrationName.ORDER
) )
let order = await orderService.create({ let order = await orderService.createOrders({
region_id: "test_region_idclear", region_id: "test_region_idclear",
email: "foo@bar.com", email: "foo@bar.com",
items: [ items: [
@@ -292,7 +293,7 @@ async function createOrderFixture({ container, product, location }) {
}, },
]) ])
order = await orderService.retrieve(order.id, { order = await orderService.retrieveOrder(order.id, {
relations: ["items"], relations: ["items"],
}) })
@@ -8,7 +8,7 @@ import {
FulfillmentWorkflow, FulfillmentWorkflow,
IOrderModuleService, IOrderModuleService,
IRegionModuleService, IRegionModuleService,
IStockLocationServiceNext, IStockLocationService,
OrderWorkflow, OrderWorkflow,
ProductDTO, ProductDTO,
RegionDTO, RegionDTO,
@@ -34,7 +34,7 @@ async function prepareDataFixtures({ container }) {
const salesChannelService = container.resolve( const salesChannelService = container.resolve(
ModuleRegistrationName.SALES_CHANNEL ModuleRegistrationName.SALES_CHANNEL
) )
const stockLocationModule: IStockLocationServiceNext = container.resolve( const stockLocationModule: IStockLocationService = container.resolve(
ModuleRegistrationName.STOCK_LOCATION ModuleRegistrationName.STOCK_LOCATION
) )
const productModule = container.resolve(ModuleRegistrationName.PRODUCT) const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
@@ -45,7 +45,7 @@ async function prepareDataFixtures({ container }) {
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentService.create({ const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -65,7 +65,7 @@ async function prepareDataFixtures({ container }) {
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -73,11 +73,12 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
const salesChannel = await salesChannelService.create({ const salesChannel = await salesChannelService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location: StockLocationDTO = await stockLocationModule.create({ const location: StockLocationDTO =
await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
address: { address: {
address_1: "Test", address_1: "Test",
@@ -88,7 +89,7 @@ async function prepareDataFixtures({ container }) {
}, },
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -105,7 +106,7 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
inventoryItem = await inventoryModule.create({ inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -214,7 +215,7 @@ async function createOrderFixture({ container, product, location }) {
const orderService: IOrderModuleService = container.resolve( const orderService: IOrderModuleService = container.resolve(
ModuleRegistrationName.ORDER ModuleRegistrationName.ORDER
) )
let order = await orderService.create({ let order = await orderService.createOrders({
region_id: "test_region_idclear", region_id: "test_region_idclear",
email: "foo@bar.com", email: "foo@bar.com",
items: [ items: [
@@ -305,7 +306,7 @@ async function createOrderFixture({ container, product, location }) {
}, },
]) ])
order = await orderService.retrieve(order.id, { order = await orderService.retrieveOrder(order.id, {
relations: ["items"], relations: ["items"],
}) })
@@ -12,7 +12,7 @@ import {
FulfillmentWorkflow, FulfillmentWorkflow,
IOrderModuleService, IOrderModuleService,
IRegionModuleService, IRegionModuleService,
IStockLocationServiceNext, IStockLocationService,
OrderWorkflow, OrderWorkflow,
ProductDTO, ProductDTO,
RegionDTO, RegionDTO,
@@ -21,8 +21,8 @@ import {
} from "@medusajs/types" } from "@medusajs/types"
import { import {
ContainerRegistrationKeys, ContainerRegistrationKeys,
RuleOperator,
remoteQueryObjectFromString, remoteQueryObjectFromString,
RuleOperator,
} from "@medusajs/utils" } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist" import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
@@ -38,7 +38,7 @@ async function prepareDataFixtures({ container }) {
const salesChannelService = container.resolve( const salesChannelService = container.resolve(
ModuleRegistrationName.SALES_CHANNEL ModuleRegistrationName.SALES_CHANNEL
) )
const stockLocationModule: IStockLocationServiceNext = container.resolve( const stockLocationModule: IStockLocationService = container.resolve(
ModuleRegistrationName.STOCK_LOCATION ModuleRegistrationName.STOCK_LOCATION
) )
const productModule = container.resolve(ModuleRegistrationName.PRODUCT) const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
@@ -49,7 +49,7 @@ async function prepareDataFixtures({ container }) {
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentService.create({ const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -69,7 +69,7 @@ async function prepareDataFixtures({ container }) {
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -77,11 +77,12 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
const salesChannel = await salesChannelService.create({ const salesChannel = await salesChannelService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location: StockLocationDTO = await stockLocationModule.create({ const location: StockLocationDTO =
await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
address: { address: {
address_1: "Test", address_1: "Test",
@@ -92,7 +93,7 @@ async function prepareDataFixtures({ container }) {
}, },
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -104,7 +105,7 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
const inventoryItem = await inventoryModule.create({ const inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -221,7 +222,7 @@ async function createOrderFixture({ container, product }) {
const orderService: IOrderModuleService = container.resolve( const orderService: IOrderModuleService = container.resolve(
ModuleRegistrationName.ORDER ModuleRegistrationName.ORDER
) )
let order = await orderService.create({ let order = await orderService.createOrders({
region_id: "test_region_idclear", region_id: "test_region_idclear",
email: "foo@bar.com", email: "foo@bar.com",
items: [ items: [
@@ -331,7 +332,7 @@ async function createOrderFixture({ container, product }) {
await orderService.applyPendingOrderActions(order.id) await orderService.applyPendingOrderActions(order.id)
order = await orderService.retrieve(order.id, { order = await orderService.retrieveOrder(order.id, {
relations: ["items"], relations: ["items"],
}) })
@@ -8,7 +8,7 @@ import {
FulfillmentWorkflow, FulfillmentWorkflow,
IOrderModuleService, IOrderModuleService,
IRegionModuleService, IRegionModuleService,
IStockLocationServiceNext, IStockLocationService,
OrderWorkflow, OrderWorkflow,
ProductDTO, ProductDTO,
RegionDTO, RegionDTO,
@@ -17,8 +17,8 @@ import {
} from "@medusajs/types" } from "@medusajs/types"
import { import {
ContainerRegistrationKeys, ContainerRegistrationKeys,
RuleOperator,
remoteQueryObjectFromString, remoteQueryObjectFromString,
RuleOperator,
} from "@medusajs/utils" } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist" import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
@@ -35,7 +35,7 @@ async function prepareDataFixtures({ container }) {
const salesChannelService = container.resolve( const salesChannelService = container.resolve(
ModuleRegistrationName.SALES_CHANNEL ModuleRegistrationName.SALES_CHANNEL
) )
const stockLocationModule: IStockLocationServiceNext = container.resolve( const stockLocationModule: IStockLocationService = container.resolve(
ModuleRegistrationName.STOCK_LOCATION ModuleRegistrationName.STOCK_LOCATION
) )
const productModule = container.resolve(ModuleRegistrationName.PRODUCT) const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
@@ -46,7 +46,7 @@ async function prepareDataFixtures({ container }) {
type: "default", type: "default",
}) })
const fulfillmentSet = await fulfillmentService.create({ const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -66,7 +66,7 @@ async function prepareDataFixtures({ container }) {
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -74,11 +74,12 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
const salesChannel = await salesChannelService.create({ const salesChannel = await salesChannelService.createSalesChannels({
name: "Webshop", name: "Webshop",
}) })
const location: StockLocationDTO = await stockLocationModule.create({ const location: StockLocationDTO =
await stockLocationModule.createStockLocations({
name: "Warehouse", name: "Warehouse",
address: { address: {
address_1: "Test", address_1: "Test",
@@ -89,7 +90,7 @@ async function prepareDataFixtures({ container }) {
}, },
}) })
const [product] = await productModule.create([ const [product] = await productModule.createProducts([
{ {
title: "Test product", title: "Test product",
variants: [ variants: [
@@ -101,7 +102,7 @@ async function prepareDataFixtures({ container }) {
}, },
]) ])
inventoryItem = await inventoryModule.create({ inventoryItem = await inventoryModule.createInventoryItems({
sku: "inv-1234", sku: "inv-1234",
}) })
@@ -217,7 +218,7 @@ async function createOrderFixture({ container, product, location }) {
const orderService: IOrderModuleService = container.resolve( const orderService: IOrderModuleService = container.resolve(
ModuleRegistrationName.ORDER ModuleRegistrationName.ORDER
) )
let order = await orderService.create({ let order = await orderService.createOrders({
region_id: "test_region_idclear", region_id: "test_region_idclear",
email: "foo@bar.com", email: "foo@bar.com",
items: [ items: [
@@ -299,7 +300,7 @@ async function createOrderFixture({ container, product, location }) {
}, },
]) ])
order = await orderService.retrieve(order.id, { order = await orderService.retrieveOrder(order.id, {
relations: ["items"], relations: ["items"],
}) })
@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
let paymentCollection let paymentCollection
beforeEach(async () => { beforeEach(async () => {
region = await regionModule.create({ region = await regionModule.createRegions({
currency_code: "usd", currency_code: "usd",
name: "US", name: "US",
}) })
@@ -130,7 +130,7 @@ medusaIntegrationTestRunner({
}, },
}) })
const region = await regionModule.create({ const region = await regionModule.createRegions({
currency_code: "usd", currency_code: "usd",
name: "US", name: "US",
}) })
@@ -32,7 +32,7 @@ medusaIntegrationTestRunner({
// TODO: Test should move to `integration-tests/api` // TODO: Test should move to `integration-tests/api`
it("should list payment providers", async () => { it("should list payment providers", async () => {
const region = await regionService.create({ const region = await regionService.createRegions({
name: "Test Region", name: "Test Region",
currency_code: "usd", currency_code: "usd",
}) })
@@ -43,11 +43,14 @@ medusaIntegrationTestRunner({
beforeEach(async () => { beforeEach(async () => {
await createAdminUser(dbConnection, adminHeaders, appContainer) await createAdminUser(dbConnection, adminHeaders, appContainer)
customerGroup = await customerModule.createCustomerGroup({ customerGroup = await customerModule.createCustomerGroups({
name: "VIP", name: "VIP",
}) })
region = await regionModule.create({ name: "US", currency_code: "USD" }) region = await regionModule.createRegions({
;[product] = await productModule.create([ name: "US",
currency_code: "USD",
})
;[product] = await productModule.createProducts([
{ {
title: "test product", title: "test product",
variants: [ variants: [
@@ -1,4 +1,3 @@
import { IPricingModuleService } from "@medusajs/types"
import { PriceListStatus, PriceListType } from "@medusajs/utils" import { PriceListStatus, PriceListType } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils" import { medusaIntegrationTestRunner } from "medusa-test-utils"
import { import {
@@ -31,11 +30,9 @@ medusaIntegrationTestRunner({
let product let product
let variant let variant
let priceSetId let priceSetId
let pricingModuleService: IPricingModuleService
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
pricingModuleService = appContainer.resolve("pricingModuleService")
}) })
beforeEach(async () => { beforeEach(async () => {
@@ -82,7 +82,7 @@ medusaIntegrationTestRunner({
{ name: "region_id", rule_attribute: "region_id" }, { name: "region_id", rule_attribute: "region_id" },
]) ])
priceSet = await pricingModuleService.create({ priceSet = await pricingModuleService.createPriceSets({
rules: [{ rule_attribute: "region_id" }], rules: [{ rule_attribute: "region_id" }],
prices: [ prices: [
{ {
@@ -22,14 +22,14 @@ async function createProductsWithVariants(
): Promise<[ProductDTO, ProductVariantDTO[]]> { ): Promise<[ProductDTO, ProductVariantDTO[]]> {
const { variants: variantsData, ...productData } = productsData const { variants: variantsData, ...productData } = productsData
const [product] = await productModule.create([productData]) const [product] = await productModule.createProducts([productData])
const variantsDataWithProductId = variantsData?.map((variantData) => { const variantsDataWithProductId = variantsData?.map((variantData) => {
return { ...variantData, product_id: product.id } return { ...variantData, product_id: product.id }
}) })
const variants = variantsDataWithProductId const variants = variantsDataWithProductId
? await productModule.createVariants(variantsDataWithProductId) ? await productModule.createProductVariants(variantsDataWithProductId)
: [] : []
return [product, variants] return [product, variants]
@@ -35,8 +35,8 @@ medusaIntegrationTestRunner({
}, },
}) })
const product1 = await service.create({ title: "test1" }) const product1 = await service.createProducts({ title: "test1" })
const product2 = await service.create({ title: "test2" }) const product2 = await service.createProducts({ title: "test2" })
const { errors } = await workflow.run({ const { errors } = await workflow.run({
input: { input: {
@@ -57,7 +57,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const products = await service.list() const products = await service.listProducts()
expect(products).toHaveLength(2) expect(products).toHaveLength(2)
expect(products).toEqual([ expect(products).toEqual([
@@ -135,7 +135,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const product = await service.retrieve(product1.id, { const product = await service.retrieveProduct(product1.id, {
relations: ["variants"], relations: ["variants"],
}) })
@@ -16,13 +16,8 @@ medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => { testSuite: ({ dbConnection, getContainer, api }) => {
describe("POST /admin/promotions", () => { describe("POST /admin/promotions", () => {
let appContainer let appContainer
let promotionModuleService: IPromotionModuleService
beforeAll(async () => { beforeAll(async () => {
appContainer = getContainer() appContainer = getContainer()
promotionModuleService = appContainer.resolve(
ModuleRegistrationName.PROMOTION
)
}) })
beforeEach(async () => { beforeEach(async () => {
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
}) })
it("should delete promotion successfully", async () => { it("should delete promotion successfully", async () => {
const createdPromotion = await promotionModuleService.create({ const createdPromotion = await promotionModuleService.createPromotions({
code: "TEST", code: "TEST",
type: "standard", type: "standard",
application_method: { application_method: {
@@ -47,7 +47,7 @@ medusaIntegrationTestRunner({
expect(deleteRes.status).toEqual(200) expect(deleteRes.status).toEqual(200)
const promotions = await promotionModuleService.list({ const promotions = await promotionModuleService.listPromotions({
id: [createdPromotion.id], id: [createdPromotion.id],
}) })
@@ -30,7 +30,7 @@ medusaIntegrationTestRunner({
}) })
it("should get all promotions and its count", async () => { it("should get all promotions and its count", async () => {
await promotionModuleService.create([ await promotionModuleService.createPromotions([
{ {
code: "TEST", code: "TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
@@ -69,7 +69,7 @@ medusaIntegrationTestRunner({
}) })
it("should support search of promotions", async () => { it("should support search of promotions", async () => {
await promotionModuleService.create([ await promotionModuleService.createPromotions([
{ {
code: "first", code: "first",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
@@ -103,7 +103,7 @@ medusaIntegrationTestRunner({
}) })
it("should get all promotions and its count filtered", async () => { it("should get all promotions and its count filtered", async () => {
await promotionModuleService.create([ await promotionModuleService.createPromotions([
{ {
code: "TEST", code: "TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
@@ -47,7 +47,7 @@ medusaIntegrationTestRunner({
beforeEach(async () => { beforeEach(async () => {
await createAdminUser(dbConnection, adminHeaders, appContainer) await createAdminUser(dbConnection, adminHeaders, appContainer)
standardPromotion = await promotionModule.create({ standardPromotion = await promotionModule.createPromotions({
code: "TEST_ACROSS", code: "TEST_ACROSS",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -322,7 +322,7 @@ medusaIntegrationTestRunner({
}) })
it("should add buy rules to a buyget promotion successfully", async () => { it("should add buy rules to a buyget promotion successfully", async () => {
const buyGetPromotion = await promotionModule.create({ const buyGetPromotion = await promotionModule.createPromotions({
code: "TEST_BUYGET", code: "TEST_BUYGET",
type: PromotionType.BUYGET, type: PromotionType.BUYGET,
application_method: { application_method: {
@@ -414,7 +414,7 @@ medusaIntegrationTestRunner({
deleted: true, deleted: true,
}) })
const promotion = await promotionModule.retrieve( const promotion = await promotionModule.retrievePromotion(
standardPromotion.id, standardPromotion.id,
{ relations: ["rules"] } { relations: ["rules"] }
) )
@@ -455,7 +455,7 @@ medusaIntegrationTestRunner({
deleted: true, deleted: true,
}) })
const promotion = await promotionModule.retrieve( const promotion = await promotionModule.retrievePromotion(
standardPromotion.id, standardPromotion.id,
{ relations: ["application_method.target_rules"] } { relations: ["application_method.target_rules"] }
) )
@@ -482,7 +482,7 @@ medusaIntegrationTestRunner({
}) })
it("should remove buy rules from a promotion successfully", async () => { it("should remove buy rules from a promotion successfully", async () => {
const buyGetPromotion = await promotionModule.create({ const buyGetPromotion = await promotionModule.createPromotions({
code: "TEST_BUYGET", code: "TEST_BUYGET",
type: PromotionType.BUYGET, type: PromotionType.BUYGET,
application_method: { application_method: {
@@ -513,9 +513,12 @@ medusaIntegrationTestRunner({
deleted: true, deleted: true,
}) })
const promotion = await promotionModule.retrieve(buyGetPromotion.id, { const promotion = await promotionModule.retrievePromotion(
buyGetPromotion.id,
{
relations: ["application_method.buy_rules"], relations: ["application_method.buy_rules"],
}) }
)
expect(promotion.application_method!.buy_rules!.length).toEqual(0) expect(promotion.application_method!.buy_rules!.length).toEqual(0)
}) })
@@ -731,7 +734,7 @@ medusaIntegrationTestRunner({
}) })
it("should return all values based on rule types", async () => { it("should return all values based on rule types", async () => {
const [region1, region2] = await regionService.create([ const [region1, region2] = await regionService.createRegions([
{ name: "North America", currency_code: "usd" }, { name: "North America", currency_code: "usd" },
{ name: "Europe", currency_code: "eur" }, { name: "Europe", currency_code: "eur" },
]) ])
@@ -770,7 +773,7 @@ medusaIntegrationTestRunner({
]) ])
) )
const group = await customerService.createCustomerGroup({ const group = await customerService.createCustomerGroups({
name: "VIP", name: "VIP",
}) })
@@ -787,7 +790,7 @@ medusaIntegrationTestRunner({
}, },
]) ])
const salesChannel = await salesChannelService.create({ const salesChannel = await salesChannelService.createSalesChannels({
name: "Instagram", name: "Instagram",
}) })
@@ -826,7 +829,7 @@ medusaIntegrationTestRunner({
]) ])
) )
const [product1, product2] = await productService.create([ const [product1, product2] = await productService.createProducts([
{ title: "test product 1" }, { title: "test product 1" },
{ title: "test product 2" }, { title: "test product 2" },
]) ])
@@ -845,7 +848,7 @@ medusaIntegrationTestRunner({
]) ])
) )
const category = await productService.createCategory({ const category = await productService.createProductCategories({
name: "test category 1", name: "test category 1",
parent_category_id: null, parent_category_id: null,
}) })
@@ -860,7 +863,7 @@ medusaIntegrationTestRunner({
{ label: "test category 1", value: category.id }, { label: "test category 1", value: category.id },
]) ])
const collection = await productService.createCollections({ const collection = await productService.createProductCollections({
title: "test collection 1", title: "test collection 1",
}) })
@@ -874,7 +877,7 @@ medusaIntegrationTestRunner({
{ label: "test collection 1", value: collection.id }, { label: "test collection 1", value: collection.id },
]) ])
const type = await productService.createTypes({ const type = await productService.createProductTypes({
value: "test type", value: "test type",
}) })
@@ -888,7 +891,7 @@ medusaIntegrationTestRunner({
{ label: "test type", value: type.id }, { label: "test type", value: type.id },
]) ])
const [tag1, tag2] = await productService.createTags([ const [tag1, tag2] = await productService.createProductTags([
{ value: "test tag 1" }, { value: "test tag 1" },
{ value: "test tag 2" }, { value: "test tag 2" },
]) ])
@@ -41,7 +41,7 @@ medusaIntegrationTestRunner({
}) })
it("should get the requested promotion by id or codde", async () => { it("should get the requested promotion by id or codde", async () => {
const createdPromotion = await promotionModuleService.create({ const createdPromotion = await promotionModuleService.createPromotions({
code: "TEST", code: "TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -78,7 +78,7 @@ medusaIntegrationTestRunner({
}) })
it("should get the requested promotion with filtered fields and relations", async () => { it("should get the requested promotion with filtered fields and relations", async () => {
const createdPromotion = await promotionModuleService.create({ const createdPromotion = await promotionModuleService.createPromotions({
code: "TEST", code: "TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
application_method: { application_method: {
@@ -45,7 +45,7 @@ medusaIntegrationTestRunner({
}) })
it("should throw an error when both campaign and campaign_id params are passed", async () => { it("should throw an error when both campaign and campaign_id params are passed", async () => {
const createdPromotion = await promotionModuleService.create({ const createdPromotion = await promotionModuleService.createPromotions({
code: "TEST", code: "TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
is_automatic: true, is_automatic: true,
@@ -79,7 +79,7 @@ medusaIntegrationTestRunner({
}) })
it("should update a promotion successfully", async () => { it("should update a promotion successfully", async () => {
const createdPromotion = await promotionModuleService.create({ const createdPromotion = await promotionModuleService.createPromotions({
code: "TEST", code: "TEST",
type: PromotionType.STANDARD, type: PromotionType.STANDARD,
is_automatic: true, is_automatic: true,
@@ -117,7 +117,7 @@ medusaIntegrationTestRunner({
}) })
it("should update a buyget promotion successfully", async () => { it("should update a buyget promotion successfully", async () => {
const createdPromotion = await promotionModuleService.create({ const createdPromotion = await promotionModuleService.createPromotions({
code: "PROMOTION_TEST", code: "PROMOTION_TEST",
type: PromotionType.BUYGET, type: PromotionType.BUYGET,
application_method: { application_method: {
@@ -87,9 +87,12 @@ medusaIntegrationTestRunner({
deleted: true, deleted: true,
}) })
const deletedRegion = await service.retrieve(updated.data.region.id, { const deletedRegion = await service.retrieveRegion(
updated.data.region.id,
{
withDeleted: true, withDeleted: true,
}) }
)
// @ts-ignore // @ts-ignore
expect(deletedRegion.deleted_at).toBeTruthy() expect(deletedRegion.deleted_at).toBeTruthy()
@@ -294,7 +297,7 @@ medusaIntegrationTestRunner({
}) })
it("should throw on unknown properties in update", async () => { it("should throw on unknown properties in update", async () => {
const created = await service.create({ const created = await service.createRegions({
name: "Test Region", name: "Test Region",
currency_code: "usd", currency_code: "usd",
}) })
@@ -318,7 +321,7 @@ medusaIntegrationTestRunner({
}) })
it("should get all regions and count", async () => { it("should get all regions and count", async () => {
await service.create([ await service.createRegions([
{ {
name: "Test", name: "Test",
currency_code: "usd", currency_code: "usd",
@@ -344,7 +347,7 @@ medusaIntegrationTestRunner({
}) })
it("should support searching of regions", async () => { it("should support searching of regions", async () => {
await service.create([ await service.createRegions([
{ {
name: "APAC", name: "APAC",
currency_code: "usd", currency_code: "usd",
@@ -369,7 +372,7 @@ medusaIntegrationTestRunner({
}) })
it("should get a region", async () => { it("should get a region", async () => {
const [region] = await service.create([ const [region] = await service.createRegions([
{ {
name: "Test", name: "Test",
currency_code: "usd", currency_code: "usd",
@@ -43,7 +43,7 @@ medusaIntegrationTestRunner({
ContainerRegistrationKeys.REMOTE_LINK ContainerRegistrationKeys.REMOTE_LINK
) )
region = await regionService.create({ region = await regionService.createRegions({
name: "Test region", name: "Test region",
countries: ["US"], countries: ["US"],
currency_code: "usd", currency_code: "usd",
@@ -103,7 +103,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
fulfillmentSet = await fulfillmentModule.create({ fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
name: "Test", name: "Test",
type: "test-type", type: "test-type",
service_zones: [ service_zones: [
@@ -184,7 +184,9 @@ medusaIntegrationTestRunner({
describe("GET /admin/shipping-options?cart_id=", () => { describe("GET /admin/shipping-options?cart_id=", () => {
it("should get all shipping options for a cart successfully", async () => { it("should get all shipping options for a cart successfully", async () => {
const resp = await api.get(`/store/shipping-options?cart_id=${cart.id}`) const resp = await api.get(
`/store/shipping-options?cart_id=${cart.id}`
)
const shippingOptions = resp.data.shipping_options const shippingOptions = resp.data.shipping_options
expect(shippingOptions).toHaveLength(1) expect(shippingOptions).toHaveLength(1)
@@ -1,4 +1,4 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk" import {ModuleRegistrationName} from "@medusajs/modules-sdk"
import { import {
BatchWorkflowInput, BatchWorkflowInput,
CreateShippingOptionRuleDTO, CreateShippingOptionRuleDTO,
@@ -10,7 +10,7 @@ import {
ShippingProfileDTO, ShippingProfileDTO,
UpdateShippingOptionRuleDTO, UpdateShippingOptionRuleDTO,
} from "@medusajs/types" } from "@medusajs/types"
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist" import {medusaIntegrationTestRunner} from "medusa-test-utils/dist"
import { import {
batchShippingOptionRulesWorkflow, batchShippingOptionRulesWorkflow,
createShippingOptionsWorkflow, createShippingOptionsWorkflow,
@@ -35,7 +35,7 @@ async function createShippingOptionFixture({
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -136,7 +136,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
fulfillmentSet = await service.create({ fulfillmentSet = await service.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -42,7 +42,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
fulfillmentSet = await service.create({ fulfillmentSet = await service.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -64,7 +64,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -180,7 +180,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -45,7 +45,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
fulfillmentSet = await service.create({ fulfillmentSet = await service.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -67,7 +67,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -150,7 +150,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -46,7 +46,7 @@ medusaIntegrationTestRunner({
type: "default", type: "default",
}) })
fulfillmentSet = await service.create({ fulfillmentSet = await service.createFulfillmentSets({
name: "Test fulfillment set", name: "Test fulfillment set",
type: "manual_test", type: "manual_test",
}) })
@@ -68,7 +68,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -233,7 +233,7 @@ medusaIntegrationTestRunner({
ModuleRegistrationName.REGION ModuleRegistrationName.REGION
) as IRegionModuleService ) as IRegionModuleService
const [region] = await regionService.create([ const [region] = await regionService.createRegions([
{ {
name: "Test region", name: "Test region",
currency_code: "eur", currency_code: "eur",
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
}) })
it("should correctly implement the entire lifecycle of a store", async () => { it("should correctly implement the entire lifecycle of a store", async () => {
const createdStore = await service.create({ const createdStore = await service.createStores({
name: "Test store", name: "Test store",
supported_currency_codes: ["usd"], supported_currency_codes: ["usd"],
}) })
@@ -56,8 +56,11 @@ medusaIntegrationTestRunner({
}) })
) )
await service.delete(createdStore.id) await service.deleteStores(createdStore.id)
const listedStores = await api.get(`/admin/stores?id=${createdStore.id}`, adminHeaders) const listedStores = await api.get(
`/admin/stores?id=${createdStore.id}`,
adminHeaders
)
expect(listedStores.data.stores).toHaveLength(0) expect(listedStores.data.stores).toHaveLength(0)
}) })
}) })
@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
const region = await service.createTaxRegions({ const region = await service.createTaxRegions({
country_code: "us", country_code: "us",
}) })
const rate = await service.create({ const rate = await service.createTaxRates({
tax_region_id: region.id, tax_region_id: region.id,
code: "test", code: "test",
rate: 2.5, rate: 2.5,
@@ -69,14 +69,14 @@ medusaIntegrationTestRunner({
country_code: "us", country_code: "us",
}) })
await service.create({ await service.createTaxRates({
tax_region_id: region.id, tax_region_id: region.id,
code: "low", code: "low",
rate: 2.5, rate: 2.5,
name: "low rate", name: "low rate",
}) })
await service.create({ await service.createTaxRates({
tax_region_id: region.id, tax_region_id: region.id,
code: "high", code: "high",
rate: 5, rate: 5,
@@ -384,7 +384,7 @@ medusaIntegrationTestRunner({
deleted: true, deleted: true,
}) })
const rates = await service.list( const rates = await service.listTaxRates(
{ id: rateRes.data.tax_rate.id }, { id: rateRes.data.tax_rate.id },
{ withDeleted: true } { withDeleted: true }
) )
@@ -397,7 +397,7 @@ medusaIntegrationTestRunner({
country_code: "us", country_code: "us",
}) })
const rate = await service.create({ const rate = await service.createTaxRates({
tax_region_id: region.id, tax_region_id: region.id,
code: "test", code: "test",
rate: 2.5, rate: 2.5,
@@ -36,7 +36,7 @@ medusaIntegrationTestRunner({
country_code: "us", country_code: "us",
}) })
const [rateOne, rateTwo] = await service.create([ const [rateOne, rateTwo] = await service.createTaxRates([
{ {
tax_region_id: taxRegion.id, tax_region_id: taxRegion.id,
rate: 10, rate: 10,
@@ -123,7 +123,7 @@ medusaIntegrationTestRunner({
country_code: "us", country_code: "us",
}) })
const [rateOne, rateTwo] = await service.create([ const [rateOne, rateTwo] = await service.createTaxRates([
{ {
tax_region_id: taxRegion.id, tax_region_id: taxRegion.id,
rate: 10, rate: 10,
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
}) })
it("should delete a single user", async () => { it("should delete a single user", async () => {
const user = await userModuleService.create({ const user = await userModuleService.createUsers({
email: "member@test.com", email: "member@test.com",
}) })
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
}) })
it("should list users", async () => { it("should list users", async () => {
await userModuleService.create([ await userModuleService.createUsers([
{ {
email: "member@test.com", email: "member@test.com",
}, },
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
}) })
it("should retrieve a single user", async () => { it("should retrieve a single user", async () => {
const user = await userModuleService.create({ const user = await userModuleService.createUsers({
email: "member@test.com", email: "member@test.com",
}) })
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
}) })
it("should update a single user", async () => { it("should update a single user", async () => {
const user = await userModuleService.create({ const user = await userModuleService.createUsers({
email: "member@test.com", email: "member@test.com",
}) })
@@ -13,16 +13,20 @@ export const createAuthenticatedCustomer = async (
ModuleRegistrationName.CUSTOMER ModuleRegistrationName.CUSTOMER
) )
const customer = await customerModuleService.create({ const customer = await customerModuleService.createCustomers({
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
email: "john@me.com", email: "john@me.com",
...customerData, ...customerData,
}) })
const authIdentity = await authService.create({ const authIdentity = await authService.createAuthIdentities({
provider_identities: [
{
entity_id: "store_user", entity_id: "store_user",
provider: "emailpass", provider: "emailpass",
},
],
app_metadata: { app_metadata: {
customer_id: customer.id, customer_id: customer.id,
}, },
@@ -5,7 +5,7 @@ export const createDefaultRuleTypes = async (container) => {
"pricingModuleService" "pricingModuleService"
) )
return pricingModuleService.createRuleTypes([ return await pricingModuleService.createRuleTypes([
{ {
name: "region_id", name: "region_id",
rule_attribute: "region_id", rule_attribute: "region_id",
@@ -30,7 +30,7 @@ export const createVariantPriceSet = async ({
"pricingModuleService" "pricingModuleService"
) )
const priceSet = await pricingModuleService.create({ const priceSet = await pricingModuleService.createPriceSets({
rules, rules,
prices, prices,
}) })
@@ -40,7 +40,7 @@ export const createVariantPriceSet = async ({
[Modules.PRICING]: { price_set_id: priceSet.id }, [Modules.PRICING]: { price_set_id: priceSet.id },
}) })
return await pricingModuleService.retrieve(priceSet.id, { return await pricingModuleService.retrievePriceSet(priceSet.id, {
relations: ["prices"], relations: ["prices"],
}) })
} }
@@ -15,7 +15,7 @@ import {
ReservationItemRes, ReservationItemRes,
} from "../../types/api-responses" } from "../../types/api-responses"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { client } from "../../lib/client" import { client } from "../../lib/client"
import { queryClient } from "../../lib/query-client" import { queryClient } from "../../lib/query-client"
import { queryKeysFactory } from "../../lib/query-key-factory" import { queryKeysFactory } from "../../lib/query-key-factory"
@@ -68,7 +68,7 @@ export const useUpdateReservationItem = (
options?: UseMutationOptions<ReservationItemRes, Error, UpdateReservationReq> options?: UseMutationOptions<ReservationItemRes, Error, UpdateReservationReq>
) => { ) => {
return useMutation({ return useMutation({
mutationFn: (payload: InventoryNext.UpdateReservationItemInput) => mutationFn: (payload: InventoryTypes.UpdateReservationItemInput) =>
client.reservations.update(id, payload), client.reservations.update(id, payload),
onSuccess: (data, variables, context) => { onSuccess: (data, variables, context) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
@@ -5,7 +5,7 @@ import {
} from "../../types/api-responses" } from "../../types/api-responses"
import { deleteRequest, getRequest, postRequest } from "./common" import { deleteRequest, getRequest, postRequest } from "./common"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
async function retrieveReservation(id: string, query?: Record<string, any>) { async function retrieveReservation(id: string, query?: Record<string, any>) {
return getRequest<ReservationRes>(`/admin/reservations/${id}`, query) return getRequest<ReservationRes>(`/admin/reservations/${id}`, query)
@@ -16,14 +16,14 @@ async function listReservations(query?: Record<string, any>) {
} }
async function createReservation( async function createReservation(
payload: InventoryNext.CreateReservationItemInput payload: InventoryTypes.CreateReservationItemInput
) { ) {
return postRequest<ReservationRes>(`/admin/reservations`, payload) return postRequest<ReservationRes>(`/admin/reservations`, payload)
} }
async function updateReservation( async function updateReservation(
id: string, id: string,
payload: InventoryNext.UpdateReservationItemInput payload: InventoryTypes.UpdateReservationItemInput
) { ) {
return postRequest<ReservationRes>(`/admin/reservations/${id}`, payload) return postRequest<ReservationRes>(`/admin/reservations/${id}`, payload)
} }
@@ -14,7 +14,7 @@ async function retrieveWorkflowExecution(
) )
} }
async function listWorkflowExecutions(query?: Record<string, any>) { async function listWorkflowExecutionss(query?: Record<string, any>) {
return getRequest<WorkflowExecutionListRes>( return getRequest<WorkflowExecutionListRes>(
`/admin/workflows-executions`, `/admin/workflows-executions`,
query query
@@ -23,5 +23,5 @@ async function listWorkflowExecutions(query?: Record<string, any>) {
export const workflowExecutions = { export const workflowExecutions = {
retrieve: retrieveWorkflowExecution, retrieve: retrieveWorkflowExecution,
list: listWorkflowExecutions, list: listWorkflowExecutionss,
} }
@@ -1,6 +1,6 @@
import { AdjustInventoryForm } from "./components/adjust-inventory-form" import { AdjustInventoryForm } from "./components/adjust-inventory-form"
import { Heading } from "@medusajs/ui" import { Heading } from "@medusajs/ui"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { RouteDrawer } from "../../../../../components/route-modal" import { RouteDrawer } from "../../../../../components/route-modal"
import { useInventoryItem } from "../../../../../hooks/api/inventory" import { useInventoryItem } from "../../../../../hooks/api/inventory"
import { useParams } from "react-router-dom" import { useParams } from "react-router-dom"
@@ -19,7 +19,7 @@ export const AdjustInventoryDrawer = () => {
} = useInventoryItem(id!) } = useInventoryItem(id!)
const inventoryLevel = inventoryItem?.location_levels!.find( const inventoryLevel = inventoryItem?.location_levels!.find(
(level: InventoryNext.InventoryLevelDTO) => (level: InventoryTypes.InventoryLevelDTO) =>
level.location_id === location_id level.location_id === location_id
) )
@@ -7,7 +7,7 @@ import {
} from "../../../../../../components/route-modal" } from "../../../../../../components/route-modal"
import { zodResolver } from "@hookform/resolvers/zod" import { zodResolver } from "@hookform/resolvers/zod"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { useForm } from "react-hook-form" import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
import { z } from "zod" import { z } from "zod"
@@ -16,7 +16,7 @@ import { CountrySelect } from "../../../../../../components/inputs/country-selec
import { useUpdateInventoryItem } from "../../../../../../hooks/api/inventory" import { useUpdateInventoryItem } from "../../../../../../hooks/api/inventory"
type EditInventoryItemAttributeFormProps = { type EditInventoryItemAttributeFormProps = {
item: InventoryNext.InventoryItemDTO item: InventoryTypes.InventoryItemDTO
} }
const EditInventoryItemAttributesSchema = z.object({ const EditInventoryItemAttributesSchema = z.object({
@@ -29,7 +29,7 @@ const EditInventoryItemAttributesSchema = z.object({
origin_country: z.string().optional(), origin_country: z.string().optional(),
}) })
const getDefaultValues = (item: InventoryNext.InventoryItemDTO) => { const getDefaultValues = (item: InventoryTypes.InventoryItemDTO) => {
return { return {
height: item.height ?? undefined, height: item.height ?? undefined,
width: item.width ?? undefined, width: item.width ?? undefined,
@@ -7,7 +7,7 @@ import {
} from "../../../../../../components/route-modal" } from "../../../../../../components/route-modal"
import { Form } from "../../../../../../components/common/form" import { Form } from "../../../../../../components/common/form"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { useForm } from "react-hook-form" import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
import { useUpdateInventoryItem } from "../../../../../../hooks/api/inventory" import { useUpdateInventoryItem } from "../../../../../../hooks/api/inventory"
@@ -15,7 +15,7 @@ import { z } from "zod"
import { zodResolver } from "@hookform/resolvers/zod" import { zodResolver } from "@hookform/resolvers/zod"
type EditInventoryItemFormProps = { type EditInventoryItemFormProps = {
item: InventoryNext.InventoryItemDTO item: InventoryTypes.InventoryItemDTO
} }
const EditInventoryItemSchema = z.object({ const EditInventoryItemSchema = z.object({
@@ -23,7 +23,7 @@ const EditInventoryItemSchema = z.object({
sku: z.string().min(1), sku: z.string().min(1),
}) })
const getDefaultValues = (item: InventoryNext.InventoryItemDTO) => { const getDefaultValues = (item: InventoryTypes.InventoryItemDTO) => {
return { return {
title: item.title ?? undefined, title: item.title ?? undefined,
sku: item.sku ?? undefined, sku: item.sku ?? undefined,
@@ -1,14 +1,14 @@
import { Container, Heading } from "@medusajs/ui" import { Container, Heading } from "@medusajs/ui"
import { ActionMenu } from "../../../../../components/common/action-menu" import { ActionMenu } from "../../../../../components/common/action-menu"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { PencilSquare } from "@medusajs/icons" import { PencilSquare } from "@medusajs/icons"
import { SectionRow } from "../../../../../components/common/section" import { SectionRow } from "../../../../../components/common/section"
import { getFormattedCountry } from "../../../../../lib/addresses" import { getFormattedCountry } from "../../../../../lib/addresses"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
type InventoryItemAttributeSectionProps = { type InventoryItemAttributeSectionProps = {
inventoryItem: InventoryNext.InventoryItemDTO inventoryItem: InventoryTypes.InventoryItemDTO
} }
export const InventoryItemAttributeSection = ({ export const InventoryItemAttributeSection = ({
@@ -1,7 +1,7 @@
import { PencilSquare, Trash } from "@medusajs/icons" import { PencilSquare, Trash } from "@medusajs/icons"
import { ActionMenu } from "../../../../../components/common/action-menu" import { ActionMenu } from "../../../../../components/common/action-menu"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { useDeleteInventoryItemLevel } from "../../../../../hooks/api/inventory" import { useDeleteInventoryItemLevel } from "../../../../../hooks/api/inventory"
import { usePrompt } from "@medusajs/ui" import { usePrompt } from "@medusajs/ui"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
@@ -9,7 +9,7 @@ import { useTranslation } from "react-i18next"
export const LocationActions = ({ export const LocationActions = ({
level, level,
}: { }: {
level: InventoryNext.InventoryLevelDTO level: InventoryTypes.InventoryLevelDTO
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const prompt = usePrompt() const prompt = usePrompt()
@@ -1,4 +1,4 @@
import { InventoryNext, StockLocationDTO } from "@medusajs/types" import { InventoryTypes, StockLocationDTO } from "@medusajs/types"
import { LocationActions } from "./location-actions" import { LocationActions } from "./location-actions"
import { PlaceholderCell } from "../../../../../components/table/table-cells/common/placeholder-cell" import { PlaceholderCell } from "../../../../../components/table/table-cells/common/placeholder-cell"
@@ -9,7 +9,7 @@ import { useTranslation } from "react-i18next"
/** /**
* Adds missing properties to the InventoryLevelDTO type. * Adds missing properties to the InventoryLevelDTO type.
*/ */
interface ExtendedLocationLevel extends InventoryNext.InventoryLevelDTO { interface ExtendedLocationLevel extends InventoryTypes.InventoryLevelDTO {
stock_locations: StockLocationDTO[] stock_locations: StockLocationDTO[]
reserved_quantity: number reserved_quantity: number
stocked_quantity: number stocked_quantity: number
@@ -2,14 +2,14 @@ import { PencilSquare, Trash } from "@medusajs/icons"
import { toast, usePrompt } from "@medusajs/ui" import { toast, usePrompt } from "@medusajs/ui"
import { ActionMenu } from "../../../../../components/common/action-menu" import { ActionMenu } from "../../../../../components/common/action-menu"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { useDeleteReservationItem } from "../../../../../hooks/api/reservations" import { useDeleteReservationItem } from "../../../../../hooks/api/reservations"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
export const ReservationActions = ({ export const ReservationActions = ({
reservation, reservation,
}: { }: {
reservation: InventoryNext.ReservationItemDTO reservation: InventoryTypes.ReservationItemDTO
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const prompt = usePrompt() const prompt = usePrompt()
@@ -1,5 +1,5 @@
import { DataTable } from "../../../../../components/table/data-table" import { DataTable } from "../../../../../components/table/data-table"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { useDataTable } from "../../../../../hooks/use-data-table" import { useDataTable } from "../../../../../hooks/use-data-table"
import { useReservationItems } from "../../../../../hooks/api/reservations" import { useReservationItems } from "../../../../../hooks/api/reservations"
import { useReservationTableColumn } from "./use-reservation-list-table-columns" import { useReservationTableColumn } from "./use-reservation-list-table-columns"
@@ -10,7 +10,7 @@ const PAGE_SIZE = 20
export const ReservationItemTable = ({ export const ReservationItemTable = ({
inventoryItem, inventoryItem,
}: { }: {
inventoryItem: InventoryNext.InventoryItemDTO inventoryItem: InventoryTypes.InventoryItemDTO
}) => { }) => {
const { searchParams, raw } = useReservationsTableQuery({ const { searchParams, raw } = useReservationsTableQuery({
pageSize: PAGE_SIZE, pageSize: PAGE_SIZE,
@@ -29,7 +29,7 @@ export const ReservationItemTable = ({
columns, columns,
count, count,
enablePagination: true, enablePagination: true,
getRowId: (row: InventoryNext.ReservationItemDTO) => row.id, getRowId: (row: InventoryTypes.ReservationItemDTO) => row.id,
pageSize: PAGE_SIZE, pageSize: PAGE_SIZE,
}) })
@@ -1,4 +1,4 @@
import { InventoryNext, StockLocationDTO } from "@medusajs/types" import { InventoryTypes, StockLocationDTO } from "@medusajs/types"
import { PlaceholderCell } from "../../../../../components/table/table-cells/common/placeholder-cell" import { PlaceholderCell } from "../../../../../components/table/table-cells/common/placeholder-cell"
import { ReservationActions } from "./reservation-actions" import { ReservationActions } from "./reservation-actions"
@@ -9,7 +9,7 @@ import { useTranslation } from "react-i18next"
/** /**
* Adds missing properties to the InventoryItemDTO type. * Adds missing properties to the InventoryItemDTO type.
*/ */
interface ExtendedReservationItem extends InventoryNext.ReservationItemDTO { interface ExtendedReservationItem extends InventoryTypes.ReservationItemDTO {
line_item: { order_id: string } line_item: { order_id: string }
location: StockLocationDTO location: StockLocationDTO
} }
@@ -1,5 +1,5 @@
import { Button, Container, Heading } from "@medusajs/ui" import { Button, Container, Heading } from "@medusajs/ui"
import { InventoryNext } from "@medusajs/types" import { InventoryTypes } from "@medusajs/types"
import { DataTable } from "../../../../components/table/data-table" import { DataTable } from "../../../../components/table/data-table"
import { useDataTable } from "../../../../hooks/use-data-table" import { useDataTable } from "../../../../hooks/use-data-table"
@@ -33,7 +33,7 @@ export const InventoryListTable = () => {
const columns = useInventoryTableColumns() const columns = useInventoryTableColumns()
const { table } = useDataTable({ const { table } = useDataTable({
data: (inventory_items ?? []) as InventoryNext.InventoryItemDTO[], data: (inventory_items ?? []) as InventoryTypes.InventoryItemDTO[],
columns, columns,
count, count,
enablePagination: true, enablePagination: true,
@@ -1,4 +1,4 @@
import { InventoryNext, ProductVariantDTO } from "@medusajs/types" import { InventoryTypes, ProductVariantDTO } from "@medusajs/types"
import { InventoryActions } from "./inventory-actions" import { InventoryActions } from "./inventory-actions"
import { PlaceholderCell } from "../../../../components/table/table-cells/common/placeholder-cell" import { PlaceholderCell } from "../../../../components/table/table-cells/common/placeholder-cell"
@@ -9,7 +9,7 @@ import { useTranslation } from "react-i18next"
/** /**
* Adds missing properties to the InventoryItemDTO type. * Adds missing properties to the InventoryItemDTO type.
*/ */
interface ExtendedInventoryItem extends InventoryNext.InventoryItemDTO { interface ExtendedInventoryItem extends InventoryTypes.InventoryItemDTO {
variants?: ProductVariantDTO[] | null variants?: ProductVariantDTO[] | null
stocked_quantity?: number stocked_quantity?: number
reserved_quantity?: number reserved_quantity?: number
@@ -1,7 +1,7 @@
import * as zod from "zod" import * as zod from "zod"
import { Button, Input, Select, Text, Textarea, toast } from "@medusajs/ui" import { Button, Input, Select, Text, Textarea, toast } from "@medusajs/ui"
import { InventoryNext, StockLocationDTO } from "@medusajs/types" import { InventoryTypes, StockLocationDTO } from "@medusajs/types"
import { import {
RouteDrawer, RouteDrawer,
useRouteModal, useRouteModal,
@@ -16,7 +16,7 @@ import { z } from "zod"
import { zodResolver } from "@hookform/resolvers/zod" import { zodResolver } from "@hookform/resolvers/zod"
type EditReservationFormProps = { type EditReservationFormProps = {
reservation: InventoryNext.ReservationItemDTO reservation: InventoryTypes.ReservationItemDTO
locations: StockLocationDTO[] locations: StockLocationDTO[]
item: InventoryItemRes["inventory_item"] item: InventoryItemRes["inventory_item"]
} }
@@ -46,7 +46,7 @@ const AttributeGridRow = ({
) )
} }
const getDefaultValues = (reservation: InventoryNext.ReservationItemDTO) => { const getDefaultValues = (reservation: InventoryTypes.ReservationItemDTO) => {
return { return {
quantity: reservation.quantity, quantity: reservation.quantity,
location_id: reservation.location_id, location_id: reservation.location_id,
@@ -85,7 +85,8 @@ export const EditReservationForm = ({
const locationId = form.watch("location_id") const locationId = form.watch("location_id")
const level = item.location_levels!.find( const level = item.location_levels!.find(
(level: InventoryNext.InventoryLevelDTO) => level.location_id === locationId (level: InventoryTypes.InventoryLevelDTO) =>
level.location_id === locationId
) )
return ( return (
Loaded 100 of 533 files, more files were not shown because too many files have changed in this diff. Show more