chore: remove container registration name (#9137)

This commit is contained in:
Carlos R. L. Rodrigues
2024-09-16 06:22:24 -03:00
committed by GitHub
parent ab4a422fc8
commit 950cf9af79
421 changed files with 1528 additions and 2496 deletions
@@ -56,7 +56,7 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
linkable: "api_key_id",
entity: "ApiKey",
primaryKey: "id",
serviceName: "apiKey",
serviceName: "ApiKey",
field: "apiKey",
},
publishable_key_id: {
@@ -64,7 +64,7 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
entity: "ApiKey",
linkable: "publishable_key_id",
primaryKey: "publishable_key_id",
serviceName: "apiKey",
serviceName: "ApiKey",
},
})
})
+8 -3
View File
@@ -1,9 +1,14 @@
import { ApiKeyType, RevokeApiKeyDTO, UpdateApiKeyDTO } from "@medusajs/types"
import { IEventBusModuleService, Logger } from "@medusajs/types"
import {
ApiKeyType,
IEventBusModuleService,
Logger,
RevokeApiKeyDTO,
UpdateApiKeyDTO,
} from "@medusajs/types"
export type InitializeModuleInjectableDependencies = {
logger?: Logger
eventBusModuleService?: IEventBusModuleService
EventBus?: IEventBusModuleService
}
export type CreateApiKeyDTO = {
@@ -54,7 +54,7 @@ moduleIntegrationTestRunner({
linkable: "auth_identity_id",
entity: "AuthIdentity",
primaryKey: "id",
serviceName: "auth",
serviceName: "Auth",
field: "authIdentity",
},
})
@@ -66,7 +66,7 @@ moduleIntegrationTestRunner({
linkable: "provider_identity_id",
entity: "ProviderIdentity",
primaryKey: "id",
serviceName: "auth",
serviceName: "Auth",
field: "providerIdentity",
},
})
@@ -36,7 +36,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "cart_id",
entity: "Cart",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "cart",
},
},
@@ -45,7 +45,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "address_id",
entity: "Address",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "address",
},
},
@@ -54,7 +54,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "line_item_id",
entity: "LineItem",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "lineItem",
},
},
@@ -63,7 +63,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "line_item_adjustment_id",
entity: "LineItemAdjustment",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "lineItemAdjustment",
},
},
@@ -72,7 +72,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "line_item_tax_line_id",
entity: "LineItemTaxLine",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "lineItemTaxLine",
},
},
@@ -81,7 +81,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "shipping_method_id",
entity: "ShippingMethod",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "shippingMethod",
},
},
@@ -90,7 +90,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "shipping_method_adjustment_id",
entity: "ShippingMethodAdjustment",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "shippingMethodAdjustment",
},
},
@@ -99,7 +99,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "shipping_method_tax_line_id",
entity: "ShippingMethodTaxLine",
primaryKey: "id",
serviceName: "cart",
serviceName: "Cart",
field: "shippingMethodTaxLine",
},
},
@@ -1,7 +1,7 @@
import { ICurrencyModuleService } from "@medusajs/types"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
import { Module, Modules } from "@medusajs/utils"
import { CurrencyModuleService } from "@services"
import { moduleIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(100000)
@@ -26,7 +26,7 @@ moduleIntegrationTestRunner<ICurrencyModuleService>({
linkable: "currency_code",
entity: "Currency",
primaryKey: "code",
serviceName: "currency",
serviceName: "Currency",
field: "currency",
},
},
@@ -1,9 +1,5 @@
import { LoaderOptions, Logger, ModulesSdkTypes } from "@medusajs/types"
import {
ContainerRegistrationKeys,
ModuleRegistrationName,
defaultCurrencies,
} from "@medusajs/utils"
import { ContainerRegistrationKeys, defaultCurrencies } from "@medusajs/utils"
import { Currency } from "@models"
export default async ({
@@ -18,7 +14,7 @@ export default async ({
container.resolve<Logger>(ContainerRegistrationKeys.LOGGER) ?? console
const { currencyService_ } = container.resolve<{
currencyService_: ModulesSdkTypes.IMedusaInternalService<typeof Currency>
}>(ModuleRegistrationName.CURRENCY)
}>("currencyModuleService")
try {
const normalizedCurrencies = Object.values(defaultCurrencies).map((c) => ({
+1 -1
View File
@@ -2,5 +2,5 @@ import { IEventBusModuleService, Logger } from "@medusajs/types"
export type InitializeModuleInjectableDependencies = {
logger?: Logger
eventBusModuleService?: IEventBusModuleService
EventBus?: IEventBusModuleService
}
@@ -31,7 +31,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_address_id",
entity: "CustomerAddress",
primaryKey: "id",
serviceName: "customer",
serviceName: "Customer",
field: "customerAddress",
},
},
@@ -40,7 +40,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_group_customer_id",
entity: "CustomerGroupCustomer",
primaryKey: "id",
serviceName: "customer",
serviceName: "Customer",
field: "customerGroupCustomer",
},
},
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_group_id",
entity: "CustomerGroup",
primaryKey: "id",
serviceName: "customer",
serviceName: "Customer",
field: "customerGroup",
},
},
@@ -58,7 +58,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_id",
entity: "Customer",
primaryKey: "id",
serviceName: "customer",
serviceName: "Customer",
field: "customer",
},
},
@@ -13,7 +13,7 @@ export function buildExpectedEventMessageShape(options: {
metadata: {
action: options.action,
eventGroupId: options.eventGroupId,
source: "fulfillment",
source: "Fulfillment",
object: options.object,
},
data: options.data,
@@ -133,7 +133,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_address_id",
entity: "FulfillmentAddress",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "fulfillmentAddress",
},
},
@@ -142,7 +142,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_item_id",
entity: "FulfillmentItem",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "fulfillmentItem",
},
},
@@ -151,7 +151,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_label_id",
entity: "FulfillmentLabel",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "fulfillmentLabel",
},
},
@@ -160,7 +160,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_provider_id",
entity: "FulfillmentProvider",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "fulfillmentProvider",
},
},
@@ -169,7 +169,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_set_id",
entity: "FulfillmentSet",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "fulfillmentSet",
},
},
@@ -178,7 +178,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_id",
entity: "Fulfillment",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "fulfillment",
},
},
@@ -187,7 +187,7 @@ moduleIntegrationTestRunner({
linkable: "geo_zone_id",
entity: "GeoZone",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "geoZone",
},
},
@@ -196,7 +196,7 @@ moduleIntegrationTestRunner({
linkable: "service_zone_id",
entity: "ServiceZone",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "serviceZone",
},
},
@@ -205,7 +205,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_option_rule_id",
entity: "ShippingOptionRule",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "shippingOptionRule",
},
},
@@ -214,7 +214,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_option_type_id",
entity: "ShippingOptionType",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "shippingOptionType",
},
},
@@ -223,7 +223,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_option_id",
entity: "ShippingOption",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "shippingOption",
},
},
@@ -232,7 +232,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_profile_id",
entity: "ShippingProfile",
primaryKey: "id",
serviceName: "fulfillment",
serviceName: "Fulfillment",
field: "shippingProfile",
},
},
@@ -7,7 +7,7 @@ import {
export type InitializeModuleInjectableDependencies = {
logger?: Logger
eventBusModuleService?: IEventBusModuleService
EventBus?: IEventBusModuleService
}
export const FulfillmentIdentifiersRegistrationName =
@@ -31,7 +31,7 @@ moduleIntegrationTestRunner<IInventoryService>({
entity: "InventoryItem",
linkable: "inventory_item_id",
primaryKey: "id",
serviceName: "inventoryService",
serviceName: "Inventory",
},
},
inventoryLevel: {
@@ -40,7 +40,7 @@ moduleIntegrationTestRunner<IInventoryService>({
entity: "InventoryLevel",
linkable: "inventory_level_id",
primaryKey: "id",
serviceName: "inventoryService",
serviceName: "Inventory",
},
},
reservationItem: {
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner<IInventoryService>({
entity: "ReservationItem",
linkable: "reservation_item_id",
primaryKey: "id",
serviceName: "inventoryService",
serviceName: "Inventory",
},
},
})
+2 -3
View File
@@ -1,6 +1,5 @@
export * from "./initialize"
export * from "./migration"
export * from "./types"
export * from "./loaders"
export * from "./migration"
export * from "./services"
export * from "./utils/compose-link-name"
export * from "./types"
@@ -15,20 +15,17 @@ import {
} from "@medusajs/types"
import {
arrayDifference,
composeLinkName,
composeTableName,
ContainerRegistrationKeys,
lowerCaseFirst,
ModuleRegistrationName,
Modules,
simpleHash,
toPascalCase,
} from "@medusajs/utils"
import * as linkDefinitions from "../definitions"
import { MigrationsExecutionPlanner } from "../migration"
import { InitializeModuleInjectableDependencies } from "../types"
import {
composeLinkName,
composeTableName,
generateGraphQLSchema,
} from "../utils"
import { generateGraphQLSchema } from "../utils"
import { getLinkModuleDefinition } from "./module-definition"
export const initialize = async (
@@ -86,14 +83,12 @@ export const initialize = async (
}
const serviceKey = !definition.isReadOnlyLink
? lowerCaseFirst(
definition.serviceName ??
composeLinkName(
primary.serviceName,
primary.foreignKey,
foreign.serviceName,
foreign.foreignKey
)
? definition.serviceName ??
composeLinkName(
primary.serviceName,
primary.foreignKey,
foreign.serviceName,
foreign.foreignKey
)
: simpleHash(JSON.stringify(definition.extends))
@@ -159,9 +154,8 @@ export const initialize = async (
const linkModuleDefinition: LinkModuleDefinition = {
key: serviceKey,
registrationName: serviceKey,
label: serviceKey,
dependencies: [ModuleRegistrationName.EVENT_BUS],
dependencies: [Modules.EVENT_BUS],
defaultModuleDeclaration: {
scope: MODULE_SCOPE.INTERNAL,
resources: injectedDependencies?.[
@@ -218,15 +212,14 @@ export function getMigrationPlanner(
}
const [primary, foreign] = definition.relationships ?? []
const serviceKey = lowerCaseFirst(
const serviceKey =
definition.serviceName ??
composeLinkName(
primary.serviceName,
primary.foreignKey,
foreign.serviceName,
foreign.foreignKey
)
)
composeLinkName(
primary.serviceName,
primary.foreignKey,
foreign.serviceName,
foreign.foreignKey
)
if (allLinks.has(serviceKey)) {
throw new Error(`Link module ${serviceKey} already exists.`)
@@ -7,10 +7,13 @@ import {
ModuleJoinerConfig,
ModulesSdkTypes,
} from "@medusajs/types"
import { lowerCaseFirst, simpleHash, toPascalCase } from "@medusajs/utils"
import {
composeLinkName,
composeTableName,
simpleHash,
toPascalCase,
} from "@medusajs/utils"
import { asClass, asValue } from "awilix"
import { composeLinkName, composeTableName } from "../utils"
export function containerLoader(entity, joinerConfig: ModuleJoinerConfig) {
return async (
{
@@ -25,14 +28,12 @@ export function containerLoader(entity, joinerConfig: ModuleJoinerConfig) {
const [primary, foreign] = joinerConfig.relationships!
const serviceName = !joinerConfig.isReadOnlyLink
? lowerCaseFirst(
joinerConfig.serviceName ??
composeLinkName(
primary.serviceName,
primary.foreignKey,
foreign.serviceName,
foreign.foreignKey
)
? joinerConfig.serviceName ??
composeLinkName(
primary.serviceName,
primary.foreignKey,
foreign.serviceName,
foreign.foreignKey
)
: simpleHash(JSON.stringify(joinerConfig.extends))
@@ -13,12 +13,13 @@ import {
CommonEvents,
InjectManager,
InjectTransactionManager,
isDefined,
mapObjectTo,
MapToConfig,
MedusaContext,
MedusaError,
Modules,
ModulesSdkUtils,
isDefined,
mapObjectTo,
} from "@medusajs/utils"
import { LinkService } from "@services"
import { shouldForceTransaction } from "../utils"
@@ -26,12 +27,12 @@ import { shouldForceTransaction } from "../utils"
type InjectedDependencies = {
baseRepository: DAL.RepositoryService
linkService: LinkService<any>
eventBusModuleService?: IEventBusModuleService
primaryKey: string | string[]
foreignKey: string
extraFields: string[]
entityName: string
serviceName: string
[Modules.EVENT_BUS]?: IEventBusModuleService
}
export default class LinkModuleService<TLink> implements ILinkModule {
@@ -48,12 +49,12 @@ export default class LinkModuleService<TLink> implements ILinkModule {
{
baseRepository,
linkService,
eventBusModuleService,
primaryKey,
foreignKey,
extraFields,
entityName,
serviceName,
[Modules.EVENT_BUS]: eventBusModuleService,
}: InjectedDependencies,
readonly moduleDeclaration: InternalModuleDeclaration
) {
@@ -1,9 +0,0 @@
import { lowerCaseFirst, toPascalCase } from "@medusajs/utils"
export const composeLinkName = (...args) => {
return lowerCaseFirst(toPascalCase(composeTableName(...args.concat("link"))))
}
export const composeTableName = (...args) => {
return args.map((name) => name.replace(/(_id|Service)$/gi, "")).join("_")
}
@@ -1,12 +1,12 @@
import { JoinerRelationship, ModuleJoinerConfig } from "@medusajs/types"
import {
SoftDeletableFilterKey,
composeTableName,
mikroOrmSoftDeletableFilterOptions,
simpleHash,
} from "@medusajs/utils"
import { EntitySchema } from "@mikro-orm/core"
import { composeTableName } from "./compose-link-name"
function getClass(...properties) {
return class LinkModel {
@@ -2,11 +2,11 @@ import { MedusaModule } from "@medusajs/modules-sdk"
import { ModuleJoinerConfig, ModuleJoinerRelationship } from "@medusajs/types"
import {
camelToSnakeCase,
composeTableName,
isString,
lowerCaseFirst,
toPascalCase,
} from "@medusajs/utils"
import { composeTableName } from "./compose-link-name"
export function generateGraphQLSchema(
joinerConfig: ModuleJoinerConfig,
@@ -1,6 +1,5 @@
import { MODULE_RESOURCE_TYPE } from "@medusajs/modules-sdk"
export * from "./compose-link-name"
export * from "./generate-entity"
export * from "./generate-schema"
@@ -60,7 +60,7 @@ moduleIntegrationTestRunner<INotificationModuleService>({
linkable: "notification_id",
entity: "Notification",
primaryKey: "id",
serviceName: "notification",
serviceName: "Notification",
field: "notification",
},
},
@@ -35,7 +35,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_id",
entity: "Order",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "order",
},
},
@@ -44,7 +44,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_address_id",
entity: "OrderAddress",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "orderAddress",
},
},
@@ -53,7 +53,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_change_id",
entity: "OrderChange",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "orderChange",
},
},
@@ -62,14 +62,14 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_claim_id",
entity: "OrderClaim",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "orderClaim",
},
claim_id: {
linkable: "claim_id",
entity: "OrderClaim",
primaryKey: "claim_id",
serviceName: "order",
serviceName: "Order",
field: "orderClaim",
},
},
@@ -78,14 +78,14 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_exchange_id",
entity: "OrderExchange",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "orderExchange",
},
exchange_id: {
linkable: "exchange_id",
entity: "OrderExchange",
primaryKey: "exchange_id",
serviceName: "order",
serviceName: "Order",
field: "orderExchange",
},
},
@@ -94,7 +94,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_line_item_id",
entity: "OrderLineItem",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "orderLineItem",
},
},
@@ -103,7 +103,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_shipping_method_id",
entity: "OrderShippingMethod",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "orderShippingMethod",
},
},
@@ -112,7 +112,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_transaction_id",
entity: "OrderTransaction",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "orderTransaction",
},
},
@@ -121,7 +121,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "return_id",
entity: "Return",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "return",
},
},
@@ -130,7 +130,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "return_reason_id",
entity: "ReturnReason",
primaryKey: "id",
serviceName: "order",
serviceName: "Order",
field: "returnReason",
},
},
+1 -1
View File
@@ -15,5 +15,5 @@ export * from "./utils"
export type InitializeModuleInjectableDependencies = {
logger?: Logger
eventBusModuleService?: IEventBusModuleService
EventBus?: IEventBusModuleService
}
@@ -37,7 +37,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "payment_id",
entity: "Payment",
primaryKey: "id",
serviceName: "payment",
serviceName: "Payment",
field: "payment",
},
},
@@ -46,7 +46,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "payment_collection_id",
entity: "PaymentCollection",
primaryKey: "id",
serviceName: "payment",
serviceName: "Payment",
field: "paymentCollection",
},
},
@@ -55,7 +55,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "payment_provider_id",
entity: "PaymentProvider",
primaryKey: "id",
serviceName: "payment",
serviceName: "Payment",
field: "paymentProvider",
},
},
@@ -65,7 +65,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
entity: "PaymentSession",
linkable: "payment_session_id",
primaryKey: "id",
serviceName: "payment",
serviceName: "Payment",
},
},
refundReason: {
@@ -73,7 +73,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "refund_reason_id",
entity: "RefundReason",
primaryKey: "id",
serviceName: "payment",
serviceName: "Payment",
field: "refundReason",
},
},
@@ -29,7 +29,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_set_id",
entity: "PriceSet",
primaryKey: "id",
serviceName: "pricingService",
serviceName: "Pricing",
field: "priceSet",
},
},
@@ -38,7 +38,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_list_id",
entity: "PriceList",
primaryKey: "id",
serviceName: "pricingService",
serviceName: "Pricing",
field: "priceList",
},
},
@@ -47,7 +47,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_id",
entity: "Price",
primaryKey: "id",
serviceName: "pricingService",
serviceName: "Pricing",
field: "price",
},
},
@@ -56,7 +56,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_preference_id",
entity: "PricePreference",
primaryKey: "id",
serviceName: "pricingService",
serviceName: "Pricing",
field: "pricePreference",
},
},
@@ -18,7 +18,7 @@ jest.setTimeout(30000)
moduleIntegrationTestRunner<IProductModuleService>({
moduleName: Modules.PRODUCT,
injectedDependencies: {
eventBusModuleService: new MockEventBusService(),
[Modules.EVENT_BUS]: new MockEventBusService(),
},
testSuite: ({ MikroOrmWrapper, service }) => {
describe("ProductModuleService product categories", () => {
@@ -12,7 +12,7 @@ jest.setTimeout(30000)
moduleIntegrationTestRunner<IProductModuleService>({
moduleName: Modules.PRODUCT,
injectedDependencies: {
eventBusModuleService: new MockEventBusService(),
[Modules.EVENT_BUS]: new MockEventBusService(),
},
testSuite: ({ MikroOrmWrapper, service }) => {
describe("ProductModuleService product collections", () => {
@@ -3,7 +3,7 @@ import {
ProductCategoryDTO,
ProductTagDTO,
} from "@medusajs/types"
import { kebabCase, Modules, ProductStatus } from "@medusajs/utils"
import { Modules, ProductStatus, kebabCase } from "@medusajs/utils"
import {
Product,
ProductCategory,
@@ -27,7 +27,7 @@ jest.setTimeout(300000)
moduleIntegrationTestRunner<IProductModuleService>({
moduleName: Modules.PRODUCT,
injectedDependencies: {
eventBusModuleService: new MockEventBusService(),
[Modules.EVENT_BUS]: new MockEventBusService(),
},
testSuite: ({ MikroOrmWrapper, service }) => {
describe("ProductModuleService products", function () {
@@ -67,7 +67,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_id",
entity: "Product",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "product",
},
},
@@ -76,7 +76,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_variant_id",
entity: "ProductVariant",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "productVariant",
},
variant_id: {
@@ -84,7 +84,7 @@ moduleIntegrationTestRunner<Service>({
entity: "ProductVariant",
linkable: "variant_id",
primaryKey: "variant_id",
serviceName: "productService",
serviceName: "Product",
},
},
productOption: {
@@ -92,7 +92,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_option_id",
entity: "ProductOption",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "productOption",
},
},
@@ -101,7 +101,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_type_id",
entity: "ProductType",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "productType",
},
},
@@ -110,7 +110,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_image_id",
entity: "ProductImage",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "productImage",
},
},
@@ -119,7 +119,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_tag_id",
entity: "ProductTag",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "productTag",
},
},
@@ -128,7 +128,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_collection_id",
entity: "ProductCollection",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "productCollection",
},
},
@@ -137,7 +137,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_category_id",
entity: "ProductCategory",
primaryKey: "id",
serviceName: "productService",
serviceName: "Product",
field: "productCategory",
},
},
@@ -32,6 +32,7 @@ import {
MedusaContext,
MedusaError,
MedusaService,
Modules,
ProductStatus,
promiseAll,
removeUndefined,
@@ -64,7 +65,7 @@ type InjectedDependencies = {
productTypeService: ModulesSdkTypes.IMedusaInternalService<any>
productOptionService: ModulesSdkTypes.IMedusaInternalService<any>
productOptionValueService: ModulesSdkTypes.IMedusaInternalService<any>
eventBusModuleService?: IEventBusModuleService
[Modules.EVENT_BUS]?: IEventBusModuleService
}
export default class ProductModuleService
@@ -129,7 +130,7 @@ export default class ProductModuleService
productTypeService,
productOptionService,
productOptionValueService,
eventBusModuleService,
[Modules.EVENT_BUS]: eventBusModuleService,
}: InjectedDependencies,
protected readonly moduleDeclaration: InternalModuleDeclaration
) {
+1 -1
View File
@@ -2,7 +2,7 @@ import { IEventBusModuleService, Logger, ProductTypes } from "@medusajs/types"
export type InitializeModuleInjectableDependencies = {
logger?: Logger
eventBusModuleService?: IEventBusModuleService
EventBus?: IEventBusModuleService
}
// TODO: remove and cleanup bellow code
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner({
linkable: "promotion_id",
entity: "Promotion",
primaryKey: "id",
serviceName: "promotion",
serviceName: "Promotion",
field: "promotion",
},
},
@@ -58,7 +58,7 @@ moduleIntegrationTestRunner({
linkable: "campaign_id",
entity: "Campaign",
primaryKey: "id",
serviceName: "promotion",
serviceName: "Promotion",
field: "campaign",
},
},
@@ -67,7 +67,7 @@ moduleIntegrationTestRunner({
linkable: "promotion_rule_id",
entity: "PromotionRule",
primaryKey: "id",
serviceName: "promotion",
serviceName: "Promotion",
field: "promotionRule",
},
},
@@ -26,7 +26,7 @@ moduleIntegrationTestRunner<IRegionModuleService>({
linkable: "region_id",
entity: "Region",
primaryKey: "id",
serviceName: "region",
serviceName: "Region",
field: "region",
},
},
@@ -35,7 +35,7 @@ moduleIntegrationTestRunner<IRegionModuleService>({
linkable: "country_iso_2",
entity: "Country",
primaryKey: "iso_2",
serviceName: "region",
serviceName: "Region",
field: "country",
},
},
@@ -51,7 +51,7 @@ moduleIntegrationTestRunner<ISalesChannelModuleService>({
linkable: "sales_channel_id",
entity: "SalesChannel",
primaryKey: "id",
serviceName: "salesChannel",
serviceName: "SalesChannel",
field: "salesChannel",
},
},
@@ -30,7 +30,7 @@ moduleIntegrationTestRunner<IStockLocationService>({
linkable: "stock_location_address_id",
entity: "StockLocationAddress",
primaryKey: "id",
serviceName: "stockLocationService",
serviceName: "StockLocation",
field: "stockLocationAddress",
},
},
@@ -40,13 +40,13 @@ moduleIntegrationTestRunner<IStockLocationService>({
entity: "StockLocation",
linkable: "stock_location_id",
primaryKey: "id",
serviceName: "stockLocationService",
serviceName: "StockLocation",
},
location_id: {
linkable: "location_id",
entity: "StockLocation",
primaryKey: "location_id",
serviceName: "stockLocationService",
serviceName: "StockLocation",
field: "stockLocation",
},
},
@@ -18,6 +18,7 @@ import {
InjectTransactionManager,
MedusaContext,
MedusaService,
Modules,
isString,
promiseAll,
} from "@medusajs/utils"
@@ -25,7 +26,7 @@ import { joinerConfig } from "../joiner-config"
import { StockLocation, StockLocationAddress } from "../models"
type InjectedDependencies = {
eventBusModuleService: IEventBusService
[Modules.EVENT_BUS]: IEventBusService
baseRepository: DAL.RepositoryService
stockLocationService: ModulesSdkTypes.IMedusaInternalService<any>
stockLocationAddressService: ModulesSdkTypes.IMedusaInternalService<any>
@@ -48,7 +49,7 @@ export default class StockLocationModuleService
constructor(
{
eventBusModuleService,
[Modules.EVENT_BUS]: eventBusModuleService,
baseRepository,
stockLocationService,
stockLocationAddressService,
@@ -27,7 +27,7 @@ moduleIntegrationTestRunner<IStoreModuleService>({
linkable: "store_id",
entity: "Store",
primaryKey: "id",
serviceName: "store",
serviceName: "Store",
field: "store",
},
},
@@ -36,7 +36,7 @@ moduleIntegrationTestRunner<IStoreModuleService>({
linkable: "store_currency_id",
entity: "StoreCurrency",
primaryKey: "id",
serviceName: "store",
serviceName: "Store",
field: "storeCurrency",
},
},
+2 -3
View File
@@ -1,9 +1,8 @@
import { StoreTypes } from "@medusajs/types"
import { IEventBusModuleService, Logger } from "@medusajs/types"
import { IEventBusModuleService, Logger, StoreTypes } from "@medusajs/types"
export type InitializeModuleInjectableDependencies = {
logger?: Logger
eventBusModuleService?: IEventBusModuleService
EventBus?: IEventBusModuleService
}
export type UpdateStoreInput = StoreTypes.UpdateStoreDTO & { id: string }
@@ -32,7 +32,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_rate_id",
entity: "TaxRate",
primaryKey: "id",
serviceName: "tax",
serviceName: "Tax",
field: "taxRate",
},
},
@@ -41,7 +41,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_region_id",
entity: "TaxRegion",
primaryKey: "id",
serviceName: "tax",
serviceName: "Tax",
field: "taxRegion",
},
},
@@ -50,7 +50,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_rate_rule_id",
entity: "TaxRateRule",
primaryKey: "id",
serviceName: "tax",
serviceName: "Tax",
field: "taxRateRule",
},
},
@@ -59,7 +59,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_provider_id",
entity: "TaxProvider",
primaryKey: "id",
serviceName: "tax",
serviceName: "Tax",
field: "taxProvider",
},
},
@@ -31,7 +31,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
jwt_secret: "test",
},
injectedDependencies: {
eventBusModuleService: new MockEventBusService(),
[Modules.EVENT_BUS]: new MockEventBusService(),
},
testSuite: ({ service }) => {
describe("UserModuleService - Invite", () => {
@@ -25,7 +25,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
jwt_secret: "test",
},
injectedDependencies: {
eventBusModuleService: new MockEventBusService(),
[Modules.EVENT_BUS]: new MockEventBusService(),
},
testSuite: ({ service }) => {
it(`should export the appropriate linkable configuration`, () => {
@@ -45,7 +45,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
linkable: "user_id",
entity: "User",
primaryKey: "id",
serviceName: "user",
serviceName: "User",
field: "user",
},
},
@@ -54,7 +54,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
linkable: "invite_id",
entity: "Invite",
primaryKey: "id",
serviceName: "user",
serviceName: "User",
field: "invite",
},
},
@@ -1,13 +1,11 @@
import {
Context,
DAL,
IEventBusModuleService,
InternalModuleDeclaration,
ModulesSdkTypes,
UserTypes,
} from "@medusajs/types"
import {
arrayDifference,
CommonEvents,
EmitEvents,
InjectManager,
@@ -16,6 +14,7 @@ import {
MedusaError,
MedusaService,
UserEvents,
arrayDifference,
} from "@medusajs/utils"
import jwt, { JwtPayload } from "jsonwebtoken"
import crypto from "node:crypto"
@@ -26,7 +25,6 @@ type InjectedDependencies = {
baseRepository: DAL.RepositoryService
userService: ModulesSdkTypes.IMedusaInternalService<any>
inviteService: ModulesSdkTypes.IMedusaInternalService<any>
eventBusModuleService: IEventBusModuleService
}
// 1 day
@@ -53,7 +53,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
linkable: "workflow_execution_id",
entity: "WorkflowExecution",
primaryKey: "id",
serviceName: "workflows",
serviceName: "Workflows",
field: "workflowExecution",
},
},
@@ -85,7 +85,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
linkable: "workflow_execution_id",
entity: "WorkflowExecution",
primaryKey: "id",
serviceName: "workflows",
serviceName: "Workflows",
field: "workflowExecution",
},
},