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

View File

@@ -91,7 +91,7 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
const [address] = await customerModuleService.listAddresses({
const [address] = await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_shipping: true,
})
@@ -126,7 +126,7 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
const [address] = await customerModuleService.listAddresses({
const [address] = await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_billing: true,
})

View File

@@ -34,7 +34,7 @@ medusaIntegrationTestRunner({
last_name: "Doe",
})
const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",

View File

@@ -34,7 +34,7 @@ medusaIntegrationTestRunner({
last_name: "Doe",
})
const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -66,21 +66,23 @@ medusaIntegrationTestRunner({
first_name: "John",
last_name: "Doe",
})
const [, address] = await customerModuleService.createAddresses([
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_shipping: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
])
const [, address] = await customerModuleService.createCustomerAddresses(
[
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_shipping: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
]
)
const response = await api.post(
`/admin/customers/${customer.id}/addresses/${address.id}`,
@@ -93,10 +95,11 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
const [defaultAddress] = await customerModuleService.listAddresses({
customer_id: customer.id,
is_default_shipping: true,
})
const [defaultAddress] =
await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_shipping: true,
})
expect(defaultAddress.first_name).toEqual("jane")
expect(defaultAddress.address_1).toEqual("Test street 2")
@@ -108,21 +111,23 @@ medusaIntegrationTestRunner({
first_name: "John",
last_name: "Doe",
})
const [, address] = await customerModuleService.createAddresses([
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_billing: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
])
const [, address] = await customerModuleService.createCustomerAddresses(
[
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_billing: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
]
)
const response = await api.post(
`/admin/customers/${customer.id}/addresses/${address.id}`,
@@ -135,10 +140,11 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
const [defaultAddress] = await customerModuleService.listAddresses({
customer_id: customer.id,
is_default_billing: true,
})
const [defaultAddress] =
await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_billing: true,
})
expect(defaultAddress.first_name).toEqual("jane")
expect(defaultAddress.address_1).toEqual("Test street 2")

View File

@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer
)
const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -57,7 +57,7 @@ medusaIntegrationTestRunner({
first_name: "Jane",
last_name: "Doe",
})
const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: otherCustomer.id,
first_name: "John",
last_name: "Doe",

View File

@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer
)
await customerModuleService.createAddresses([
await customerModuleService.createCustomerAddresses([
{
first_name: "Test",
last_name: "Test",

View File

@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer
)
const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
@@ -59,7 +59,7 @@ medusaIntegrationTestRunner({
last_name: "Doe",
})
const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: otherCustomer.id,
first_name: "John",
last_name: "Doe",

View File

@@ -2,8 +2,8 @@ import { medusaIntegrationTestRunner } from "medusa-test-utils"
import CurrencyModule from "@medusajs/currency"
import { MedusaModule } from "@medusajs/modules-sdk"
import RegionModule from "@medusajs/region"
import ProductModule from "@medusajs/product"
import RegionModule from "@medusajs/region"
import { defineLink } from "@medusajs/utils"
jest.setTimeout(50000)
@@ -43,6 +43,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "currency",
entity: "Currency",
primaryKey: "code",
foreignKey: "currency_code",
alias: "currency",
@@ -53,6 +54,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
@@ -69,6 +71,7 @@ medusaIntegrationTestRunner({
region: {
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
@@ -85,6 +88,7 @@ medusaIntegrationTestRunner({
currency: {
path: "currency_link.currency",
isList: false,
forwardArgumentsOnPath: ["currency_link.currency"],
},
},
relationship: {
@@ -134,6 +138,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "productService",
entity: "ProductVariant",
primaryKey: "id",
foreignKey: "product_variant_id",
alias: "product_variant",
@@ -144,6 +149,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
@@ -160,6 +166,7 @@ medusaIntegrationTestRunner({
region: {
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
@@ -176,6 +183,9 @@ medusaIntegrationTestRunner({
product_variant: {
path: "product_variant_link.product_variant",
isList: false,
forwardArgumentsOnPath: [
"product_variant_link.product_variant",
],
},
},
relationship: {
@@ -228,6 +238,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "currency",
entity: "Currency",
primaryKey: "code",
foreignKey: "currency_code",
alias: "currency",
@@ -238,6 +249,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
@@ -254,6 +266,7 @@ medusaIntegrationTestRunner({
region: {
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
@@ -270,6 +283,7 @@ medusaIntegrationTestRunner({
currency: {
path: "currency_link.currency",
isList: false,
forwardArgumentsOnPath: ["currency_link.currency"],
},
},
relationship: {
@@ -318,6 +332,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "currency",
entity: "Currency",
primaryKey: "code",
foreignKey: "currency_code",
alias: "currency",
@@ -328,6 +343,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
@@ -344,6 +360,7 @@ medusaIntegrationTestRunner({
regions: {
path: "region_link.region",
isList: true,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
@@ -360,6 +377,7 @@ medusaIntegrationTestRunner({
currency: {
path: "currency_link.currency",
isList: false,
forwardArgumentsOnPath: ["currency_link.currency"],
},
},
relationship: {

View File

@@ -16,7 +16,7 @@ export const createCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
const addresses = await service.createAddresses(data)
const addresses = await service.createCustomerAddresses(data)
return new StepResponse(
addresses,
@@ -32,6 +32,6 @@ export const createCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await service.deleteAddresses(ids)
await service.deleteCustomerAddresses(ids)
}
)

View File

@@ -13,10 +13,10 @@ export const deleteCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
const existing = await service.listAddresses({
const existing = await service.listCustomerAddresses({
id: ids,
})
await service.deleteAddresses(ids)
await service.deleteCustomerAddresses(ids)
return new StepResponse(void 0, existing)
},
@@ -29,6 +29,6 @@ export const deleteCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await service.createAddresses(prevAddresses)
await service.createCustomerAddresses(prevAddresses)
}
)

View File

@@ -55,7 +55,7 @@ export const maybeUnsetDefaultBillingAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await customerModuleService.updateAddresses(
await customerModuleService.updateCustomerAddresses(
{ id: addressesToSet },
{ is_default_billing: true }
)

View File

@@ -54,7 +54,7 @@ export const maybeUnsetDefaultShippingAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await customerModuleService.updateAddresses(
await customerModuleService.updateCustomerAddresses(
{ id: addressesToSet },
{ is_default_shipping: true }
)

View File

@@ -29,12 +29,12 @@ export const updateCustomerAddressesStep = createStep(
const { selects, relations } = getSelectsAndRelationsFromObjectArray([
data.update,
])
const prevCustomers = await service.listAddresses(data.selector, {
const prevCustomers = await service.listCustomerAddresses(data.selector, {
select: selects,
relations,
})
const customerAddresses = await service.updateAddresses(
const customerAddresses = await service.updateCustomerAddresses(
data.selector,
data.update
)
@@ -51,7 +51,9 @@ export const updateCustomerAddressesStep = createStep(
)
await promiseAll(
prevCustomerAddresses.map((c) => service.updateAddresses(c.id, { ...c }))
prevCustomerAddresses.map((c) =>
service.updateCustomerAddresses(c.id, { ...c })
)
)
}
)

View File

@@ -16,12 +16,12 @@ export const unsetForCreate = async (
return acc
}, [])
const customerDefaultAddresses = await customerService.listAddresses({
const customerDefaultAddresses = await customerService.listCustomerAddresses({
customer_id: customerIds,
[field]: true,
})
await customerService.updateAddresses(
await customerService.updateCustomerAddresses(
{ customer_id: customerIds, [field]: true },
{ [field]: false }
)

View File

@@ -1,7 +1,7 @@
import {
UpdateCustomerAddressDTO,
FilterableCustomerAddressProps,
ICustomerModuleService,
UpdateCustomerAddressDTO,
} from "@medusajs/types"
import { StepResponse } from "@medusajs/workflows-sdk"
@@ -17,18 +17,21 @@ export const unsetForUpdate = async (
return new StepResponse(void 0)
}
const affectedCustomers = await customerService.listAddresses(data.selector, {
select: ["id", "customer_id"],
})
const affectedCustomers = await customerService.listCustomerAddresses(
data.selector,
{
select: ["id", "customer_id"],
}
)
const customerIds = affectedCustomers.map((address) => address.customer_id)
const customerDefaultAddresses = await customerService.listAddresses({
const customerDefaultAddresses = await customerService.listCustomerAddresses({
customer_id: customerIds,
[field]: true,
})
await customerService.updateAddresses(
await customerService.updateCustomerAddresses(
{ customer_id: customerIds, [field]: true },
{ [field]: false }
)

View File

@@ -7,9 +7,7 @@ export class ModuleService implements IModuleService {
alias: [
{
name: ["custom_name"],
args: {
entity: "Custom",
},
entity: "Custom",
},
],
})

View File

@@ -75,15 +75,15 @@ describe("load internal - load resources", () => {
alias: [
{
name: ["dml_entity", "dml_entities"],
entity: "DmlEntity",
args: {
entity: "DmlEntity",
methodSuffix: "DmlEntities",
},
},
{
name: ["entity_model", "entity_models"],
entity: "EntityModel",
args: {
entity: "EntityModel",
methodSuffix: "EntityModels",
},
},
@@ -156,15 +156,15 @@ describe("load internal - load resources", () => {
alias: [
{
name: ["entity_model", "entity_models"],
entity: "EntityModel",
args: {
entity: "EntityModel",
methodSuffix: "EntityModels",
},
},
{
name: ["dml_entity", "dml_entities"],
entity: "DmlEntity",
args: {
entity: "DmlEntity",
methodSuffix: "DmlEntities",
},
},
@@ -237,15 +237,15 @@ describe("load internal - load resources", () => {
alias: [
{
name: ["entity2", "entity2s"],
entity: "Entity2",
args: {
entity: "Entity2",
methodSuffix: "Entity2s",
},
},
{
name: ["entity_model", "entity_models"],
entity: "EntityModel",
args: {
entity: "EntityModel",
methodSuffix: "EntityModels",
},
},
@@ -310,8 +310,8 @@ describe("load internal - load resources", () => {
alias: [
{
name: ["custom_name"],
entity: "Custom",
args: {
entity: "Custom",
methodSuffix: "Customs",
},
},

View File

@@ -206,6 +206,7 @@ export class RemoteJoiner {
for (const name of alias.name) {
service_.alias.push({
name,
entity: alias.entity,
args: alias.args,
})
}
@@ -234,16 +235,13 @@ export class RemoteJoiner {
service_.relationships?.set(alias.name as string, {
alias: alias.name as string,
entity: alias.entity,
foreignKey: alias.name + "_id",
primaryKey: "id",
serviceName: service_.serviceName!,
args,
})
this.cacheServiceConfig(
serviceConfigs,
undefined,
alias.name as string
)
this.cacheServiceConfig(serviceConfigs, undefined, alias)
}
this.cacheServiceConfig(serviceConfigs, service_.serviceName)
@@ -313,21 +311,23 @@ export class RemoteJoiner {
private cacheServiceConfig(
serviceConfigs,
serviceName?: string,
serviceAlias?: string
serviceAlias?: JoinerServiceConfigAlias
): void {
if (serviceAlias) {
const name = `alias_${serviceAlias}`
const name = `alias_${serviceAlias.name}`
if (!this.serviceConfigCache.has(name)) {
let aliasConfig: JoinerServiceConfigAlias | undefined
const config = serviceConfigs.find((conf) => {
const aliases = conf.alias as JoinerServiceConfigAlias[]
const hasArgs = aliases?.find((alias) => alias.name === serviceAlias)
const hasArgs = aliases?.find(
(alias) => alias.name === serviceAlias.name
)
aliasConfig = hasArgs
return hasArgs
})
if (config) {
const serviceConfig = { ...config }
const serviceConfig = { ...config, entity: serviceAlias.entity }
if (aliasConfig) {
serviceConfig.args = { ...config?.args, ...aliasConfig?.args }
}
@@ -450,7 +450,7 @@ export class RemoteJoiner {
if (notFound.size > 0) {
const entityName =
expand.serviceConfig.args?.entity ??
expand.serviceConfig.entity ??
expand.serviceConfig.args?.methodSuffix ??
expand.serviceConfig.serviceName

View File

@@ -491,7 +491,7 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<CustomerAddressDTO[]>} The list of created addresses.
*
* @example
* const addresses = await customerModuleService.createAddresses([
* const addresses = await customerModuleService.createCustomerAddresses([
* {
* customer_id: "cus_123",
* address_name: "Home",
@@ -501,7 +501,7 @@ export interface ICustomerModuleService extends IModuleService {
* },
* ])
*/
createAddresses(
createCustomerAddresses(
addresses: CreateCustomerAddressDTO[],
sharedContext?: Context
): Promise<CustomerAddressDTO[]>
@@ -514,7 +514,7 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<CustomerAddressDTO>} The created address.
*
* @example
* const address = await customerModuleService.createAddresses({
* const address = await customerModuleService.createCustomerAddresses({
* customer_id: "cus_123",
* address_name: "Home",
* address_1: "432 Stierlin Rd",
@@ -522,7 +522,7 @@ export interface ICustomerModuleService extends IModuleService {
* country_code: "us",
* })
*/
createAddresses(
createCustomerAddresses(
address: CreateCustomerAddressDTO,
sharedContext?: Context
): Promise<CustomerAddressDTO>
@@ -536,7 +536,7 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<CustomerAddressDTO>} The updated address.
*
* @example
* const address = await customerModuleService.updateAddresses(
* const address = await customerModuleService.updateCustomerAddresses(
* "cuaddr_123",
* {
* first_name: "John",
@@ -544,7 +544,7 @@ export interface ICustomerModuleService extends IModuleService {
* }
* )
*/
updateAddresses(
updateCustomerAddresses(
addressId: string,
data: UpdateCustomerAddressDTO,
sharedContext?: Context
@@ -559,7 +559,7 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<CustomerAddressDTO[]>} The updated addresses.
*
* @example
* const addresses = await customerModuleService.updateAddresses(
* const addresses = await customerModuleService.updateCustomerAddresses(
* ["cuaddr_123", "cuaddr_321"],
* {
* first_name: "John",
@@ -567,7 +567,7 @@ export interface ICustomerModuleService extends IModuleService {
* }
* )
*/
updateAddresses(
updateCustomerAddresses(
addressIds: string[],
data: UpdateCustomerAddressDTO,
sharedContext?: Context
@@ -582,14 +582,14 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<CustomerAddressDTO[]>} The updated addresses.
*
* @example
* const addresses = await customerModuleService.updateAddresses(
* const addresses = await customerModuleService.updateCustomerAddresses(
* { first_name: "John" },
* {
* last_name: "Smith",
* }
* )
*/
updateAddresses(
updateCustomerAddresses(
selector: FilterableCustomerAddressProps,
data: UpdateCustomerAddressDTO,
sharedContext?: Context
@@ -603,9 +603,12 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<void>} Resolves when the address is deleted successfully.
*
* @example
* await customerModuleService.deleteAddresses("cuaddr_123")
* await customerModuleService.deleteCustomerAddresses("cuaddr_123")
*/
deleteAddresses(addressId: string, sharedContext?: Context): Promise<void>
deleteCustomerAddresses(
addressId: string,
sharedContext?: Context
): Promise<void>
/**
* This method deletes addresses by their IDs.
@@ -615,12 +618,15 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<void>} Resolves when the addresses are deleted successfully.
*
* @example
* await customerModuleService.deleteAddresses([
* await customerModuleService.deleteCustomerAddresses([
* "cuaddr_123",
* "cuaddr_321",
* ])
*/
deleteAddresses(addressIds: string[], sharedContext?: Context): Promise<void>
deleteCustomerAddresses(
addressIds: string[],
sharedContext?: Context
): Promise<void>
/**
* This method deletes addresses matching the specified filters.
@@ -630,12 +636,12 @@ export interface ICustomerModuleService extends IModuleService {
* @returns {Promise<void>} Resolves when the addresses are deleted successfully.
*
* @example
* await customerModuleService.deleteAddresses({
* await customerModuleService.deleteCustomerAddresses({
* first_name: "John",
* last_name: "Smith",
* })
*/
deleteAddresses(
deleteCustomerAddresses(
selector: FilterableCustomerAddressProps,
sharedContext?: Context
): Promise<void>
@@ -653,7 +659,7 @@ export interface ICustomerModuleService extends IModuleService {
* To retrieve a list of addresses using their IDs:
*
* ```ts
* const addresses = await customerModuleService.listAddresses({
* const addresses = await customerModuleService.listCustomerAddresses({
* id: ["cuaddr_123", "cuaddr_321"],
* })
* ```
@@ -661,7 +667,7 @@ export interface ICustomerModuleService extends IModuleService {
* To specify relations that should be retrieved within the addresses:
*
* ```ts
* const addresses = await customerModuleService.listAddresses(
* const addresses = await customerModuleService.listCustomerAddresses(
* {
* id: ["cuaddr_123", "cuaddr_321"],
* },
@@ -674,7 +680,7 @@ export interface ICustomerModuleService extends IModuleService {
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const addresses = await customerModuleService.listAddresses(
* const addresses = await customerModuleService.listCustomerAddresses(
* {
* id: ["cuaddr_123", "cuaddr_321"],
* },
@@ -686,7 +692,7 @@ export interface ICustomerModuleService extends IModuleService {
* )
* ```
*/
listAddresses(
listCustomerAddresses(
filters?: FilterableCustomerAddressProps,
config?: FindConfig<CustomerAddressDTO>,
sharedContext?: Context
@@ -706,7 +712,7 @@ export interface ICustomerModuleService extends IModuleService {
*
* ```ts
* const [addresses, count] =
* await customerModuleService.listAndCountAddresses({
* await customerModuleService.listAndCountCustomerAddresses({
* id: ["cuaddr_123", "cuaddr_321"],
* })
* ```
@@ -715,7 +721,7 @@ export interface ICustomerModuleService extends IModuleService {
*
* ```ts
* const [addresses, count] =
* await customerModuleService.listAndCountAddresses(
* await customerModuleService.listAndCountCustomerAddresses(
* {
* id: ["cuaddr_123", "cuaddr_321"],
* },
@@ -729,7 +735,7 @@ export interface ICustomerModuleService extends IModuleService {
*
* ```ts
* const [addresses, count] =
* await customerModuleService.listAndCountAddresses(
* await customerModuleService.listAndCountCustomerAddresses(
* {
* id: ["cuaddr_123", "cuaddr_321"],
* },
@@ -741,7 +747,7 @@ export interface ICustomerModuleService extends IModuleService {
* )
* ```
*/
listAndCountAddresses(
listAndCountCustomerAddresses(
filters?: FilterableCustomerAddressProps,
config?: FindConfig<CustomerAddressDTO>,
sharedContext?: Context

View File

@@ -3,6 +3,7 @@ export type JoinerRelationship = {
foreignKey: string
primaryKey: string
serviceName: string
entity?: string
/**
* In an inverted relationship the foreign key is on the other service and the primary key is on the current service
*/
@@ -19,6 +20,7 @@ export type JoinerRelationship = {
export interface JoinerServiceConfigAlias {
name: string | string[]
entity?: string
/**
* Extra arguments to pass to the remoteFetchData callback
*/
@@ -96,6 +98,7 @@ export type InternalJoinerServiceConfig = Omit<
"relationships"
> & {
relationships?: Map<string, JoinerRelationship>
entity?: string
}
export interface RemoteExpandProperty {

View File

@@ -61,57 +61,57 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["fulfillment_set", "fulfillment_sets"],
entity: FulfillmentSet.name,
args: {
entity: FulfillmentSet.name,
methodSuffix: "FulfillmentSets",
},
},
{
name: ["shipping_option", "shipping_options"],
entity: ShippingOption.name,
args: {
entity: ShippingOption.name,
methodSuffix: "ShippingOptions",
},
},
{
name: ["shipping_profile", "shipping_profiles"],
entity: ShippingProfile.name,
args: {
entity: ShippingProfile.name,
methodSuffix: "ShippingProfiles",
},
},
{
name: ["fulfillment", "fulfillments"],
entity: Fulfillment.name,
args: {
entity: Fulfillment.name,
methodSuffix: "Fulfillments",
},
},
{
name: ["fulfillment_provider", "fulfillment_providers"],
entity: FulfillmentProvider.name,
args: {
entity: FulfillmentProvider.name,
methodSuffix: "FulfillmentProviders",
},
},
{
name: ["service_zone", "service_zones"],
entity: ServiceZone.name,
args: {
entity: ServiceZone.name,
methodSuffix: "ServiceZones",
},
},
{
name: ["geo_zone", "geo_zones"],
entity: GeoZone.name,
args: {
entity: GeoZone.name,
methodSuffix: "GeoZones",
},
},
{
name: ["shipping_option_rule", "shipping_option_rules"],
entity: ShippingOptionRule.name,
args: {
entity: ShippingOptionRule.name,
methodSuffix: "ShippingOptionRules",
},
},
@@ -124,8 +124,8 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["custom", "customs"],
entity: "Custom",
args: {
entity: "Custom",
methodSuffix: "Customs",
},
},
@@ -140,8 +140,8 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["custom", "customs"],
entity: "Custom",
args: {
entity: "Custom",
methodSuffix: "Customs",
},
},
@@ -164,8 +164,8 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["custom", "customs"],
entity: "Custom",
args: {
entity: "Custom",
methodSuffix: "Customs",
},
},
@@ -189,64 +189,64 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["custom", "customs"],
entity: "Custom",
args: {
entity: "Custom",
methodSuffix: "Customs",
},
},
{
name: ["fulfillment_set", "fulfillment_sets"],
entity: FulfillmentSet.name,
args: {
entity: FulfillmentSet.name,
methodSuffix: "FulfillmentSets",
},
},
{
name: ["shipping_option", "shipping_options"],
entity: ShippingOption.name,
args: {
entity: ShippingOption.name,
methodSuffix: "ShippingOptions",
},
},
{
name: ["shipping_profile", "shipping_profiles"],
entity: ShippingProfile.name,
args: {
entity: ShippingProfile.name,
methodSuffix: "ShippingProfiles",
},
},
{
name: ["fulfillment", "fulfillments"],
entity: Fulfillment.name,
args: {
entity: Fulfillment.name,
methodSuffix: "Fulfillments",
},
},
{
name: ["fulfillment_provider", "fulfillment_providers"],
entity: FulfillmentProvider.name,
args: {
entity: FulfillmentProvider.name,
methodSuffix: "FulfillmentProviders",
},
},
{
name: ["service_zone", "service_zones"],
entity: ServiceZone.name,
args: {
entity: ServiceZone.name,
methodSuffix: "ServiceZones",
},
},
{
name: ["geo_zone", "geo_zones"],
entity: GeoZone.name,
args: {
entity: GeoZone.name,
methodSuffix: "GeoZones",
},
},
{
name: ["shipping_option_rule", "shipping_option_rules"],
entity: ShippingOptionRule.name,
args: {
entity: ShippingOptionRule.name,
methodSuffix: "ShippingOptionRules",
},
},
@@ -259,9 +259,8 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["custom", "customs"],
args: {
entity: "Custom",
},
entity: "Custom",
args: {},
},
],
})
@@ -274,8 +273,8 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["custom", "customs"],
entity: "Custom",
args: {
entity: "Custom",
methodSuffix: "Customs",
},
},
@@ -283,14 +282,14 @@ describe("joiner-config-builder", () => {
})
})
it("should return a full joiner configuration with custom aliases overriding defaults", () => {
it.only("should return a full joiner configuration with custom aliases overriding defaults", () => {
const joinerConfig = defineJoinerConfig(Modules.FULFILLMENT, {
models: [FulfillmentSet],
alias: [
{
name: ["fulfillment_set", "fulfillment_sets"],
entity: "FulfillmentSet",
args: {
entity: "FulfillmentSet",
methodSuffix: "fulfillmentSetCustom",
},
},
@@ -307,8 +306,8 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["fulfillment_set", "fulfillment_sets"],
entity: "FulfillmentSet",
args: {
entity: "FulfillmentSet",
methodSuffix: "fulfillmentSetCustom",
},
},
@@ -349,57 +348,57 @@ describe("joiner-config-builder", () => {
alias: [
{
name: ["fulfillment_set", "fulfillment_sets"],
entity: FulfillmentSet.name,
args: {
entity: FulfillmentSet.name,
methodSuffix: "FulfillmentSets",
},
},
{
name: ["shipping_option", "shipping_options"],
entity: ShippingOption.name,
args: {
entity: ShippingOption.name,
methodSuffix: "ShippingOptions",
},
},
{
name: ["shipping_profile", "shipping_profiles"],
entity: ShippingProfile.name,
args: {
entity: ShippingProfile.name,
methodSuffix: "ShippingProfiles",
},
},
{
name: ["fulfillment", "fulfillments"],
entity: Fulfillment.name,
args: {
entity: Fulfillment.name,
methodSuffix: "Fulfillments",
},
},
{
name: ["fulfillment_provider", "fulfillment_providers"],
entity: FulfillmentProvider.name,
args: {
entity: FulfillmentProvider.name,
methodSuffix: "FulfillmentProviders",
},
},
{
name: ["service_zone", "service_zones"],
entity: ServiceZone.name,
args: {
entity: ServiceZone.name,
methodSuffix: "ServiceZones",
},
},
{
name: ["geo_zone", "geo_zones"],
entity: GeoZone.name,
args: {
entity: GeoZone.name,
methodSuffix: "GeoZones",
},
},
{
name: ["shipping_option_rule", "shipping_option_rules"],
entity: ShippingOptionRule.name,
args: {
entity: ShippingOptionRule.name,
methodSuffix: "ShippingOptionRules",
},
},
@@ -518,6 +517,7 @@ describe("joiner-config-builder", () => {
car: {
id: {
field: "car",
entity: "Car",
linkable: "car_id",
primaryKey: "id",
serviceName: "myService",
@@ -527,6 +527,7 @@ describe("joiner-config-builder", () => {
user: {
id: {
field: "user",
entity: "User",
linkable: "user_id",
primaryKey: "id",
serviceName: "myService",
@@ -537,12 +538,14 @@ describe("joiner-config-builder", () => {
expect(linkConfig.car.toJSON()).toEqual({
field: "car",
entity: "Car",
linkable: "car_id",
primaryKey: "id",
serviceName: "myService",
})
expect(linkConfig.user.toJSON()).toEqual({
field: "user",
entity: "User",
linkable: "user_id",
primaryKey: "id",
serviceName: "myService",
@@ -559,6 +562,7 @@ describe("joiner-config-builder", () => {
user: {
id: {
field: "user",
entity: "User",
linkable: "user_id",
primaryKey: "id",
serviceName: "myService",
@@ -568,6 +572,7 @@ describe("joiner-config-builder", () => {
currency: {
code: {
field: "currency",
entity: "Currency",
linkable: "currency_code",
primaryKey: "code",
serviceName: "myService",
@@ -578,12 +583,14 @@ describe("joiner-config-builder", () => {
expect(linkConfig.user.toJSON()).toEqual({
field: "user",
entity: "User",
linkable: "user_id",
primaryKey: "id",
serviceName: "myService",
})
expect(linkConfig.currency.toJSON()).toEqual({
field: "currency",
entity: "Currency",
linkable: "currency_code",
primaryKey: "code",
serviceName: "myService",
@@ -645,12 +652,14 @@ describe("joiner-config-builder", () => {
expect(linkConfig.user.id).toEqual({
serviceName: "myService",
field: "user",
entity: "User",
linkable: "user_id",
primaryKey: "id",
})
expect(linkConfig.car.number_plate).toEqual({
serviceName: "myService",
field: "car",
entity: "Car",
linkable: "car_number_plate",
primaryKey: "number_plate",
})
@@ -658,12 +667,14 @@ describe("joiner-config-builder", () => {
expect(linkConfig.car.toJSON()).toEqual({
serviceName: "myService",
field: "car",
entity: "Car",
linkable: "car_number_plate",
primaryKey: "number_plate",
})
expect(linkConfig.user.toJSON()).toEqual({
serviceName: "myService",
field: "user",
entity: "User",
linkable: "user_id",
primaryKey: "id",
})

View File

@@ -13,6 +13,8 @@ export interface DefineLinkExport {
type InputSource = {
serviceName: string
field: string
entity?: string
alias?: string
linkable: string
primaryKey: string
}
@@ -44,7 +46,9 @@ type DefineLinkInputSource = InputSource | InputOptions | CombinedSource
type ModuleLinkableKeyConfig = {
module: string
entity?: string
key: string
field: string
isList?: boolean
deleteCascade?: boolean
primaryKey: string
@@ -74,11 +78,13 @@ function prepareServiceConfig(input: DefineLinkInputSource) {
serviceConfig = {
key: source.linkable,
alias: camelToSnakeCase(source.field),
alias: source.alias ?? camelToSnakeCase(source.field),
field: source.field,
primaryKey: source.primaryKey,
isList: false,
deleteCascade: false,
module: source.serviceName,
entity: source.entity,
}
} else if (isInputOptions(input)) {
const source = isToJSON(input.linkable)
@@ -87,11 +93,13 @@ function prepareServiceConfig(input: DefineLinkInputSource) {
serviceConfig = {
key: source.linkable,
alias: camelToSnakeCase(source.field),
alias: source.alias ?? camelToSnakeCase(source.field),
field: source.field,
primaryKey: source.primaryKey,
isList: input.isList ?? false,
deleteCascade: input.deleteCascade ?? false,
module: source.serviceName,
entity: source.entity,
}
} else {
throw new Error(
@@ -176,7 +184,7 @@ ${serviceBObj.module}: {
let aliasAOptions =
serviceAObj.alias ??
serviceAAliases.find((a) => {
return a.args?.entity == serviceAKeyEntity
return a.entity == serviceAKeyEntity
})?.name
let aliasA = aliasAOptions
@@ -190,10 +198,11 @@ ${serviceBObj.module}: {
)
}
const serviceAObjEntryPoint = camelToSnakeCase(serviceAObj.field)
const serviceAMethodSuffix = serviceAAliases.find((serviceAlias) => {
return Array.isArray(serviceAlias.name)
? serviceAlias.name.includes(aliasA)
: serviceAlias.name === aliasA
? serviceAlias.name.includes(serviceAObjEntryPoint)
: serviceAlias.name === serviceAObjEntryPoint
})?.args?.methodSuffix
let serviceBAliases = serviceBInfo.alias ?? []
@@ -204,7 +213,7 @@ ${serviceBObj.module}: {
let aliasBOptions =
serviceBObj.alias ??
serviceBAliases.find((a) => {
return a.args?.entity == serviceBKeyInfo
return a.entity == serviceBKeyInfo
})?.name
let aliasB = aliasBOptions
@@ -218,10 +227,11 @@ ${serviceBObj.module}: {
)
}
const serviceBObjEntryPoint = camelToSnakeCase(serviceBObj.field)
const serviceBMethodSuffix = serviceBAliases.find((serviceAlias) => {
return Array.isArray(serviceAlias.name)
? serviceAlias.name.includes(aliasB)
: serviceAlias.name === aliasB
? serviceAlias.name.includes(serviceBObjEntryPoint)
: serviceAlias.name === serviceBObjEntryPoint
})?.args?.methodSuffix
const moduleAPrimaryKeys = serviceAInfo.primaryKeys ?? []
@@ -290,6 +300,7 @@ ${serviceBObj.module}: {
relationships: [
{
serviceName: serviceAObj.module,
entity: serviceAObj.entity,
primaryKey: serviceAPrimaryKey,
foreignKey: serviceAObj.key,
alias: aliasA,
@@ -300,6 +311,7 @@ ${serviceBObj.module}: {
},
{
serviceName: serviceBObj.module,
entity: serviceBObj.entity,
primaryKey: serviceBPrimaryKey!,
foreignKey: serviceBObj.key,
alias: aliasB,
@@ -316,6 +328,7 @@ ${serviceBObj.module}: {
[serviceBObj.isList ? pluralize(aliasB) : aliasB]: {
path: aliasB + "_link." + aliasB,
isList: serviceBObj.isList,
forwardArgumentsOnPath: [aliasB + "_link." + aliasB],
},
},
relationship: {
@@ -332,6 +345,7 @@ ${serviceBObj.module}: {
[serviceAObj.isList ? pluralize(aliasA) : aliasA]: {
path: aliasA + "_link." + aliasA,
isList: serviceAObj.isList,
forwardArgumentsOnPath: [aliasA + "_link." + aliasA],
},
},
relationship: {

View File

@@ -193,17 +193,17 @@ export function defineJoinerConfig(
alias: [
...[...(alias ?? ([] as any))].map((alias) => ({
name: alias.name,
entity: alias.entity,
args: {
entity: alias.args.entity,
methodSuffix:
alias.args.methodSuffix ??
pluralize(upperCaseFirst(alias.args.entity)),
alias.args?.methodSuffix ?? pluralize(upperCaseFirst(alias.entity)),
},
})),
...deduplicatedLoadedModels
.filter((model) => {
return (
!alias || !alias.some((alias) => alias.args?.entity === model.name)
!alias ||
!alias.some((alias) => alias.entity === upperCaseFirst(model.name))
)
})
.map((entity, i) => ({
@@ -211,8 +211,8 @@ export function defineJoinerConfig(
`${camelToSnakeCase(entity.name).toLowerCase()}`,
`${pluralize(camelToSnakeCase(entity.name).toLowerCase())}`,
],
entity: upperCaseFirst(entity.name),
args: {
entity: upperCaseFirst(entity.name),
methodSuffix: pluralize(upperCaseFirst(entity.name)),
},
})),
@@ -378,6 +378,7 @@ export function buildLinkConfigFromModelObjects<
primaryKey: property,
serviceName,
field: lowerCaseFirst(model.name),
entity: upperCaseFirst(model.name),
}
}
}
@@ -412,6 +413,7 @@ export function buildLinkConfigFromLinkableKeys<
primaryKey: inferredReferenceProperty,
serviceName,
field: keyName,
entity: upperCaseFirst(modelName),
}
linkConfig[keyName] ??= {

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -24,6 +24,7 @@ moduleIntegrationTestRunner<ICurrencyModuleService>({
currency: {
code: {
linkable: "currency_code",
entity: "Currency",
primaryKey: "code",
serviceName: "currency",
field: "currency",

View File

@@ -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,
})

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)

View File

@@ -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" })

View File

@@ -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(),

View File

@@ -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"

View File

@@ -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
)

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",
},
},

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",
},
},

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -9,6 +9,7 @@ export const LineItemAdjustmentPromotion: ModuleJoinerConfig = {
serviceName: Modules.CART,
relationship: {
serviceName: Modules.PROMOTION,
entity: "Promotion",
primaryKey: "id",
foreignKey: "promotion_id",
alias: "promotion",

View File

@@ -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",

View File

@@ -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",
},
},
},

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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(

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",
},
},
],

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -83,6 +83,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
workflowExecution: {
id: {
linkable: "workflow_execution_id",
entity: "WorkflowExecution",
primaryKey: "id",
serviceName: "workflows",
field: "workflowExecution",