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

View File

@@ -10,8 +10,8 @@ describe("defineConfig", function () {
},
"featureFlags": {},
"modules": {
"apiKey": true,
"auth": {
"ApiKey": true,
"Auth": {
"options": {
"providers": [
{
@@ -22,12 +22,12 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/auth",
},
"cacheService": true,
"cart": true,
"currency": true,
"customer": true,
"eventBus": true,
"file": {
"Cache": true,
"Cart": true,
"Currency": true,
"Customer": true,
"EventBus": true,
"File": {
"options": {
"providers": [
{
@@ -38,7 +38,7 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/file",
},
"fulfillment": {
"Fulfillment": {
"options": {
"providers": [
{
@@ -49,8 +49,8 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/fulfillment",
},
"inventoryService": true,
"notification": {
"Inventory": true,
"Notification": {
"options": {
"providers": [
{
@@ -67,23 +67,23 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/notification",
},
"order": true,
"payment": true,
"pricingService": true,
"productService": true,
"promotion": true,
"region": true,
"salesChannel": true,
"stockLocationService": true,
"store": true,
"tax": true,
"user": {
"Order": true,
"Payment": true,
"Pricing": true,
"Product": true,
"Promotion": true,
"Region": true,
"SalesChannel": true,
"StockLocation": true,
"Store": true,
"Tax": true,
"User": {
"options": {
"jwt_secret": "supersecret",
},
"resolve": "@medusajs/user",
},
"workflows": true,
"Workflows": true,
},
"plugins": [],
"projectConfig": {
@@ -104,7 +104,7 @@ describe("defineConfig", function () {
expect(
defineConfig({
modules: {
githubModuleService: {
GithubModuleService: {
resolve: "./modules/github",
},
},
@@ -116,8 +116,8 @@ describe("defineConfig", function () {
},
"featureFlags": {},
"modules": {
"apiKey": true,
"auth": {
"ApiKey": true,
"Auth": {
"options": {
"providers": [
{
@@ -128,12 +128,12 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/auth",
},
"cacheService": true,
"cart": true,
"currency": true,
"customer": true,
"eventBus": true,
"file": {
"Cache": true,
"Cart": true,
"Currency": true,
"Customer": true,
"EventBus": true,
"File": {
"options": {
"providers": [
{
@@ -144,7 +144,7 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/file",
},
"fulfillment": {
"Fulfillment": {
"options": {
"providers": [
{
@@ -155,11 +155,11 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/fulfillment",
},
"githubModuleService": {
"GithubModuleService": {
"resolve": "./modules/github",
},
"inventoryService": true,
"notification": {
"Inventory": true,
"Notification": {
"options": {
"providers": [
{
@@ -176,23 +176,23 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/notification",
},
"order": true,
"payment": true,
"pricingService": true,
"productService": true,
"promotion": true,
"region": true,
"salesChannel": true,
"stockLocationService": true,
"store": true,
"tax": true,
"user": {
"Order": true,
"Payment": true,
"Pricing": true,
"Product": true,
"Promotion": true,
"Region": true,
"SalesChannel": true,
"StockLocation": true,
"Store": true,
"Tax": true,
"User": {
"options": {
"jwt_secret": "supersecret",
},
"resolve": "@medusajs/user",
},
"workflows": true,
"Workflows": true,
},
"plugins": [],
"projectConfig": {
@@ -225,8 +225,8 @@ describe("defineConfig", function () {
},
"featureFlags": {},
"modules": {
"apiKey": true,
"auth": {
"ApiKey": true,
"Auth": {
"options": {
"providers": [
{
@@ -237,12 +237,12 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/auth",
},
"cacheService": true,
"cart": true,
"currency": true,
"customer": true,
"eventBus": true,
"file": {
"Cache": true,
"Cart": true,
"Currency": true,
"Customer": true,
"EventBus": true,
"File": {
"options": {
"providers": [
{
@@ -253,7 +253,7 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/file",
},
"fulfillment": {
"Fulfillment": {
"options": {
"providers": [
{
@@ -264,8 +264,8 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/fulfillment",
},
"inventoryService": true,
"notification": {
"Inventory": true,
"Notification": {
"options": {
"providers": [
{
@@ -282,23 +282,23 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/notification",
},
"order": true,
"payment": true,
"pricingService": true,
"productService": true,
"promotion": true,
"region": true,
"salesChannel": true,
"stockLocationService": true,
"store": true,
"tax": true,
"user": {
"Order": true,
"Payment": true,
"Pricing": true,
"Product": true,
"Promotion": true,
"Region": true,
"SalesChannel": true,
"StockLocation": true,
"Store": true,
"Tax": true,
"User": {
"options": {
"jwt_secret": "supersecret",
},
"resolve": "@medusajs/user",
},
"workflows": true,
"Workflows": true,
},
"plugins": [],
"projectConfig": {
@@ -334,8 +334,8 @@ describe("defineConfig", function () {
},
"featureFlags": {},
"modules": {
"apiKey": true,
"auth": {
"ApiKey": true,
"Auth": {
"options": {
"providers": [
{
@@ -346,11 +346,11 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/auth",
},
"cacheService": true,
"currency": true,
"customer": true,
"eventBus": true,
"file": {
"Cache": true,
"Currency": true,
"Customer": true,
"EventBus": true,
"File": {
"options": {
"providers": [
{
@@ -361,7 +361,7 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/file",
},
"fulfillment": {
"Fulfillment": {
"options": {
"providers": [
{
@@ -372,8 +372,8 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/fulfillment",
},
"inventoryService": true,
"notification": {
"Inventory": true,
"Notification": {
"options": {
"providers": [
{
@@ -390,23 +390,23 @@ describe("defineConfig", function () {
},
"resolve": "@medusajs/notification",
},
"order": true,
"payment": true,
"pricingService": true,
"productService": true,
"promotion": true,
"region": true,
"salesChannel": true,
"stockLocationService": true,
"store": true,
"tax": true,
"user": {
"Order": true,
"Payment": true,
"Pricing": true,
"Product": true,
"Promotion": true,
"Region": true,
"SalesChannel": true,
"StockLocation": true,
"Store": true,
"Tax": true,
"User": {
"options": {
"jwt_secret": "supersecret",
},
"resolve": "@medusajs/user",
},
"workflows": true,
"Workflows": true,
},
"plugins": [],
"projectConfig": {

View File

@@ -10,7 +10,7 @@ describe("MessageAggregator", function () {
aggregator.save({
eventName: "ProductVariant.created",
metadata: {
source: "ProductService",
source: "Product",
action: "created",
object: "ProductVariant",
eventGroupId: "1",
@@ -20,7 +20,7 @@ describe("MessageAggregator", function () {
aggregator.save({
eventName: "Product.created",
metadata: {
source: "ProductService",
source: "Product",
action: "created",
object: "Product",
eventGroupId: "1",
@@ -30,7 +30,7 @@ describe("MessageAggregator", function () {
aggregator.save({
eventName: "ProductVariant.created",
metadata: {
source: "ProductService",
source: "Product",
action: "created",
object: "ProductVariant",
eventGroupId: "1",
@@ -40,7 +40,7 @@ describe("MessageAggregator", function () {
aggregator.save({
eventName: "ProductType.detached",
metadata: {
source: "ProductService",
source: "Product",
action: "detached",
object: "ProductType",
eventGroupId: "1",
@@ -50,7 +50,7 @@ describe("MessageAggregator", function () {
aggregator.save({
eventName: "ProductVariant.updated",
metadata: {
source: "ProductService",
source: "Product",
action: "updated",
object: "ProductVariant",
eventGroupId: "1",
@@ -76,7 +76,7 @@ describe("MessageAggregator", function () {
{
eventName: "ProductType.detached",
metadata: {
source: "ProductService",
source: "Product",
action: "detached",
object: "ProductType",
eventGroupId: "1",
@@ -89,7 +89,7 @@ describe("MessageAggregator", function () {
{
eventName: "ProductVariant.updated",
metadata: {
source: "ProductService",
source: "Product",
action: "updated",
object: "ProductVariant",
eventGroupId: "1",
@@ -102,7 +102,7 @@ describe("MessageAggregator", function () {
{
eventName: "ProductVariant.created",
metadata: {
source: "ProductService",
source: "Product",
action: "created",
object: "ProductVariant",
eventGroupId: "1",
@@ -112,7 +112,7 @@ describe("MessageAggregator", function () {
{
eventName: "ProductVariant.created",
metadata: {
source: "ProductService",
source: "Product",
action: "created",
object: "ProductVariant",
eventGroupId: "1",
@@ -125,7 +125,7 @@ describe("MessageAggregator", function () {
{
eventName: "Product.created",
metadata: {
source: "ProductService",
source: "Product",
action: "created",
object: "Product",
eventGroupId: "1",

View File

@@ -1,7 +1,7 @@
import { lowerCaseFirst, toPascalCase } from "../common"
import { toPascalCase, upperCaseFirst } from "../common"
export const composeLinkName = (...args) => {
return lowerCaseFirst(toPascalCase(composeTableName(...args.concat("link"))))
return upperCaseFirst(toPascalCase(composeTableName(...args.concat("link"))))
}
export const composeTableName = (...args) => {

View File

@@ -25,82 +25,58 @@ import type {
} from "@medusajs/types"
export enum Modules {
AUTH = "auth",
CACHE = "cacheService",
CART = "cart",
CUSTOMER = "customer",
EVENT_BUS = "eventBus",
INVENTORY = "inventoryService",
LINK = "linkModules",
PAYMENT = "payment",
PRICING = "pricingService",
PRODUCT = "productService",
PROMOTION = "promotion",
SALES_CHANNEL = "salesChannel",
TAX = "tax",
FULFILLMENT = "fulfillment",
STOCK_LOCATION = "stockLocationService",
USER = "user",
WORKFLOW_ENGINE = "workflows",
REGION = "region",
ORDER = "order",
API_KEY = "apiKey",
STORE = "store",
CURRENCY = "currency",
FILE = "file",
NOTIFICATION = "notification",
AUTH = "Auth",
CACHE = "Cache",
CART = "Cart",
CUSTOMER = "Customer",
EVENT_BUS = "EventBus",
INVENTORY = "Inventory",
LINK = "LinkModules",
PAYMENT = "Payment",
PRICING = "Pricing",
PRODUCT = "Product",
PROMOTION = "Promotion",
SALES_CHANNEL = "SalesChannel",
TAX = "Tax",
FULFILLMENT = "Fulfillment",
STOCK_LOCATION = "StockLocation",
USER = "User",
WORKFLOW_ENGINE = "Workflows",
REGION = "Region",
ORDER = "Order",
API_KEY = "ApiKey",
STORE = "Store",
CURRENCY = "Currency",
FILE = "File",
NOTIFICATION = "Notification",
}
export enum ModuleRegistrationName {
AUTH = "authModuleService",
CACHE = "cacheService",
CART = "cartModuleService",
CUSTOMER = "customerModuleService",
EVENT_BUS = "eventBusModuleService",
INVENTORY = "inventoryService",
PAYMENT = "paymentModuleService",
PRICING = "pricingModuleService",
PRODUCT = "productModuleService",
PROMOTION = "promotionModuleService",
SALES_CHANNEL = "salesChannelModuleService",
FULFILLMENT = "fulfillmentModuleService",
STOCK_LOCATION = "stockLocationService",
TAX = "taxModuleService",
USER = "userModuleService",
WORKFLOW_ENGINE = "workflowsModuleService",
REGION = "regionModuleService",
ORDER = "orderModuleService",
API_KEY = "apiKeyModuleService",
STORE = "storeModuleService",
CURRENCY = "currencyModuleService",
FILE = "fileModuleService",
NOTIFICATION = "notificationModuleService",
}
export const ModuleRegistrationName = Modules
declare module "@medusajs/types" {
export interface ModuleImplementations {
[ModuleRegistrationName.AUTH]: IAuthModuleService
[ModuleRegistrationName.CACHE]: ICacheService
[ModuleRegistrationName.CART]: ICartModuleService
[ModuleRegistrationName.CUSTOMER]: ICustomerModuleService
[ModuleRegistrationName.EVENT_BUS]: IEventBusModuleService
[ModuleRegistrationName.INVENTORY]: IInventoryService
[ModuleRegistrationName.PAYMENT]: IPaymentModuleService
[ModuleRegistrationName.PRICING]: IPricingModuleService
[ModuleRegistrationName.PRODUCT]: IProductModuleService
[ModuleRegistrationName.PROMOTION]: IPromotionModuleService
[ModuleRegistrationName.SALES_CHANNEL]: ISalesChannelModuleService
[ModuleRegistrationName.TAX]: ITaxModuleService
[ModuleRegistrationName.FULFILLMENT]: IFulfillmentModuleService
[ModuleRegistrationName.STOCK_LOCATION]: IStockLocationService
[ModuleRegistrationName.USER]: IUserModuleService
[ModuleRegistrationName.WORKFLOW_ENGINE]: IWorkflowEngineService
[ModuleRegistrationName.REGION]: IRegionModuleService
[ModuleRegistrationName.ORDER]: IOrderModuleService
[ModuleRegistrationName.API_KEY]: IApiKeyModuleService
[ModuleRegistrationName.STORE]: IStoreModuleService
[ModuleRegistrationName.CURRENCY]: ICurrencyModuleService
[ModuleRegistrationName.FILE]: IFileModuleService
[ModuleRegistrationName.NOTIFICATION]: INotificationModuleService
[Modules.AUTH]: IAuthModuleService
[Modules.CACHE]: ICacheService
[Modules.CART]: ICartModuleService
[Modules.CUSTOMER]: ICustomerModuleService
[Modules.EVENT_BUS]: IEventBusModuleService
[Modules.INVENTORY]: IInventoryService
[Modules.PAYMENT]: IPaymentModuleService
[Modules.PRICING]: IPricingModuleService
[Modules.PRODUCT]: IProductModuleService
[Modules.PROMOTION]: IPromotionModuleService
[Modules.SALES_CHANNEL]: ISalesChannelModuleService
[Modules.TAX]: ITaxModuleService
[Modules.FULFILLMENT]: IFulfillmentModuleService
[Modules.STOCK_LOCATION]: IStockLocationService
[Modules.USER]: IUserModuleService
[Modules.WORKFLOW_ENGINE]: IWorkflowEngineService
[Modules.REGION]: IRegionModuleService
[Modules.ORDER]: IOrderModuleService
[Modules.API_KEY]: IApiKeyModuleService
[Modules.STORE]: IStoreModuleService
[Modules.CURRENCY]: ICurrencyModuleService
[Modules.FILE]: IFileModuleService
[Modules.NOTIFICATION]: INotificationModuleService
}
}

View File

@@ -11,17 +11,17 @@ import {
SoftDeleteReturn,
} from "@medusajs/types"
import {
MapToConfig,
isString,
kebabCase,
lowerCaseFirst,
mapObjectTo,
MapToConfig,
pluralize,
upperCaseFirst,
} from "../common"
import { DmlEntity } from "../dml"
import { InjectManager, MedusaContext } from "./decorators"
import { ModuleRegistrationName } from "./definition"
import { Modules } from "./definition"
import { buildModelsNameToLinkableKeysMap } from "./joiner-config-builder"
import {
BaseMethods,
@@ -385,11 +385,11 @@ export function MedusaService<
this.baseRepository_ = container.baseRepository
const hasEventBusModuleService = Object.keys(this.__container__).find(
(key) => key === ModuleRegistrationName.EVENT_BUS
(key) => key === Modules.EVENT_BUS
)
this.eventBusModuleService_ = hasEventBusModuleService
? this.__container__.eventBusModuleService
? this.__container__[Modules.EVENT_BUS]
: undefined
this[MedusaServiceModelNameToLinkableKeysMapSymbol] =