chore: joiner config entity property (#9084)

This commit is contained in:
Carlos R. L. Rodrigues
2024-09-11 06:25:25 -03:00
committed by GitHub
parent 28dc8d4d17
commit fdd0543011
80 changed files with 464 additions and 294 deletions
@@ -54,12 +54,14 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
expect(linkable.apiKey).toEqual({
id: {
linkable: "api_key_id",
entity: "ApiKey",
primaryKey: "id",
serviceName: "apiKey",
field: "apiKey",
},
publishable_key_id: {
field: "apiKey",
entity: "ApiKey",
linkable: "publishable_key_id",
primaryKey: "publishable_key_id",
serviceName: "apiKey",
@@ -1,7 +1,7 @@
import { IAuthModuleService } from "@medusajs/types"
import { Module, Modules } from "@medusajs/utils"
import { AuthModuleService } from "@services"
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
import { resolve } from "path"
let moduleOptions = {
@@ -52,6 +52,7 @@ moduleIntegrationTestRunner({
expect(linkable.authIdentity).toEqual({
id: {
linkable: "auth_identity_id",
entity: "AuthIdentity",
primaryKey: "id",
serviceName: "auth",
field: "authIdentity",
@@ -63,6 +64,7 @@ moduleIntegrationTestRunner({
expect(linkable.providerIdentity).toEqual({
id: {
linkable: "provider_identity_id",
entity: "ProviderIdentity",
primaryKey: "id",
serviceName: "auth",
field: "providerIdentity",
@@ -34,6 +34,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
cart: {
id: {
linkable: "cart_id",
entity: "Cart",
primaryKey: "id",
serviceName: "cart",
field: "cart",
@@ -42,6 +43,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
address: {
id: {
linkable: "address_id",
entity: "Address",
primaryKey: "id",
serviceName: "cart",
field: "address",
@@ -50,6 +52,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
lineItem: {
id: {
linkable: "line_item_id",
entity: "LineItem",
primaryKey: "id",
serviceName: "cart",
field: "lineItem",
@@ -58,6 +61,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
lineItemAdjustment: {
id: {
linkable: "line_item_adjustment_id",
entity: "LineItemAdjustment",
primaryKey: "id",
serviceName: "cart",
field: "lineItemAdjustment",
@@ -66,6 +70,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
lineItemTaxLine: {
id: {
linkable: "line_item_tax_line_id",
entity: "LineItemTaxLine",
primaryKey: "id",
serviceName: "cart",
field: "lineItemTaxLine",
@@ -74,6 +79,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
shippingMethod: {
id: {
linkable: "shipping_method_id",
entity: "ShippingMethod",
primaryKey: "id",
serviceName: "cart",
field: "shippingMethod",
@@ -82,6 +88,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
shippingMethodAdjustment: {
id: {
linkable: "shipping_method_adjustment_id",
entity: "ShippingMethodAdjustment",
primaryKey: "id",
serviceName: "cart",
field: "shippingMethodAdjustment",
@@ -90,6 +97,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
shippingMethodTaxLine: {
id: {
linkable: "shipping_method_tax_line_id",
entity: "ShippingMethodTaxLine",
primaryKey: "id",
serviceName: "cart",
field: "shippingMethodTaxLine",
@@ -24,6 +24,7 @@ moduleIntegrationTestRunner<ICurrencyModuleService>({
currency: {
code: {
linkable: "currency_code",
entity: "Currency",
primaryKey: "code",
serviceName: "currency",
field: "currency",
@@ -1,7 +1,7 @@
import { ICustomerModuleService } from "@medusajs/types"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { Module, Modules } from "@medusajs/utils"
import { CustomerModuleService } from "@services"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(30000)
@@ -15,7 +15,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
}).linkable
expect(Object.keys(linkable)).toEqual([
"address",
"customerAddress",
"customerGroupCustomer",
"customerGroup",
"customer",
@@ -26,17 +26,19 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
})
expect(linkable).toEqual({
address: {
customerAddress: {
id: {
linkable: "address_id",
linkable: "customer_address_id",
entity: "CustomerAddress",
primaryKey: "id",
serviceName: "customer",
field: "address",
field: "customerAddress",
},
},
customerGroupCustomer: {
id: {
linkable: "customer_group_customer_id",
entity: "CustomerGroupCustomer",
primaryKey: "id",
serviceName: "customer",
field: "customerGroupCustomer",
@@ -45,6 +47,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
customerGroup: {
id: {
linkable: "customer_group_id",
entity: "CustomerGroup",
primaryKey: "id",
serviceName: "customer",
field: "customerGroup",
@@ -53,6 +56,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
customer: {
id: {
linkable: "customer_id",
entity: "Customer",
primaryKey: "id",
serviceName: "customer",
field: "customer",
@@ -196,7 +200,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
}
const customer = await service.createCustomers(customerData)
const [address] = await service.listAddresses({
const [address] = await service.listCustomerAddresses({
customer_id: customer.id,
})
@@ -675,7 +679,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
first_name: "John",
last_name: "Doe",
})
await service.createAddresses({
await service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -684,17 +688,17 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
})
// verify that the address was added
const customerWithAddress = await service.retrieveCustomer(
const customerWithCustomerAddress = await service.retrieveCustomer(
customer.id,
{
relations: ["addresses"],
}
)
expect(customerWithAddress.addresses?.length).toBe(1)
expect(customerWithCustomerAddress.addresses?.length).toBe(1)
await service.deleteCustomers(customer.id)
const res = await service.listAddresses({
const res = await service.listCustomerAddresses({
customer_id: customer.id,
})
expect(res.length).toBe(0)
@@ -793,25 +797,25 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
})
})
describe("addAddresses", () => {
describe("addCustomerAddresses", () => {
it("should add a single address to a customer", async () => {
const customer = await service.createCustomers({
first_name: "John",
last_name: "Doe",
})
const address = await service.createAddresses({
const address = await service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
postal_code: "10001",
country_code: "US",
})
const [customerWithAddress] = await service.listCustomers(
const [customerWithCustomerAddress] = await service.listCustomers(
{ id: customer.id },
{ relations: ["addresses"] }
)
expect(customerWithAddress.addresses).toEqual([
expect(customerWithCustomerAddress.addresses).toEqual([
expect.objectContaining({ id: address.id }),
])
})
@@ -821,7 +825,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
first_name: "John",
last_name: "Doe",
})
const addresses = await service.createAddresses([
const addresses = await service.createCustomerAddresses([
{
customer_id: customer.id,
first_name: "John",
@@ -837,12 +841,12 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
country_code: "US",
},
])
const [customerWithAddresses] = await service.listCustomers(
const [customerWithCustomerAddresses] = await service.listCustomers(
{ id: customer.id },
{ relations: ["addresses"] }
)
expect(customerWithAddresses.addresses).toEqual(
expect(customerWithCustomerAddresses.addresses).toEqual(
expect.arrayContaining([
expect.objectContaining({ id: addresses[0].id }),
expect.objectContaining({ id: addresses[1].id }),
@@ -855,7 +859,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
first_name: "John",
last_name: "Doe",
})
await service.createAddresses({
await service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -863,7 +867,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
country_code: "US",
is_default_shipping: true,
})
await service.createAddresses({
await service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -873,7 +877,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
})
await expect(
service.createAddresses({
service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -891,7 +895,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
first_name: "John",
last_name: "Doe",
})
await service.createAddresses({
await service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -899,7 +903,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
country_code: "US",
is_default_billing: true,
})
await service.createAddresses({
await service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -909,7 +913,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
})
await expect(
service.createAddresses({
service.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -923,19 +927,19 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
})
})
describe("updateAddresses", () => {
describe("updateCustomerAddresses", () => {
it("should update a single address", async () => {
const customer = await service.createCustomers({
first_name: "John",
last_name: "Doe",
})
const address = await service.createAddresses({
const address = await service.createCustomerAddresses({
customer_id: customer.id,
address_name: "Home",
address_1: "123 Main St",
})
await service.updateAddresses(address.id, {
await service.updateCustomerAddresses(address.id, {
address_name: "Work",
address_1: "456 Main St",
})
@@ -959,18 +963,18 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
first_name: "John",
last_name: "Doe",
})
const address1 = await service.createAddresses({
const address1 = await service.createCustomerAddresses({
customer_id: customer.id,
address_name: "Home",
address_1: "123 Main St",
})
const address2 = await service.createAddresses({
const address2 = await service.createCustomerAddresses({
customer_id: customer.id,
address_name: "Work",
address_1: "456 Main St",
})
await service.updateAddresses(
await service.updateCustomerAddresses(
{ customer_id: customer.id },
{
address_name: "Under Construction",
@@ -1001,7 +1005,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
first_name: "John",
last_name: "Doe",
})
const [address1, address2] = await service.createAddresses([
const [address1, address2] = await service.createCustomerAddresses([
{
customer_id: customer.id,
address_name: "Home",
@@ -1014,7 +1018,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
},
])
await service.updateAddresses([address1.id, address2.id], {
await service.updateCustomerAddresses([address1.id, address2.id], {
address_name: "Under Construction",
})
@@ -1049,27 +1053,29 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
},
],
})
const address = await service.createAddresses({
const address = await service.createCustomerAddresses({
customer_id: customer.id,
address_name: "Work",
address_1: "456 Main St",
})
await expect(
service.updateAddresses(address.id, { is_default_shipping: true })
service.updateCustomerAddresses(address.id, {
is_default_shipping: true,
})
).rejects.toThrow(
/Customer address with customer_id: .*? already exists./
)
})
})
describe("listAddresses", () => {
describe("listCustomerAddresses", () => {
it("should list all addresses for a customer", async () => {
const customer = await service.createCustomers({
first_name: "John",
last_name: "Doe",
})
const [address1, address2] = await service.createAddresses([
const [address1, address2] = await service.createCustomerAddresses([
{
customer_id: customer.id,
address_name: "Home",
@@ -1083,7 +1089,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
},
])
const addresses = await service.listAddresses({
const addresses = await service.listCustomerAddresses({
customer_id: customer.id,
})
+1 -11
View File
@@ -1,13 +1,3 @@
import { defineJoinerConfig, Modules } from "@medusajs/utils"
export const joinerConfig = defineJoinerConfig(Modules.CUSTOMER, {
alias: [
{
name: ["customer_address", "customer_addresses"],
args: {
entity: "Address",
methodSuffix: "Addresses",
},
},
],
})
export const joinerConfig = defineJoinerConfig(Modules.CUSTOMER)
@@ -39,7 +39,7 @@ const CustomerAddressUniqueCustomerBillingAddress =
@Entity({ tableName: "customer_address" })
@CustomerAddressUniqueCustomerShippingAddress.MikroORMIndex()
@CustomerAddressUniqueCustomerBillingAddress.MikroORMIndex()
export default class Address {
export default class CustomerAddress {
[OptionalProps]: OptionalAddressProps
@PrimaryKey({ columnType: "text" })
@@ -19,7 +19,7 @@ import {
Property,
Rel,
} from "@mikro-orm/core"
import Address from "./address"
import CustomerAddress from "./address"
import CustomerGroup from "./customer-group"
import CustomerGroupCustomer from "./customer-group-customer"
@@ -77,10 +77,10 @@ export default class Customer {
})
groups = new Collection<Rel<CustomerGroup>>(this)
@OneToMany(() => Address, (address) => address.customer, {
@OneToMany(() => CustomerAddress, (address) => address.customer, {
cascade: [Cascade.REMOVE],
})
addresses = new Collection<Rel<Address>>(this)
addresses = new Collection<Rel<CustomerAddress>>(this)
@Property({
onCreate: () => new Date(),
@@ -1,5 +1,4 @@
export { default as Address } from "./address"
export { default as CustomerAddress } from "./address"
export { default as Customer } from "./customer"
export { default as CustomerGroup } from "./customer-group"
export { default as CustomerGroupCustomer } from "./customer-group-customer"
@@ -21,8 +21,8 @@ import {
} from "@medusajs/utils"
import { EntityManager } from "@mikro-orm/core"
import {
Address,
Customer,
CustomerAddress,
CustomerGroup,
CustomerGroupCustomer,
} from "@models"
@@ -31,23 +31,28 @@ import { joinerConfig } from "../joiner-config"
type InjectedDependencies = {
baseRepository: DAL.RepositoryService
customerService: ModulesSdkTypes.IMedusaInternalService<any>
addressService: ModulesSdkTypes.IMedusaInternalService<any>
customerAddressService: ModulesSdkTypes.IMedusaInternalService<any>
customerGroupService: ModulesSdkTypes.IMedusaInternalService<any>
customerGroupCustomerService: ModulesSdkTypes.IMedusaInternalService<any>
}
export default class CustomerModuleService
extends MedusaService<{
Address: { dto: CustomerAddressDTO }
CustomerAddress: { dto: CustomerAddressDTO }
Customer: { dto: CustomerDTO }
CustomerGroup: { dto: CustomerGroupDTO }
CustomerGroupCustomer: { dto: CustomerGroupCustomerDTO }
}>({ Address, Customer, CustomerGroup, CustomerGroupCustomer })
}>({
CustomerAddress,
Customer,
CustomerGroup,
CustomerGroupCustomer,
})
implements ICustomerModuleService
{
protected baseRepository_: DAL.RepositoryService
protected customerService_: ModulesSdkTypes.IMedusaInternalService<Customer>
protected addressService_: ModulesSdkTypes.IMedusaInternalService<Address>
protected customerAddressService_: ModulesSdkTypes.IMedusaInternalService<CustomerAddress>
protected customerGroupService_: ModulesSdkTypes.IMedusaInternalService<CustomerGroup>
protected customerGroupCustomerService_: ModulesSdkTypes.IMedusaInternalService<CustomerGroupCustomer>
@@ -55,7 +60,7 @@ export default class CustomerModuleService
{
baseRepository,
customerService,
addressService,
customerAddressService,
customerGroupService,
customerGroupCustomerService,
}: InjectedDependencies,
@@ -66,7 +71,7 @@ export default class CustomerModuleService
this.baseRepository_ = baseRepository
this.customerService_ = customerService
this.addressService_ = addressService
this.customerAddressService_ = customerAddressService
this.customerGroupService_ = customerGroupService
this.customerGroupCustomerService_ = customerGroupCustomerService
}
@@ -128,7 +133,10 @@ export default class CustomerModuleService
})
.flat()
await this.createAddresses(addressDataWithCustomerIds, sharedContext)
await this.createCustomerAddresses(
addressDataWithCustomerIds,
sharedContext
)
return customers as unknown as CustomerTypes.CustomerDTO[]
}
@@ -321,17 +329,17 @@ export default class CustomerModuleService
}
// @ts-expect-error
async createAddresses(
async createCustomerAddresses(
addresses: CustomerTypes.CreateCustomerAddressDTO[],
sharedContext?: Context
): Promise<CustomerTypes.CustomerAddressDTO[]>
async createAddresses(
async createCustomerAddresses(
address: CustomerTypes.CreateCustomerAddressDTO,
sharedContext?: Context
): Promise<CustomerTypes.CustomerAddressDTO>
@InjectManager("baseRepository_")
async createAddresses(
async createCustomerAddresses(
data:
| CustomerTypes.CreateCustomerAddressDTO
| CustomerTypes.CreateCustomerAddressDTO[],
@@ -339,7 +347,7 @@ export default class CustomerModuleService
): Promise<
CustomerTypes.CustomerAddressDTO | CustomerTypes.CustomerAddressDTO[]
> {
const addresses = await this.createAddresses_(data, sharedContext)
const addresses = await this.createCustomerAddresses_(data, sharedContext)
const serialized = await this.baseRepository_.serialize<
CustomerTypes.CustomerAddressDTO[]
@@ -353,37 +361,37 @@ export default class CustomerModuleService
}
@InjectTransactionManager("baseRepository_")
private async createAddresses_(
private async createCustomerAddresses_(
data:
| CustomerTypes.CreateCustomerAddressDTO
| CustomerTypes.CreateCustomerAddressDTO[],
@MedusaContext() sharedContext: Context = {}
) {
return await this.addressService_.create(
return await this.customerAddressService_.create(
Array.isArray(data) ? data : [data],
sharedContext
)
}
// @ts-expect-error
async updateAddresses(
async updateCustomerAddresses(
addressId: string,
data: CustomerTypes.UpdateCustomerAddressDTO,
sharedContext?: Context
): Promise<CustomerTypes.CustomerAddressDTO>
async updateAddresses(
async updateCustomerAddresses(
addressIds: string[],
data: CustomerTypes.UpdateCustomerAddressDTO,
sharedContext?: Context
): Promise<CustomerTypes.CustomerAddressDTO[]>
async updateAddresses(
async updateCustomerAddresses(
selector: CustomerTypes.FilterableCustomerAddressProps,
data: CustomerTypes.UpdateCustomerAddressDTO,
sharedContext?: Context
): Promise<CustomerTypes.CustomerAddressDTO[]>
@InjectTransactionManager("baseRepository_")
async updateAddresses(
async updateCustomerAddresses(
addressIdOrSelector:
| string
| string[]
@@ -416,7 +424,7 @@ export default class CustomerModuleService
}
}
const addresses = await this.addressService_.update(
const addresses = await this.customerAddressService_.update(
updateData,
sharedContext
)
@@ -131,6 +131,7 @@ moduleIntegrationTestRunner({
fulfillmentAddress: {
id: {
linkable: "fulfillment_address_id",
entity: "FulfillmentAddress",
primaryKey: "id",
serviceName: "fulfillment",
field: "fulfillmentAddress",
@@ -139,6 +140,7 @@ moduleIntegrationTestRunner({
fulfillmentItem: {
id: {
linkable: "fulfillment_item_id",
entity: "FulfillmentItem",
primaryKey: "id",
serviceName: "fulfillment",
field: "fulfillmentItem",
@@ -147,6 +149,7 @@ moduleIntegrationTestRunner({
fulfillmentLabel: {
id: {
linkable: "fulfillment_label_id",
entity: "FulfillmentLabel",
primaryKey: "id",
serviceName: "fulfillment",
field: "fulfillmentLabel",
@@ -155,6 +158,7 @@ moduleIntegrationTestRunner({
fulfillmentProvider: {
id: {
linkable: "fulfillment_provider_id",
entity: "FulfillmentProvider",
primaryKey: "id",
serviceName: "fulfillment",
field: "fulfillmentProvider",
@@ -163,6 +167,7 @@ moduleIntegrationTestRunner({
fulfillmentSet: {
id: {
linkable: "fulfillment_set_id",
entity: "FulfillmentSet",
primaryKey: "id",
serviceName: "fulfillment",
field: "fulfillmentSet",
@@ -171,6 +176,7 @@ moduleIntegrationTestRunner({
fulfillment: {
id: {
linkable: "fulfillment_id",
entity: "Fulfillment",
primaryKey: "id",
serviceName: "fulfillment",
field: "fulfillment",
@@ -179,6 +185,7 @@ moduleIntegrationTestRunner({
geoZone: {
id: {
linkable: "geo_zone_id",
entity: "GeoZone",
primaryKey: "id",
serviceName: "fulfillment",
field: "geoZone",
@@ -187,6 +194,7 @@ moduleIntegrationTestRunner({
serviceZone: {
id: {
linkable: "service_zone_id",
entity: "ServiceZone",
primaryKey: "id",
serviceName: "fulfillment",
field: "serviceZone",
@@ -195,6 +203,7 @@ moduleIntegrationTestRunner({
shippingOptionRule: {
id: {
linkable: "shipping_option_rule_id",
entity: "ShippingOptionRule",
primaryKey: "id",
serviceName: "fulfillment",
field: "shippingOptionRule",
@@ -203,6 +212,7 @@ moduleIntegrationTestRunner({
shippingOptionType: {
id: {
linkable: "shipping_option_type_id",
entity: "ShippingOptionType",
primaryKey: "id",
serviceName: "fulfillment",
field: "shippingOptionType",
@@ -211,6 +221,7 @@ moduleIntegrationTestRunner({
shippingOption: {
id: {
linkable: "shipping_option_id",
entity: "ShippingOption",
primaryKey: "id",
serviceName: "fulfillment",
field: "shippingOption",
@@ -219,6 +230,7 @@ moduleIntegrationTestRunner({
shippingProfile: {
id: {
linkable: "shipping_profile_id",
entity: "ShippingProfile",
primaryKey: "id",
serviceName: "fulfillment",
field: "shippingProfile",
@@ -28,6 +28,7 @@ moduleIntegrationTestRunner<IInventoryService>({
inventoryItem: {
id: {
field: "inventoryItem",
entity: "InventoryItem",
linkable: "inventory_item_id",
primaryKey: "id",
serviceName: "inventoryService",
@@ -36,6 +37,7 @@ moduleIntegrationTestRunner<IInventoryService>({
inventoryLevel: {
id: {
field: "inventoryLevel",
entity: "InventoryLevel",
linkable: "inventory_level_id",
primaryKey: "id",
serviceName: "inventoryService",
@@ -44,6 +46,7 @@ moduleIntegrationTestRunner<IInventoryService>({
reservationItem: {
id: {
field: "reservationItem",
entity: "ReservationItem",
linkable: "reservation_item_id",
primaryKey: "id",
serviceName: "inventoryService",
@@ -6,8 +6,8 @@ export const joinerConfig = defineJoinerConfig(Modules.INVENTORY, {
alias: [
{
name: ["inventory_items", "inventory_item", "inventory"],
entity: "InventoryItem",
args: {
entity: "InventoryItem",
methodSuffix: "InventoryItems",
},
},
@@ -18,8 +18,8 @@ export const joinerConfig = defineJoinerConfig(Modules.INVENTORY, {
"reservation_item",
"reservation_items",
],
entity: "ReservationItem",
args: {
entity: "ReservationItem",
methodSuffix: "ReservationItems",
},
},
@@ -11,15 +11,14 @@ export const CartPaymentCollection: ModuleJoinerConfig = {
alias: [
{
name: ["cart_payment_collection", "cart_payment_collections"],
args: {
entity: "LinkCartPaymentCollection",
},
entity: "LinkCartPaymentCollection",
},
],
primaryKeys: ["id", "cart_id", "payment_collection_id"],
relationships: [
{
serviceName: Modules.CART,
entity: "Cart",
primaryKey: "id",
foreignKey: "cart_id",
alias: "cart",
@@ -29,6 +28,7 @@ export const CartPaymentCollection: ModuleJoinerConfig = {
},
{
serviceName: Modules.PAYMENT,
entity: "PaymentCollection",
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
@@ -11,15 +11,14 @@ export const CartPromotion: ModuleJoinerConfig = {
alias: [
{
name: ["cart_promotion", "cart_promotions"],
args: {
entity: "LinkCartPromotion",
},
entity: "LinkCartPromotion",
},
],
primaryKeys: ["id", "cart_id", "promotion_id"],
relationships: [
{
serviceName: Modules.CART,
entity: "Cart",
primaryKey: "id",
foreignKey: "cart_id",
alias: "cart",
@@ -29,6 +28,7 @@ export const CartPromotion: ModuleJoinerConfig = {
},
{
serviceName: Modules.PROMOTION,
entity: "Promotion",
primaryKey: "id",
foreignKey: "promotion_id",
alias: "promotions",
@@ -11,13 +11,14 @@ export const LocationFulfillmentProvider: ModuleJoinerConfig = {
alias: [
{
name: ["location_fulfillment_provider", "location_fulfillment_providers"],
args: { entity: "LinkLocationFulfillmentProvider" },
entity: "LinkLocationFulfillmentProvider",
},
],
primaryKeys: ["id", "stock_location_id", "fulfillment_provider_id"],
relationships: [
{
serviceName: Modules.STOCK_LOCATION,
entity: "StockLocation",
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
@@ -25,6 +26,7 @@ export const LocationFulfillmentProvider: ModuleJoinerConfig = {
},
{
serviceName: Modules.FULFILLMENT,
entity: "FulfillmentProvider",
primaryKey: "id",
foreignKey: "fulfillment_provider_id",
alias: "fulfillment_provider",
@@ -11,15 +11,14 @@ export const LocationFulfillmentSet: ModuleJoinerConfig = {
alias: [
{
name: ["location_fulfillment_set", "location_fulfillment_sets"],
args: {
entity: "LinkLocationFulfillmentSet",
},
entity: "LinkLocationFulfillmentSet",
},
],
primaryKeys: ["id", "stock_location_id", "fulfillment_set_id"],
relationships: [
{
serviceName: Modules.STOCK_LOCATION,
entity: "StockLocation",
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
@@ -29,6 +28,7 @@ export const LocationFulfillmentSet: ModuleJoinerConfig = {
},
{
serviceName: Modules.FULFILLMENT,
entity: "FulfillmentSet",
primaryKey: "id",
foreignKey: "fulfillment_set_id",
alias: "fulfillment_set",
@@ -11,15 +11,14 @@ export const OrderCart: ModuleJoinerConfig = {
alias: [
{
name: ["order_cart", "order_carts"],
args: {
entity: "LinkOrderCart",
},
entity: "LinkOrderCart",
},
],
primaryKeys: ["id", "order_id", "cart_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
@@ -29,6 +28,7 @@ export const OrderCart: ModuleJoinerConfig = {
},
{
serviceName: Modules.CART,
entity: "Cart",
primaryKey: "id",
foreignKey: "cart_id",
alias: "cart",
@@ -14,15 +14,14 @@ export const OrderClaimPaymentCollection: ModuleJoinerConfig = {
"order_claim_payment_collection",
"order_claim_payment_collections",
],
args: {
entity: "LinkOrderClaimPaymentCollection",
},
entity: "LinkOrderClaimPaymentCollection",
},
],
primaryKeys: ["id", "claim_id", "payment_collection_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "OrderClaim",
primaryKey: "id",
foreignKey: "claim_id",
alias: "order",
@@ -32,6 +31,7 @@ export const OrderClaimPaymentCollection: ModuleJoinerConfig = {
},
{
serviceName: Modules.PAYMENT,
entity: "PaymentCollection",
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
@@ -14,15 +14,14 @@ export const OrderExchangePaymentCollection: ModuleJoinerConfig = {
"order_exchange_payment_collection",
"order_exchange_payment_collections",
],
args: {
entity: "LinkOrderExchangePaymentCollection",
},
entity: "LinkOrderExchangePaymentCollection",
},
],
primaryKeys: ["id", "exchange_id", "payment_collection_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "OrderExchange",
primaryKey: "id",
foreignKey: "exchange_id",
alias: "order",
@@ -32,6 +31,7 @@ export const OrderExchangePaymentCollection: ModuleJoinerConfig = {
},
{
serviceName: Modules.PAYMENT,
entity: "PaymentCollection",
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
@@ -11,15 +11,14 @@ export const OrderFulfillment: ModuleJoinerConfig = {
alias: [
{
name: ["order_fulfillment", "order_fulfillments"],
args: {
entity: "LinkOrderFulfillment",
},
entity: "LinkOrderFulfillment",
},
],
primaryKeys: ["id", "order_id", "fulfillment_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
@@ -29,11 +28,11 @@ export const OrderFulfillment: ModuleJoinerConfig = {
},
{
serviceName: Modules.FULFILLMENT,
entity: "Fulfillment",
primaryKey: "id",
foreignKey: "fulfillment_id",
alias: "fulfillments",
args: {
// TODO: We are not suppose to know the module implementation here, wait for later to think about inferring it
methodSuffix: "Fulfillments",
},
},
@@ -11,15 +11,14 @@ export const OrderPaymentCollection: ModuleJoinerConfig = {
alias: [
{
name: ["order_payment_collection", "order_payment_collections"],
args: {
entity: "LinkOrderPaymentCollection",
},
entity: "LinkOrderPaymentCollection",
},
],
primaryKeys: ["id", "order_id", "payment_collection_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
@@ -29,6 +28,7 @@ export const OrderPaymentCollection: ModuleJoinerConfig = {
},
{
serviceName: Modules.PAYMENT,
entity: "PaymentCollection",
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
@@ -11,15 +11,14 @@ export const OrderPromotion: ModuleJoinerConfig = {
alias: [
{
name: ["order_promotion", "order_promotions"],
args: {
entity: "LinkOrderPromotion",
},
entity: "LinkOrderPromotion",
},
],
primaryKeys: ["id", "order_id", "promotion_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
@@ -29,6 +28,7 @@ export const OrderPromotion: ModuleJoinerConfig = {
},
{
serviceName: Modules.PROMOTION,
entity: "Promotion",
primaryKey: "id",
foreignKey: "promotion_id",
alias: "promotion",
@@ -11,15 +11,14 @@ export const ReturnFulfillment: ModuleJoinerConfig = {
alias: [
{
name: ["return_fulfillment", "return_fulfillments"],
args: {
entity: "LinkReturnFulfillment",
},
entity: "LinkReturnFulfillment",
},
],
primaryKeys: ["id", "return_id", "fulfillment_id"],
relationships: [
{
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "id",
foreignKey: "return_id",
alias: "return",
@@ -29,6 +28,7 @@ export const ReturnFulfillment: ModuleJoinerConfig = {
},
{
serviceName: Modules.FULFILLMENT,
entity: "Fulfillment",
primaryKey: "id",
foreignKey: "fulfillment_id",
alias: "fulfillments",
@@ -20,6 +20,7 @@ export const ProductSalesChannel: ModuleJoinerConfig = {
relationships: [
{
serviceName: Modules.PRODUCT,
entity: "Product",
primaryKey: "id",
foreignKey: "product_id",
alias: "product",
@@ -29,6 +30,7 @@ export const ProductSalesChannel: ModuleJoinerConfig = {
},
{
serviceName: Modules.SALES_CHANNEL,
entity: "SalesChannel",
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
@@ -20,15 +20,14 @@ export const ProductVariantInventoryItem: ModuleJoinerConfig = {
"product_variant_inventory_item",
"product_variant_inventory_items",
],
args: {
entity: "LinkProductVariantInventoryItem",
},
entity: "LinkProductVariantInventoryItem",
},
],
primaryKeys: ["id", "variant_id", "inventory_item_id"],
relationships: [
{
serviceName: Modules.PRODUCT,
entity: "ProductVariant",
primaryKey: "id",
foreignKey: "variant_id",
alias: "variant",
@@ -38,6 +37,7 @@ export const ProductVariantInventoryItem: ModuleJoinerConfig = {
},
{
serviceName: Modules.INVENTORY,
entity: "InventoryItem",
primaryKey: "id",
foreignKey: "inventory_item_id",
alias: "inventory",
@@ -11,15 +11,14 @@ export const ProductVariantPriceSet: ModuleJoinerConfig = {
alias: [
{
name: ["product_variant_price_set", "product_variant_price_sets"],
args: {
entity: "LinkProductVariantPriceSet",
},
entity: "LinkProductVariantPriceSet",
},
],
primaryKeys: ["id", "variant_id", "price_set_id"],
relationships: [
{
serviceName: Modules.PRODUCT,
entity: "ProductVariant",
primaryKey: "id",
foreignKey: "variant_id",
alias: "variant",
@@ -29,6 +28,7 @@ export const ProductVariantPriceSet: ModuleJoinerConfig = {
},
{
serviceName: Modules.PRICING,
entity: "PriceSet",
primaryKey: "id",
foreignKey: "price_set_id",
alias: "price_set",
@@ -20,6 +20,7 @@ export const PublishableApiKeySalesChannel: ModuleJoinerConfig = {
relationships: [
{
serviceName: Modules.API_KEY,
entity: "ApiKey",
primaryKey: "id",
foreignKey: "publishable_key_id",
alias: "api_key",
@@ -29,6 +30,7 @@ export const PublishableApiKeySalesChannel: ModuleJoinerConfig = {
},
{
serviceName: Modules.SALES_CHANNEL,
entity: "SalesChannel",
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
@@ -9,6 +9,7 @@ export const CartCustomer: ModuleJoinerConfig = {
serviceName: Modules.CART,
relationship: {
serviceName: Modules.CUSTOMER,
entity: "Customer",
primaryKey: "id",
foreignKey: "customer_id",
alias: "customer",
@@ -21,6 +22,7 @@ export const CartCustomer: ModuleJoinerConfig = {
serviceName: Modules.CUSTOMER,
relationship: {
serviceName: Modules.CART,
entity: "Cart",
primaryKey: "customer_id",
foreignKey: "id",
alias: "carts",
@@ -21,6 +21,7 @@ export const CartProduct: ModuleJoinerConfig = {
serviceName: Modules.CART,
relationship: {
serviceName: Modules.PRODUCT,
entity: "ProductVariant",
primaryKey: "id",
foreignKey: "items.variant_id",
alias: "variant",
@@ -33,6 +34,7 @@ export const CartProduct: ModuleJoinerConfig = {
serviceName: Modules.PRODUCT,
relationship: {
serviceName: Modules.CART,
entity: "LineItem",
primaryKey: "variant_id",
foreignKey: "id",
alias: "cart_items",
@@ -9,6 +9,7 @@ export const CartRegion: ModuleJoinerConfig = {
serviceName: Modules.CART,
relationship: {
serviceName: Modules.REGION,
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
@@ -21,6 +22,7 @@ export const CartRegion: ModuleJoinerConfig = {
serviceName: Modules.REGION,
relationship: {
serviceName: Modules.CART,
entity: "Cart",
primaryKey: "region_id",
foreignKey: "id",
alias: "carts",
@@ -9,6 +9,7 @@ export const CartSalesChannel: ModuleJoinerConfig = {
serviceName: Modules.CART,
relationship: {
serviceName: Modules.SALES_CHANNEL,
entity: "SalesChannel",
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
@@ -21,6 +22,7 @@ export const CartSalesChannel: ModuleJoinerConfig = {
serviceName: Modules.SALES_CHANNEL,
relationship: {
serviceName: Modules.CART,
entity: "Cart",
primaryKey: "sales_channel_id",
foreignKey: "id",
alias: "carts",
@@ -9,6 +9,7 @@ export const InventoryLevelStockLocation: ModuleJoinerConfig = {
serviceName: Modules.INVENTORY,
relationship: {
serviceName: Modules.STOCK_LOCATION,
entity: "StockLocation",
primaryKey: "id",
foreignKey: "location_id",
alias: "stock_locations",
@@ -9,6 +9,7 @@ export const LineItemAdjustmentPromotion: ModuleJoinerConfig = {
serviceName: Modules.CART,
relationship: {
serviceName: Modules.PROMOTION,
entity: "Promotion",
primaryKey: "id",
foreignKey: "promotion_id",
alias: "promotion",
@@ -9,6 +9,7 @@ export const OrderCustomer: ModuleJoinerConfig = {
serviceName: Modules.ORDER,
relationship: {
serviceName: Modules.CUSTOMER,
entity: "Customer",
primaryKey: "id",
foreignKey: "customer_id",
alias: "customer",
@@ -21,6 +22,7 @@ export const OrderCustomer: ModuleJoinerConfig = {
serviceName: Modules.CUSTOMER,
relationship: {
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "customer_id",
foreignKey: "id",
alias: "orders",
@@ -9,6 +9,7 @@ export const OrderProduct: ModuleJoinerConfig = {
serviceName: Modules.ORDER,
relationship: {
serviceName: Modules.PRODUCT,
entity: "Product",
primaryKey: "id",
foreignKey: "items.product_id",
alias: "product",
@@ -21,6 +22,7 @@ export const OrderProduct: ModuleJoinerConfig = {
serviceName: Modules.ORDER,
relationship: {
serviceName: Modules.PRODUCT,
entity: "ProductVariant",
primaryKey: "id",
foreignKey: "items.variant_id",
alias: "variant",
@@ -33,12 +35,13 @@ export const OrderProduct: ModuleJoinerConfig = {
serviceName: Modules.PRODUCT,
relationship: {
serviceName: Modules.ORDER,
entity: "OrderLineItem",
primaryKey: "variant_id",
foreignKey: "id",
alias: "order_items",
isList: true,
args: {
methodSuffix: "LineItems",
methodSuffix: "OrderLineItems",
},
},
},
@@ -9,6 +9,7 @@ export const OrderRegion: ModuleJoinerConfig = {
serviceName: Modules.ORDER,
relationship: {
serviceName: Modules.REGION,
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
@@ -21,6 +22,7 @@ export const OrderRegion: ModuleJoinerConfig = {
serviceName: Modules.REGION,
relationship: {
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "region_id",
foreignKey: "id",
alias: "orders",
@@ -9,6 +9,7 @@ export const OrderSalesChannel: ModuleJoinerConfig = {
serviceName: Modules.ORDER,
relationship: {
serviceName: Modules.SALES_CHANNEL,
entity: "SalesChannel",
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
@@ -21,6 +22,7 @@ export const OrderSalesChannel: ModuleJoinerConfig = {
serviceName: Modules.SALES_CHANNEL,
relationship: {
serviceName: Modules.ORDER,
entity: "Order",
primaryKey: "sales_channel_id",
foreignKey: "id",
alias: "orders",
@@ -9,6 +9,7 @@ export const StoreCurrencies: ModuleJoinerConfig = {
serviceName: Modules.STORE,
relationship: {
serviceName: Modules.CURRENCY,
entity: "Currency",
primaryKey: "code",
foreignKey: "supported_currencies.currency_code",
alias: "currency",
@@ -11,15 +11,14 @@ export const RegionPaymentProvider: ModuleJoinerConfig = {
alias: [
{
name: ["region_payment_provider", "region_payment_providers"],
args: {
entity: "LinkRegionPaymentProvider",
},
entity: "LinkRegionPaymentProvider",
},
],
primaryKeys: ["id", "region_id", "payment_provider_id"],
relationships: [
{
serviceName: Modules.REGION,
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
@@ -29,6 +28,7 @@ export const RegionPaymentProvider: ModuleJoinerConfig = {
},
{
serviceName: Modules.PAYMENT,
entity: "PaymentProvider",
primaryKey: "id",
foreignKey: "payment_provider_id",
alias: "payment_provider",
@@ -11,15 +11,14 @@ export const SalesChannelLocation: ModuleJoinerConfig = {
alias: [
{
name: ["sales_channel_location", "sales_channel_locations"],
args: {
entity: "LinkSalesChannelLocation",
},
entity: "LinkSalesChannelLocation",
},
],
primaryKeys: ["id", "sales_channel_id", "stock_location_id"],
relationships: [
{
serviceName: Modules.SALES_CHANNEL,
entity: "SalesChannel",
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
@@ -29,6 +28,7 @@ export const SalesChannelLocation: ModuleJoinerConfig = {
},
{
serviceName: Modules.STOCK_LOCATION,
entity: "StockLocation",
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
@@ -11,15 +11,14 @@ export const ShippingOptionPriceSet: ModuleJoinerConfig = {
alias: [
{
name: ["shipping_option_price_set", "shipping_option_price_sets"],
args: {
entity: "LinkShippingOptionPriceSet",
},
entity: "LinkShippingOptionPriceSet",
},
],
primaryKeys: ["id", "shipping_option_id", "price_set_id"],
relationships: [
{
serviceName: Modules.FULFILLMENT,
entity: "ShippingOption",
primaryKey: "id",
foreignKey: "shipping_option_id",
alias: "shipping_option",
@@ -29,6 +28,7 @@ export const ShippingOptionPriceSet: ModuleJoinerConfig = {
},
{
serviceName: Modules.PRICING,
entity: "PriceSet",
primaryKey: "id",
foreignKey: "price_set_id",
alias: "price_set",
@@ -139,7 +139,7 @@ export const initialize = async (
for (const alias of definition.alias) {
alias.args ??= {}
alias.args.entity = toPascalCase(
alias.entity = toPascalCase(
"Link_" +
(definition.databaseConfig?.tableName ??
composeTableName(
@@ -7,12 +7,12 @@ import {
NotificationEvents,
NotificationStatus,
} from "@medusajs/utils"
import { NotificationModuleService } from "@services"
import {
MockEventBusService,
moduleIntegrationTestRunner,
} from "medusa-test-utils"
import { resolve } from "path"
import { NotificationModuleService } from "@services"
let moduleOptions = {
providers: [
@@ -58,6 +58,7 @@ moduleIntegrationTestRunner<INotificationModuleService>({
notification: {
id: {
linkable: "notification_id",
entity: "Notification",
primaryKey: "id",
serviceName: "notification",
field: "notification",
@@ -33,6 +33,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
order: {
id: {
linkable: "order_id",
entity: "Order",
primaryKey: "id",
serviceName: "order",
field: "order",
@@ -41,6 +42,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
orderAddress: {
id: {
linkable: "order_address_id",
entity: "OrderAddress",
primaryKey: "id",
serviceName: "order",
field: "orderAddress",
@@ -49,6 +51,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
orderChange: {
id: {
linkable: "order_change_id",
entity: "OrderChange",
primaryKey: "id",
serviceName: "order",
field: "orderChange",
@@ -57,12 +60,14 @@ moduleIntegrationTestRunner<IOrderModuleService>({
orderClaim: {
id: {
linkable: "order_claim_id",
entity: "OrderClaim",
primaryKey: "id",
serviceName: "order",
field: "orderClaim",
},
claim_id: {
linkable: "claim_id",
entity: "OrderClaim",
primaryKey: "claim_id",
serviceName: "order",
field: "orderClaim",
@@ -71,12 +76,14 @@ moduleIntegrationTestRunner<IOrderModuleService>({
orderExchange: {
id: {
linkable: "order_exchange_id",
entity: "OrderExchange",
primaryKey: "id",
serviceName: "order",
field: "orderExchange",
},
exchange_id: {
linkable: "exchange_id",
entity: "OrderExchange",
primaryKey: "exchange_id",
serviceName: "order",
field: "orderExchange",
@@ -85,6 +92,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
orderLineItem: {
id: {
linkable: "order_line_item_id",
entity: "OrderLineItem",
primaryKey: "id",
serviceName: "order",
field: "orderLineItem",
@@ -93,6 +101,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
orderShippingMethod: {
id: {
linkable: "order_shipping_method_id",
entity: "OrderShippingMethod",
primaryKey: "id",
serviceName: "order",
field: "orderShippingMethod",
@@ -101,6 +110,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
orderTransaction: {
id: {
linkable: "order_transaction_id",
entity: "OrderTransaction",
primaryKey: "id",
serviceName: "order",
field: "orderTransaction",
@@ -109,6 +119,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
return: {
id: {
linkable: "return_id",
entity: "Return",
primaryKey: "id",
serviceName: "order",
field: "return",
@@ -117,6 +128,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
returnReason: {
id: {
linkable: "return_reason_id",
entity: "ReturnReason",
primaryKey: "id",
serviceName: "order",
field: "returnReason",
@@ -35,6 +35,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
payment: {
id: {
linkable: "payment_id",
entity: "Payment",
primaryKey: "id",
serviceName: "payment",
field: "payment",
@@ -43,6 +44,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
paymentCollection: {
id: {
linkable: "payment_collection_id",
entity: "PaymentCollection",
primaryKey: "id",
serviceName: "payment",
field: "paymentCollection",
@@ -51,6 +53,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
paymentProvider: {
id: {
linkable: "payment_provider_id",
entity: "PaymentProvider",
primaryKey: "id",
serviceName: "payment",
field: "paymentProvider",
@@ -59,6 +62,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
paymentSession: {
id: {
field: "paymentSession",
entity: "PaymentSession",
linkable: "payment_session_id",
primaryKey: "id",
serviceName: "payment",
@@ -67,6 +71,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
refundReason: {
id: {
linkable: "refund_reason_id",
entity: "RefundReason",
primaryKey: "id",
serviceName: "payment",
field: "refundReason",
@@ -1,7 +1,7 @@
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { IPricingModuleService } from "@medusajs/types"
import { Module, Modules } from "@medusajs/utils"
import { PricingModuleService } from "@services"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
moduleIntegrationTestRunner<IPricingModuleService>({
moduleName: Modules.PRICING,
@@ -27,6 +27,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
priceSet: {
id: {
linkable: "price_set_id",
entity: "PriceSet",
primaryKey: "id",
serviceName: "pricingService",
field: "priceSet",
@@ -35,6 +36,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
priceList: {
id: {
linkable: "price_list_id",
entity: "PriceList",
primaryKey: "id",
serviceName: "pricingService",
field: "priceList",
@@ -43,6 +45,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
price: {
id: {
linkable: "price_id",
entity: "Price",
primaryKey: "id",
serviceName: "pricingService",
field: "price",
@@ -51,6 +54,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
pricePreference: {
id: {
linkable: "price_preference_id",
entity: "PricePreference",
primaryKey: "id",
serviceName: "pricingService",
field: "pricePreference",
@@ -65,6 +65,7 @@ moduleIntegrationTestRunner<Service>({
product: {
id: {
linkable: "product_id",
entity: "Product",
primaryKey: "id",
serviceName: "productService",
field: "product",
@@ -73,12 +74,14 @@ moduleIntegrationTestRunner<Service>({
productVariant: {
id: {
linkable: "product_variant_id",
entity: "ProductVariant",
primaryKey: "id",
serviceName: "productService",
field: "productVariant",
},
variant_id: {
field: "productVariant",
entity: "ProductVariant",
linkable: "variant_id",
primaryKey: "variant_id",
serviceName: "productService",
@@ -87,6 +90,7 @@ moduleIntegrationTestRunner<Service>({
productOption: {
id: {
linkable: "product_option_id",
entity: "ProductOption",
primaryKey: "id",
serviceName: "productService",
field: "productOption",
@@ -95,6 +99,7 @@ moduleIntegrationTestRunner<Service>({
productType: {
id: {
linkable: "product_type_id",
entity: "ProductType",
primaryKey: "id",
serviceName: "productService",
field: "productType",
@@ -103,6 +108,7 @@ moduleIntegrationTestRunner<Service>({
productImage: {
id: {
linkable: "product_image_id",
entity: "ProductImage",
primaryKey: "id",
serviceName: "productService",
field: "productImage",
@@ -111,6 +117,7 @@ moduleIntegrationTestRunner<Service>({
productTag: {
id: {
linkable: "product_tag_id",
entity: "ProductTag",
primaryKey: "id",
serviceName: "productService",
field: "productTag",
@@ -119,6 +126,7 @@ moduleIntegrationTestRunner<Service>({
productCollection: {
id: {
linkable: "product_collection_id",
entity: "ProductCollection",
primaryKey: "id",
serviceName: "productService",
field: "productCollection",
@@ -127,6 +135,7 @@ moduleIntegrationTestRunner<Service>({
productCategory: {
id: {
linkable: "product_category_id",
entity: "ProductCategory",
primaryKey: "id",
serviceName: "productService",
field: "productCategory",
@@ -31,8 +31,9 @@ export const joinerConfig = defineJoinerConfig(Modules.PRODUCT, {
alias: [
{
name: ["product_variant", "product_variants", "variant", "variants"],
entity: "ProductVariant",
args: {
entity: "ProductVariant",
methodSuffix: "ProductVariants",
},
},
],
@@ -6,14 +6,14 @@ import {
Modules,
PromotionType,
} from "@medusajs/utils"
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
import { PromotionModuleService } from "@services"
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
import { createCampaigns } from "../../../__fixtures__/campaigns"
import {
createDefaultPromotion,
createDefaultPromotions,
createPromotions,
} from "../../../__fixtures__/promotion"
import { PromotionModuleService } from "@services"
jest.setTimeout(30000)
@@ -47,6 +47,7 @@ moduleIntegrationTestRunner({
promotion: {
id: {
linkable: "promotion_id",
entity: "Promotion",
primaryKey: "id",
serviceName: "promotion",
field: "promotion",
@@ -55,6 +56,7 @@ moduleIntegrationTestRunner({
campaign: {
id: {
linkable: "campaign_id",
entity: "Campaign",
primaryKey: "id",
serviceName: "promotion",
field: "campaign",
@@ -63,6 +65,7 @@ moduleIntegrationTestRunner({
promotionRule: {
id: {
linkable: "promotion_rule_id",
entity: "PromotionRule",
primaryKey: "id",
serviceName: "promotion",
field: "promotionRule",
@@ -1,7 +1,7 @@
import { IRegionModuleService } from "@medusajs/types"
import { Module, Modules } from "@medusajs/utils"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { RegionModuleService } from "@services"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(30000)
@@ -24,6 +24,7 @@ moduleIntegrationTestRunner<IRegionModuleService>({
region: {
id: {
linkable: "region_id",
entity: "Region",
primaryKey: "id",
serviceName: "region",
field: "region",
@@ -32,6 +33,7 @@ moduleIntegrationTestRunner<IRegionModuleService>({
country: {
iso_2: {
linkable: "country_iso_2",
entity: "Country",
primaryKey: "iso_2",
serviceName: "region",
field: "country",
@@ -1,7 +1,7 @@
import { ISalesChannelModuleService } from "@medusajs/types"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { Module, Modules } from "@medusajs/utils"
import { SalesChannelModuleService } from "@services"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(30000)
@@ -49,6 +49,7 @@ moduleIntegrationTestRunner<ISalesChannelModuleService>({
salesChannel: {
id: {
linkable: "sales_channel_id",
entity: "SalesChannel",
primaryKey: "id",
serviceName: "salesChannel",
field: "salesChannel",
@@ -28,6 +28,7 @@ moduleIntegrationTestRunner<IStockLocationService>({
stockLocationAddress: {
id: {
linkable: "stock_location_address_id",
entity: "StockLocationAddress",
primaryKey: "id",
serviceName: "stockLocationService",
field: "stockLocationAddress",
@@ -36,12 +37,14 @@ moduleIntegrationTestRunner<IStockLocationService>({
stockLocation: {
id: {
field: "stockLocation",
entity: "StockLocation",
linkable: "stock_location_id",
primaryKey: "id",
serviceName: "stockLocationService",
},
location_id: {
linkable: "location_id",
entity: "StockLocation",
primaryKey: "location_id",
serviceName: "stockLocationService",
field: "stockLocation",
@@ -1,8 +1,8 @@
import { IStoreModuleService } from "@medusajs/types"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { createStoreFixture } from "../__fixtures__"
import { Module, Modules } from "@medusajs/utils"
import { StoreModuleService } from "@services"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { createStoreFixture } from "../__fixtures__"
jest.setTimeout(100000)
@@ -25,6 +25,7 @@ moduleIntegrationTestRunner<IStoreModuleService>({
store: {
id: {
linkable: "store_id",
entity: "Store",
primaryKey: "id",
serviceName: "store",
field: "store",
@@ -33,6 +34,7 @@ moduleIntegrationTestRunner<IStoreModuleService>({
storeCurrency: {
id: {
linkable: "store_currency_id",
entity: "StoreCurrency",
primaryKey: "id",
serviceName: "store",
field: "storeCurrency",
@@ -30,6 +30,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
taxRate: {
id: {
linkable: "tax_rate_id",
entity: "TaxRate",
primaryKey: "id",
serviceName: "tax",
field: "taxRate",
@@ -38,6 +39,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
taxRegion: {
id: {
linkable: "tax_region_id",
entity: "TaxRegion",
primaryKey: "id",
serviceName: "tax",
field: "taxRegion",
@@ -46,6 +48,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
taxRateRule: {
id: {
linkable: "tax_rate_rule_id",
entity: "TaxRateRule",
primaryKey: "id",
serviceName: "tax",
field: "taxRateRule",
@@ -54,6 +57,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
taxProvider: {
id: {
linkable: "tax_provider_id",
entity: "TaxProvider",
primaryKey: "id",
serviceName: "tax",
field: "taxProvider",
@@ -1,10 +1,10 @@
import { IUserModuleService } from "@medusajs/types"
import { Module, Modules, UserEvents } from "@medusajs/utils"
import { UserModuleService } from "@services"
import {
MockEventBusService,
moduleIntegrationTestRunner,
} from "medusa-test-utils"
import { UserModuleService } from "@services"
jest.setTimeout(30000)
@@ -43,6 +43,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
user: {
id: {
linkable: "user_id",
entity: "User",
primaryKey: "id",
serviceName: "user",
field: "user",
@@ -51,6 +52,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
invite: {
id: {
linkable: "invite_id",
entity: "Invite",
primaryKey: "id",
serviceName: "user",
field: "invite",
@@ -5,6 +5,8 @@ import {
RemoteQueryFunction,
} from "@medusajs/types"
import { Module, Modules, TransactionHandlerType } from "@medusajs/utils"
import { WorkflowsModuleService } from "@services"
import { asFunction } from "awilix"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { setTimeout as setTimeoutPromise } from "timers/promises"
import "../__fixtures__"
@@ -20,8 +22,6 @@ import {
workflowEventGroupIdStep2Mock,
} from "../__fixtures__/workflow_event_group_id"
import { createScheduled } from "../__fixtures__/workflow_scheduled"
import { WorkflowsModuleService } from "@services"
import { asFunction } from "awilix"
jest.setTimeout(100000)
@@ -51,6 +51,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
workflowExecution: {
id: {
linkable: "workflow_execution_id",
entity: "WorkflowExecution",
primaryKey: "id",
serviceName: "workflows",
field: "workflowExecution",
@@ -83,6 +83,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
workflowExecution: {
id: {
linkable: "workflow_execution_id",
entity: "WorkflowExecution",
primaryKey: "id",
serviceName: "workflows",
field: "workflowExecution",