chore(): Allow to register modules through array (#9522)
This commit is contained in:
committed by
GitHub
parent
9c73503084
commit
1d8939df3a
@@ -144,18 +144,18 @@ medusaIntegrationTestRunner({
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
Product: {
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: product.variants[0].id,
|
||||
},
|
||||
Pricing: {
|
||||
[Modules.PRICING]: {
|
||||
price_set_id: priceSet.id,
|
||||
},
|
||||
},
|
||||
{
|
||||
Product: {
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: product.variants[1].id,
|
||||
},
|
||||
Pricing: {
|
||||
[Modules.PRICING]: {
|
||||
price_set_id: priceSetTwo.id,
|
||||
},
|
||||
},
|
||||
@@ -232,8 +232,8 @@ medusaIntegrationTestRunner({
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
Product: { variant_id: product.variants[0].id },
|
||||
Pricing: { price_set_id: priceSet.id },
|
||||
[Modules.PRODUCT]: { variant_id: product.variants[0].id },
|
||||
[Modules.PRICING]: { price_set_id: priceSet.id },
|
||||
},
|
||||
])
|
||||
|
||||
@@ -1080,10 +1080,10 @@ medusaIntegrationTestRunner({
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
Product: {
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: productWithDefaultTax.variants[0].id,
|
||||
},
|
||||
Pricing: { price_set_id: priceSetDefaultTax.id },
|
||||
[Modules.PRICING]: { price_set_id: priceSetDefaultTax.id },
|
||||
},
|
||||
])
|
||||
|
||||
@@ -1212,10 +1212,10 @@ medusaIntegrationTestRunner({
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
Product: {
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: productWithDefaultTax.variants[0].id,
|
||||
},
|
||||
Pricing: { price_set_id: priceSetDefaultTax.id },
|
||||
[Modules.PRICING]: { price_set_id: priceSetDefaultTax.id },
|
||||
},
|
||||
])
|
||||
|
||||
@@ -2104,16 +2104,16 @@ medusaIntegrationTestRunner({
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
Product: {
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: productWithSpecialTax.variants[0].id,
|
||||
},
|
||||
Pricing: { price_set_id: priceSet.id },
|
||||
[Modules.PRICING]: { price_set_id: priceSet.id },
|
||||
},
|
||||
{
|
||||
Product: {
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: productWithDefaultTax.variants[0].id,
|
||||
},
|
||||
Pricing: { price_set_id: priceSetDefaultTax.id },
|
||||
[Modules.PRICING]: { price_set_id: priceSetDefaultTax.id },
|
||||
},
|
||||
{
|
||||
[Modules.CART]: { cart_id: cart.id },
|
||||
|
||||
@@ -42,7 +42,7 @@ medusaIntegrationTestRunner({
|
||||
primaryKeys: ["id", "currency_code", "region_id"],
|
||||
relationships: [
|
||||
{
|
||||
serviceName: "Currency",
|
||||
serviceName: "currency",
|
||||
entity: "Currency",
|
||||
primaryKey: "code",
|
||||
foreignKey: "currency_code",
|
||||
@@ -53,7 +53,7 @@ medusaIntegrationTestRunner({
|
||||
deleteCascade: false,
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
entity: "Region",
|
||||
primaryKey: "id",
|
||||
foreignKey: "region_id",
|
||||
@@ -66,7 +66,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
extends: [
|
||||
{
|
||||
serviceName: "Currency",
|
||||
serviceName: "currency",
|
||||
fieldAlias: {
|
||||
region: {
|
||||
path: "region_link.region",
|
||||
@@ -84,7 +84,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
fieldAlias: {
|
||||
currency: {
|
||||
path: "currency_link.currency",
|
||||
@@ -139,7 +139,7 @@ medusaIntegrationTestRunner({
|
||||
primaryKeys: ["id", "product_variant_id", "region_id"],
|
||||
relationships: [
|
||||
{
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
entity: "ProductVariant",
|
||||
primaryKey: "id",
|
||||
foreignKey: "product_variant_id",
|
||||
@@ -150,7 +150,7 @@ medusaIntegrationTestRunner({
|
||||
deleteCascade: false,
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
entity: "Region",
|
||||
primaryKey: "id",
|
||||
foreignKey: "region_id",
|
||||
@@ -163,7 +163,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
extends: [
|
||||
{
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
fieldAlias: {
|
||||
region: {
|
||||
path: "region_link.region",
|
||||
@@ -181,7 +181,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
fieldAlias: {
|
||||
product_variant: {
|
||||
path: "product_variant_link.product_variant",
|
||||
@@ -241,7 +241,7 @@ medusaIntegrationTestRunner({
|
||||
primaryKeys: ["id", "currency_code", "region_id"],
|
||||
relationships: [
|
||||
{
|
||||
serviceName: "Currency",
|
||||
serviceName: "currency",
|
||||
entity: "Currency",
|
||||
primaryKey: "code",
|
||||
foreignKey: "currency_code",
|
||||
@@ -252,7 +252,7 @@ medusaIntegrationTestRunner({
|
||||
deleteCascade: true,
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
entity: "Region",
|
||||
primaryKey: "id",
|
||||
foreignKey: "region_id",
|
||||
@@ -265,7 +265,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
extends: [
|
||||
{
|
||||
serviceName: "Currency",
|
||||
serviceName: "currency",
|
||||
fieldAlias: {
|
||||
region: {
|
||||
path: "region_link.region",
|
||||
@@ -283,7 +283,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
fieldAlias: {
|
||||
currency: {
|
||||
path: "currency_link.currency",
|
||||
@@ -337,7 +337,7 @@ medusaIntegrationTestRunner({
|
||||
primaryKeys: ["id", "currency_code", "region_id"],
|
||||
relationships: [
|
||||
{
|
||||
serviceName: "Currency",
|
||||
serviceName: "currency",
|
||||
entity: "Currency",
|
||||
primaryKey: "code",
|
||||
foreignKey: "currency_code",
|
||||
@@ -348,7 +348,7 @@ medusaIntegrationTestRunner({
|
||||
deleteCascade: false,
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
entity: "Region",
|
||||
primaryKey: "id",
|
||||
foreignKey: "region_id",
|
||||
@@ -361,7 +361,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
extends: [
|
||||
{
|
||||
serviceName: "Currency",
|
||||
serviceName: "currency",
|
||||
fieldAlias: {
|
||||
regions: {
|
||||
path: "region_link.region",
|
||||
@@ -379,7 +379,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceName: "Region",
|
||||
serviceName: "region",
|
||||
fieldAlias: {
|
||||
currency: {
|
||||
path: "currency_link.currency",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import { ContainerRegistrationKeys, Modules } from "@medusajs/framework/utils"
|
||||
|
||||
export const attachInventoryItemToVariantsStepId =
|
||||
"attach-inventory-items-to-variants-step"
|
||||
@@ -21,10 +21,10 @@ export const attachInventoryItemToVariants = createStep(
|
||||
const linkDefinitions = input
|
||||
.filter(({ tag }) => !!tag)
|
||||
.map(({ inventoryItemId, tag }) => ({
|
||||
Product: {
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: tag!,
|
||||
},
|
||||
Inventory: {
|
||||
[Modules.INVENTORY]: {
|
||||
inventory_item_id: inventoryItemId,
|
||||
},
|
||||
}))
|
||||
|
||||
@@ -1,39 +1,12 @@
|
||||
import { ModuleDefinition } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
MODULE_PACKAGE_NAMES,
|
||||
Modules,
|
||||
upperCaseFirst,
|
||||
} from "@medusajs/utils"
|
||||
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||
|
||||
export const MODULE_PACKAGE_NAMES = {
|
||||
[Modules.AUTH]: "@medusajs/medusa/auth",
|
||||
[Modules.CACHE]: "@medusajs/medusa/cache-inmemory",
|
||||
[Modules.CART]: "@medusajs/medusa/cart",
|
||||
[Modules.CUSTOMER]: "@medusajs/medusa/customer",
|
||||
[Modules.EVENT_BUS]: "@medusajs/medusa/event-bus-local",
|
||||
[Modules.INVENTORY]: "@medusajs/medusa/inventory-next", // TODO: To be replaced when current `@medusajs/inventory` is deprecated
|
||||
[Modules.LINK]: "@medusajs/medusa/link-modules",
|
||||
[Modules.PAYMENT]: "@medusajs/medusa/payment",
|
||||
[Modules.PRICING]: "@medusajs/medusa/pricing",
|
||||
[Modules.PRODUCT]: "@medusajs/medusa/product",
|
||||
[Modules.PROMOTION]: "@medusajs/medusa/promotion",
|
||||
[Modules.SALES_CHANNEL]: "@medusajs/medusa/sales-channel",
|
||||
[Modules.FULFILLMENT]: "@medusajs/medusa/fulfillment",
|
||||
[Modules.STOCK_LOCATION]: "@medusajs/medusa/stock-location-next", // TODO: To be replaced when current `@medusajs/stock-location` is deprecated
|
||||
[Modules.TAX]: "@medusajs/medusa/tax",
|
||||
[Modules.USER]: "@medusajs/medusa/user",
|
||||
[Modules.WORKFLOW_ENGINE]: "@medusajs/medusa/workflow-engine-inmemory",
|
||||
[Modules.REGION]: "@medusajs/medusa/region",
|
||||
[Modules.ORDER]: "@medusajs/medusa/order",
|
||||
[Modules.API_KEY]: "@medusajs/medusa/api-key",
|
||||
[Modules.STORE]: "@medusajs/medusa/store",
|
||||
[Modules.CURRENCY]: "@medusajs/medusa/currency",
|
||||
[Modules.FILE]: "@medusajs/medusa/file",
|
||||
[Modules.NOTIFICATION]: "@medusajs/medusa/notification",
|
||||
[Modules.INDEX]: "@medusajs/medusa/index-module",
|
||||
}
|
||||
|
||||
export const ModulesDefinition: {
|
||||
[key: string]: ModuleDefinition
|
||||
} = {
|
||||
|
||||
@@ -20,12 +20,12 @@ import {
|
||||
isObject,
|
||||
isString,
|
||||
MedusaError,
|
||||
MODULE_PACKAGE_NAMES,
|
||||
Modules,
|
||||
ModulesSdkUtils,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { asValue } from "awilix"
|
||||
import { MODULE_PACKAGE_NAMES } from "./definitions"
|
||||
import {
|
||||
MedusaModule,
|
||||
MigrationOptions,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Module } from "../../../../modules-sdk"
|
||||
|
||||
export default Module("GithubModuleService", {
|
||||
service: class GithubModuleService {},
|
||||
})
|
||||
@@ -12,8 +12,10 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"featureFlags": {},
|
||||
"modules": {
|
||||
"ApiKey": true,
|
||||
"Auth": {
|
||||
"api_key": {
|
||||
"resolve": "@medusajs/medusa/api-key",
|
||||
},
|
||||
"auth": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -22,14 +24,24 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/auth",
|
||||
"resolve": "@medusajs/medusa/auth",
|
||||
},
|
||||
"Cache": true,
|
||||
"Cart": true,
|
||||
"Currency": true,
|
||||
"Customer": true,
|
||||
"EventBus": true,
|
||||
"File": {
|
||||
"cache": {
|
||||
"resolve": "@medusajs/medusa/cache-inmemory",
|
||||
},
|
||||
"cart": {
|
||||
"resolve": "@medusajs/medusa/cart",
|
||||
},
|
||||
"currency": {
|
||||
"resolve": "@medusajs/medusa/currency",
|
||||
},
|
||||
"customer": {
|
||||
"resolve": "@medusajs/medusa/customer",
|
||||
},
|
||||
"event_bus": {
|
||||
"resolve": "@medusajs/medusa/event-bus-local",
|
||||
},
|
||||
"file": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -38,9 +50,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/file",
|
||||
"resolve": "@medusajs/medusa/file",
|
||||
},
|
||||
"Fulfillment": {
|
||||
"fulfillment": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -49,10 +61,12 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/fulfillment",
|
||||
"resolve": "@medusajs/medusa/fulfillment",
|
||||
},
|
||||
"Inventory": true,
|
||||
"Notification": {
|
||||
"inventory": {
|
||||
"resolve": "@medusajs/medusa/inventory-next",
|
||||
},
|
||||
"notification": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -67,25 +81,47 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/notification",
|
||||
"resolve": "@medusajs/medusa/notification",
|
||||
},
|
||||
"Order": true,
|
||||
"Payment": true,
|
||||
"Pricing": true,
|
||||
"Product": true,
|
||||
"Promotion": true,
|
||||
"Region": true,
|
||||
"SalesChannel": true,
|
||||
"StockLocation": true,
|
||||
"Store": true,
|
||||
"Tax": true,
|
||||
"User": {
|
||||
"order": {
|
||||
"resolve": "@medusajs/medusa/order",
|
||||
},
|
||||
"payment": {
|
||||
"resolve": "@medusajs/medusa/payment",
|
||||
},
|
||||
"pricing": {
|
||||
"resolve": "@medusajs/medusa/pricing",
|
||||
},
|
||||
"product": {
|
||||
"resolve": "@medusajs/medusa/product",
|
||||
},
|
||||
"promotion": {
|
||||
"resolve": "@medusajs/medusa/promotion",
|
||||
},
|
||||
"region": {
|
||||
"resolve": "@medusajs/medusa/region",
|
||||
},
|
||||
"sales_channel": {
|
||||
"resolve": "@medusajs/medusa/sales-channel",
|
||||
},
|
||||
"stock_location": {
|
||||
"resolve": "@medusajs/medusa/stock-location-next",
|
||||
},
|
||||
"store": {
|
||||
"resolve": "@medusajs/medusa/store",
|
||||
},
|
||||
"tax": {
|
||||
"resolve": "@medusajs/medusa/tax",
|
||||
},
|
||||
"user": {
|
||||
"options": {
|
||||
"jwt_secret": "supersecret",
|
||||
},
|
||||
"resolve": "@medusajs/user",
|
||||
"resolve": "@medusajs/medusa/user",
|
||||
},
|
||||
"workflows": {
|
||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||
},
|
||||
"Workflows": true,
|
||||
},
|
||||
"plugins": [],
|
||||
"projectConfig": {
|
||||
@@ -120,8 +156,13 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"featureFlags": {},
|
||||
"modules": {
|
||||
"ApiKey": true,
|
||||
"Auth": {
|
||||
"GithubModuleService": {
|
||||
"resolve": "./modules/github",
|
||||
},
|
||||
"api_key": {
|
||||
"resolve": "@medusajs/medusa/api-key",
|
||||
},
|
||||
"auth": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -130,14 +171,24 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/auth",
|
||||
"resolve": "@medusajs/medusa/auth",
|
||||
},
|
||||
"Cache": true,
|
||||
"Cart": true,
|
||||
"Currency": true,
|
||||
"Customer": true,
|
||||
"EventBus": true,
|
||||
"File": {
|
||||
"cache": {
|
||||
"resolve": "@medusajs/medusa/cache-inmemory",
|
||||
},
|
||||
"cart": {
|
||||
"resolve": "@medusajs/medusa/cart",
|
||||
},
|
||||
"currency": {
|
||||
"resolve": "@medusajs/medusa/currency",
|
||||
},
|
||||
"customer": {
|
||||
"resolve": "@medusajs/medusa/customer",
|
||||
},
|
||||
"event_bus": {
|
||||
"resolve": "@medusajs/medusa/event-bus-local",
|
||||
},
|
||||
"file": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -146,9 +197,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/file",
|
||||
"resolve": "@medusajs/medusa/file",
|
||||
},
|
||||
"Fulfillment": {
|
||||
"fulfillment": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -157,13 +208,12 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/fulfillment",
|
||||
"resolve": "@medusajs/medusa/fulfillment",
|
||||
},
|
||||
"GithubModuleService": {
|
||||
"resolve": "./modules/github",
|
||||
"inventory": {
|
||||
"resolve": "@medusajs/medusa/inventory-next",
|
||||
},
|
||||
"Inventory": true,
|
||||
"Notification": {
|
||||
"notification": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -178,25 +228,358 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/notification",
|
||||
"resolve": "@medusajs/medusa/notification",
|
||||
},
|
||||
"Order": true,
|
||||
"Payment": true,
|
||||
"Pricing": true,
|
||||
"Product": true,
|
||||
"Promotion": true,
|
||||
"Region": true,
|
||||
"SalesChannel": true,
|
||||
"StockLocation": true,
|
||||
"Store": true,
|
||||
"Tax": true,
|
||||
"User": {
|
||||
"order": {
|
||||
"resolve": "@medusajs/medusa/order",
|
||||
},
|
||||
"payment": {
|
||||
"resolve": "@medusajs/medusa/payment",
|
||||
},
|
||||
"pricing": {
|
||||
"resolve": "@medusajs/medusa/pricing",
|
||||
},
|
||||
"product": {
|
||||
"resolve": "@medusajs/medusa/product",
|
||||
},
|
||||
"promotion": {
|
||||
"resolve": "@medusajs/medusa/promotion",
|
||||
},
|
||||
"region": {
|
||||
"resolve": "@medusajs/medusa/region",
|
||||
},
|
||||
"sales_channel": {
|
||||
"resolve": "@medusajs/medusa/sales-channel",
|
||||
},
|
||||
"stock_location": {
|
||||
"resolve": "@medusajs/medusa/stock-location-next",
|
||||
},
|
||||
"store": {
|
||||
"resolve": "@medusajs/medusa/store",
|
||||
},
|
||||
"tax": {
|
||||
"resolve": "@medusajs/medusa/tax",
|
||||
},
|
||||
"user": {
|
||||
"options": {
|
||||
"jwt_secret": "supersecret",
|
||||
},
|
||||
"resolve": "@medusajs/user",
|
||||
"resolve": "@medusajs/medusa/user",
|
||||
},
|
||||
"workflows": {
|
||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||
},
|
||||
},
|
||||
"plugins": [],
|
||||
"projectConfig": {
|
||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||
"http": {
|
||||
"adminCors": "http://localhost:7000,http://localhost:7001,http://localhost:5173",
|
||||
"authCors": "http://localhost:7000,http://localhost:7001,http://localhost:5173",
|
||||
"cookieSecret": "supersecret",
|
||||
"jwtSecret": "supersecret",
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
it("should merge custom modules when an array is provided", function () {
|
||||
expect(
|
||||
defineConfig({
|
||||
modules: [
|
||||
{
|
||||
resolve: require.resolve("../__fixtures__/define-config/github"),
|
||||
options: {
|
||||
apiKey: "test",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"admin": {
|
||||
"backendUrl": "http://localhost:9000",
|
||||
"outDir": ".medusa/admin",
|
||||
"path": "/app",
|
||||
},
|
||||
"featureFlags": {},
|
||||
"modules": {
|
||||
"GithubModuleService": {
|
||||
"options": {
|
||||
"apiKey": "test",
|
||||
},
|
||||
"resolve": "${require.resolve(
|
||||
"../__fixtures__/define-config/github"
|
||||
)}",
|
||||
},
|
||||
"api_key": {
|
||||
"resolve": "@medusajs/medusa/api-key",
|
||||
},
|
||||
"auth": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "emailpass",
|
||||
"resolve": "@medusajs/auth-emailpass",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/auth",
|
||||
},
|
||||
"cache": {
|
||||
"resolve": "@medusajs/medusa/cache-inmemory",
|
||||
},
|
||||
"cart": {
|
||||
"resolve": "@medusajs/medusa/cart",
|
||||
},
|
||||
"currency": {
|
||||
"resolve": "@medusajs/medusa/currency",
|
||||
},
|
||||
"customer": {
|
||||
"resolve": "@medusajs/medusa/customer",
|
||||
},
|
||||
"event_bus": {
|
||||
"resolve": "@medusajs/medusa/event-bus-local",
|
||||
},
|
||||
"file": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/file-local-next",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/file",
|
||||
},
|
||||
"fulfillment": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "manual",
|
||||
"resolve": "@medusajs/fulfillment-manual",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/fulfillment",
|
||||
},
|
||||
"inventory": {
|
||||
"resolve": "@medusajs/medusa/inventory-next",
|
||||
},
|
||||
"notification": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "local",
|
||||
"options": {
|
||||
"channels": [
|
||||
"feed",
|
||||
],
|
||||
"name": "Local Notification Provider",
|
||||
},
|
||||
"resolve": "@medusajs/notification-local",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/notification",
|
||||
},
|
||||
"order": {
|
||||
"resolve": "@medusajs/medusa/order",
|
||||
},
|
||||
"payment": {
|
||||
"resolve": "@medusajs/medusa/payment",
|
||||
},
|
||||
"pricing": {
|
||||
"resolve": "@medusajs/medusa/pricing",
|
||||
},
|
||||
"product": {
|
||||
"resolve": "@medusajs/medusa/product",
|
||||
},
|
||||
"promotion": {
|
||||
"resolve": "@medusajs/medusa/promotion",
|
||||
},
|
||||
"region": {
|
||||
"resolve": "@medusajs/medusa/region",
|
||||
},
|
||||
"sales_channel": {
|
||||
"resolve": "@medusajs/medusa/sales-channel",
|
||||
},
|
||||
"stock_location": {
|
||||
"resolve": "@medusajs/medusa/stock-location-next",
|
||||
},
|
||||
"store": {
|
||||
"resolve": "@medusajs/medusa/store",
|
||||
},
|
||||
"tax": {
|
||||
"resolve": "@medusajs/medusa/tax",
|
||||
},
|
||||
"user": {
|
||||
"options": {
|
||||
"jwt_secret": "supersecret",
|
||||
},
|
||||
"resolve": "@medusajs/medusa/user",
|
||||
},
|
||||
"workflows": {
|
||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||
},
|
||||
},
|
||||
"plugins": [],
|
||||
"projectConfig": {
|
||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||
"http": {
|
||||
"adminCors": "http://localhost:7000,http://localhost:7001,http://localhost:5173",
|
||||
"authCors": "http://localhost:7000,http://localhost:7001,http://localhost:5173",
|
||||
"cookieSecret": "supersecret",
|
||||
"jwtSecret": "supersecret",
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
it("should merge custom modules when an array is provided with a key to override the module registration name", function () {
|
||||
expect(
|
||||
defineConfig({
|
||||
modules: [
|
||||
{
|
||||
key: "GithubModuleServiceOverride",
|
||||
resolve: require.resolve("../__fixtures__/define-config/github"),
|
||||
options: {
|
||||
apiKey: "test",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"admin": {
|
||||
"backendUrl": "http://localhost:9000",
|
||||
"outDir": ".medusa/admin",
|
||||
"path": "/app",
|
||||
},
|
||||
"featureFlags": {},
|
||||
"modules": {
|
||||
"GithubModuleServiceOverride": {
|
||||
"options": {
|
||||
"apiKey": "test",
|
||||
},
|
||||
"resolve": "${require.resolve(
|
||||
"../__fixtures__/define-config/github"
|
||||
)}",
|
||||
},
|
||||
"api_key": {
|
||||
"resolve": "@medusajs/medusa/api-key",
|
||||
},
|
||||
"auth": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "emailpass",
|
||||
"resolve": "@medusajs/auth-emailpass",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/auth",
|
||||
},
|
||||
"cache": {
|
||||
"resolve": "@medusajs/medusa/cache-inmemory",
|
||||
},
|
||||
"cart": {
|
||||
"resolve": "@medusajs/medusa/cart",
|
||||
},
|
||||
"currency": {
|
||||
"resolve": "@medusajs/medusa/currency",
|
||||
},
|
||||
"customer": {
|
||||
"resolve": "@medusajs/medusa/customer",
|
||||
},
|
||||
"event_bus": {
|
||||
"resolve": "@medusajs/medusa/event-bus-local",
|
||||
},
|
||||
"file": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/file-local-next",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/file",
|
||||
},
|
||||
"fulfillment": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "manual",
|
||||
"resolve": "@medusajs/fulfillment-manual",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/fulfillment",
|
||||
},
|
||||
"inventory": {
|
||||
"resolve": "@medusajs/medusa/inventory-next",
|
||||
},
|
||||
"notification": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"id": "local",
|
||||
"options": {
|
||||
"channels": [
|
||||
"feed",
|
||||
],
|
||||
"name": "Local Notification Provider",
|
||||
},
|
||||
"resolve": "@medusajs/notification-local",
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/medusa/notification",
|
||||
},
|
||||
"order": {
|
||||
"resolve": "@medusajs/medusa/order",
|
||||
},
|
||||
"payment": {
|
||||
"resolve": "@medusajs/medusa/payment",
|
||||
},
|
||||
"pricing": {
|
||||
"resolve": "@medusajs/medusa/pricing",
|
||||
},
|
||||
"product": {
|
||||
"resolve": "@medusajs/medusa/product",
|
||||
},
|
||||
"promotion": {
|
||||
"resolve": "@medusajs/medusa/promotion",
|
||||
},
|
||||
"region": {
|
||||
"resolve": "@medusajs/medusa/region",
|
||||
},
|
||||
"sales_channel": {
|
||||
"resolve": "@medusajs/medusa/sales-channel",
|
||||
},
|
||||
"stock_location": {
|
||||
"resolve": "@medusajs/medusa/stock-location-next",
|
||||
},
|
||||
"store": {
|
||||
"resolve": "@medusajs/medusa/store",
|
||||
},
|
||||
"tax": {
|
||||
"resolve": "@medusajs/medusa/tax",
|
||||
},
|
||||
"user": {
|
||||
"options": {
|
||||
"jwt_secret": "supersecret",
|
||||
},
|
||||
"resolve": "@medusajs/medusa/user",
|
||||
},
|
||||
"workflows": {
|
||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||
},
|
||||
"Workflows": true,
|
||||
},
|
||||
"plugins": [],
|
||||
"projectConfig": {
|
||||
@@ -231,8 +614,10 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"featureFlags": {},
|
||||
"modules": {
|
||||
"ApiKey": true,
|
||||
"Auth": {
|
||||
"api_key": {
|
||||
"resolve": "@medusajs/medusa/api-key",
|
||||
},
|
||||
"auth": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -241,14 +626,24 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/auth",
|
||||
"resolve": "@medusajs/medusa/auth",
|
||||
},
|
||||
"Cache": true,
|
||||
"Cart": true,
|
||||
"Currency": true,
|
||||
"Customer": true,
|
||||
"EventBus": true,
|
||||
"File": {
|
||||
"cache": {
|
||||
"resolve": "@medusajs/medusa/cache-inmemory",
|
||||
},
|
||||
"cart": {
|
||||
"resolve": "@medusajs/medusa/cart",
|
||||
},
|
||||
"currency": {
|
||||
"resolve": "@medusajs/medusa/currency",
|
||||
},
|
||||
"customer": {
|
||||
"resolve": "@medusajs/medusa/customer",
|
||||
},
|
||||
"event_bus": {
|
||||
"resolve": "@medusajs/medusa/event-bus-local",
|
||||
},
|
||||
"file": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -257,9 +652,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/file",
|
||||
"resolve": "@medusajs/medusa/file",
|
||||
},
|
||||
"Fulfillment": {
|
||||
"fulfillment": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -268,10 +663,12 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/fulfillment",
|
||||
"resolve": "@medusajs/medusa/fulfillment",
|
||||
},
|
||||
"Inventory": true,
|
||||
"Notification": {
|
||||
"inventory": {
|
||||
"resolve": "@medusajs/medusa/inventory-next",
|
||||
},
|
||||
"notification": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -286,25 +683,47 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/notification",
|
||||
"resolve": "@medusajs/medusa/notification",
|
||||
},
|
||||
"Order": true,
|
||||
"Payment": true,
|
||||
"Pricing": true,
|
||||
"Product": true,
|
||||
"Promotion": true,
|
||||
"Region": true,
|
||||
"SalesChannel": true,
|
||||
"StockLocation": true,
|
||||
"Store": true,
|
||||
"Tax": true,
|
||||
"User": {
|
||||
"order": {
|
||||
"resolve": "@medusajs/medusa/order",
|
||||
},
|
||||
"payment": {
|
||||
"resolve": "@medusajs/medusa/payment",
|
||||
},
|
||||
"pricing": {
|
||||
"resolve": "@medusajs/medusa/pricing",
|
||||
},
|
||||
"product": {
|
||||
"resolve": "@medusajs/medusa/product",
|
||||
},
|
||||
"promotion": {
|
||||
"resolve": "@medusajs/medusa/promotion",
|
||||
},
|
||||
"region": {
|
||||
"resolve": "@medusajs/medusa/region",
|
||||
},
|
||||
"sales_channel": {
|
||||
"resolve": "@medusajs/medusa/sales-channel",
|
||||
},
|
||||
"stock_location": {
|
||||
"resolve": "@medusajs/medusa/stock-location-next",
|
||||
},
|
||||
"store": {
|
||||
"resolve": "@medusajs/medusa/store",
|
||||
},
|
||||
"tax": {
|
||||
"resolve": "@medusajs/medusa/tax",
|
||||
},
|
||||
"user": {
|
||||
"options": {
|
||||
"jwt_secret": "supersecret",
|
||||
},
|
||||
"resolve": "@medusajs/user",
|
||||
"resolve": "@medusajs/medusa/user",
|
||||
},
|
||||
"workflows": {
|
||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||
},
|
||||
"Workflows": true,
|
||||
},
|
||||
"plugins": [],
|
||||
"projectConfig": {
|
||||
@@ -342,8 +761,10 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"featureFlags": {},
|
||||
"modules": {
|
||||
"ApiKey": true,
|
||||
"Auth": {
|
||||
"api_key": {
|
||||
"resolve": "@medusajs/medusa/api-key",
|
||||
},
|
||||
"auth": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -352,13 +773,21 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/auth",
|
||||
"resolve": "@medusajs/medusa/auth",
|
||||
},
|
||||
"Cache": true,
|
||||
"Currency": true,
|
||||
"Customer": true,
|
||||
"EventBus": true,
|
||||
"File": {
|
||||
"cache": {
|
||||
"resolve": "@medusajs/medusa/cache-inmemory",
|
||||
},
|
||||
"currency": {
|
||||
"resolve": "@medusajs/medusa/currency",
|
||||
},
|
||||
"customer": {
|
||||
"resolve": "@medusajs/medusa/customer",
|
||||
},
|
||||
"event_bus": {
|
||||
"resolve": "@medusajs/medusa/event-bus-local",
|
||||
},
|
||||
"file": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -367,9 +796,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/file",
|
||||
"resolve": "@medusajs/medusa/file",
|
||||
},
|
||||
"Fulfillment": {
|
||||
"fulfillment": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -378,10 +807,12 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/fulfillment",
|
||||
"resolve": "@medusajs/medusa/fulfillment",
|
||||
},
|
||||
"Inventory": true,
|
||||
"Notification": {
|
||||
"inventory": {
|
||||
"resolve": "@medusajs/medusa/inventory-next",
|
||||
},
|
||||
"notification": {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
@@ -396,25 +827,47 @@ describe("defineConfig", function () {
|
||||
},
|
||||
],
|
||||
},
|
||||
"resolve": "@medusajs/notification",
|
||||
"resolve": "@medusajs/medusa/notification",
|
||||
},
|
||||
"Order": true,
|
||||
"Payment": true,
|
||||
"Pricing": true,
|
||||
"Product": true,
|
||||
"Promotion": true,
|
||||
"Region": true,
|
||||
"SalesChannel": true,
|
||||
"StockLocation": true,
|
||||
"Store": true,
|
||||
"Tax": true,
|
||||
"User": {
|
||||
"order": {
|
||||
"resolve": "@medusajs/medusa/order",
|
||||
},
|
||||
"payment": {
|
||||
"resolve": "@medusajs/medusa/payment",
|
||||
},
|
||||
"pricing": {
|
||||
"resolve": "@medusajs/medusa/pricing",
|
||||
},
|
||||
"product": {
|
||||
"resolve": "@medusajs/medusa/product",
|
||||
},
|
||||
"promotion": {
|
||||
"resolve": "@medusajs/medusa/promotion",
|
||||
},
|
||||
"region": {
|
||||
"resolve": "@medusajs/medusa/region",
|
||||
},
|
||||
"sales_channel": {
|
||||
"resolve": "@medusajs/medusa/sales-channel",
|
||||
},
|
||||
"stock_location": {
|
||||
"resolve": "@medusajs/medusa/stock-location-next",
|
||||
},
|
||||
"store": {
|
||||
"resolve": "@medusajs/medusa/store",
|
||||
},
|
||||
"tax": {
|
||||
"resolve": "@medusajs/medusa/tax",
|
||||
},
|
||||
"user": {
|
||||
"options": {
|
||||
"jwt_secret": "supersecret",
|
||||
},
|
||||
"resolve": "@medusajs/user",
|
||||
"resolve": "@medusajs/medusa/user",
|
||||
},
|
||||
"workflows": {
|
||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||
},
|
||||
"Workflows": true,
|
||||
},
|
||||
"plugins": [],
|
||||
"projectConfig": {
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
import { ConfigModule } from "@medusajs/types"
|
||||
import { Modules } from "../modules-sdk/definition"
|
||||
import {
|
||||
ConfigModule,
|
||||
ExternalModuleDeclaration,
|
||||
InternalModuleDeclaration,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
MODULE_PACKAGE_NAMES,
|
||||
Modules,
|
||||
REVERSED_MODULE_PACKAGE_NAMES,
|
||||
} from "../modules-sdk"
|
||||
import { isString } from "./is-string"
|
||||
import { resolveExports } from "./resolve-exports"
|
||||
import { isObject } from "./is-object"
|
||||
import { normalizeImportPathWithSource } from "./normalize-import-path-with-source"
|
||||
|
||||
const DEFAULT_SECRET = "supersecret"
|
||||
const DEFAULT_ADMIN_URL = "http://localhost:9000"
|
||||
@@ -8,6 +20,42 @@ const DEFAULT_DATABASE_URL = "postgres://localhost/medusa-starter-default"
|
||||
const DEFAULT_ADMIN_CORS =
|
||||
"http://localhost:7000,http://localhost:7001,http://localhost:5173"
|
||||
|
||||
type InternalModuleDeclarationOverride = InternalModuleDeclaration & {
|
||||
/**
|
||||
* Optional key to be used to identify the module, if not provided, it will be inferred from the module joiner config service name.
|
||||
*/
|
||||
key?: string
|
||||
/**
|
||||
* By default, modules are enabled, if provided as true, this will disable the module entirely.
|
||||
*/
|
||||
disable?: boolean
|
||||
}
|
||||
|
||||
type ExternalModuleDeclarationOverride = ExternalModuleDeclaration & {
|
||||
/**
|
||||
* key to be used to identify the module, if not provided, it will be inferred from the module joiner config service name.
|
||||
*/
|
||||
key: string
|
||||
/**
|
||||
* By default, modules are enabled, if provided as true, this will disable the module entirely.
|
||||
*/
|
||||
disable?: boolean
|
||||
}
|
||||
|
||||
type Config = Partial<
|
||||
Omit<ConfigModule, "admin" | "modules"> & {
|
||||
admin: Partial<ConfigModule["admin"]>
|
||||
modules:
|
||||
| Partial<
|
||||
InternalModuleDeclarationOverride | ExternalModuleDeclarationOverride
|
||||
>[]
|
||||
/**
|
||||
* @deprecated use the array instead
|
||||
*/
|
||||
| ConfigModule["modules"]
|
||||
}
|
||||
>
|
||||
|
||||
/**
|
||||
* The "defineConfig" helper can be used to define the configuration
|
||||
* of a medusa application.
|
||||
@@ -16,13 +64,7 @@ const DEFAULT_ADMIN_CORS =
|
||||
* make an application work seamlessly, but still provide you the ability
|
||||
* to override configuration as needed.
|
||||
*/
|
||||
export function defineConfig(
|
||||
config: Partial<
|
||||
Omit<ConfigModule, "admin"> & {
|
||||
admin: Partial<ConfigModule["admin"]>
|
||||
}
|
||||
> = {}
|
||||
): ConfigModule {
|
||||
export function defineConfig(config: Config = {}): ConfigModule {
|
||||
const { http, ...restOfProjectConfig } = config.projectConfig || {}
|
||||
|
||||
/**
|
||||
@@ -61,32 +103,54 @@ export function defineConfig(
|
||||
...config.featureFlags,
|
||||
}
|
||||
|
||||
const modules = resolveModules(config.modules)
|
||||
|
||||
return {
|
||||
projectConfig,
|
||||
featureFlags,
|
||||
plugins: config.plugins || [],
|
||||
admin,
|
||||
modules: modules,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The user API allow to use array of modules configuration. This method manage the loading of the user modules
|
||||
* along side the default modules and re map them to an object.
|
||||
*
|
||||
* @param configModules
|
||||
*/
|
||||
function resolveModules(
|
||||
configModules: Config["modules"]
|
||||
): ConfigModule["modules"] {
|
||||
/**
|
||||
* The default set of modules to always use. The end user can swap
|
||||
* the modules by providing an alternate implementation via their
|
||||
* config. But they can never remove a module from this list.
|
||||
*/
|
||||
const modules: ConfigModule["modules"] = {
|
||||
[Modules.CACHE]: true,
|
||||
[Modules.EVENT_BUS]: true,
|
||||
[Modules.WORKFLOW_ENGINE]: true,
|
||||
[Modules.STOCK_LOCATION]: true,
|
||||
[Modules.INVENTORY]: true,
|
||||
[Modules.PRODUCT]: true,
|
||||
[Modules.PRICING]: true,
|
||||
[Modules.PROMOTION]: true,
|
||||
[Modules.CUSTOMER]: true,
|
||||
[Modules.SALES_CHANNEL]: true,
|
||||
[Modules.CART]: true,
|
||||
[Modules.REGION]: true,
|
||||
[Modules.API_KEY]: true,
|
||||
[Modules.STORE]: true,
|
||||
[Modules.TAX]: true,
|
||||
[Modules.CURRENCY]: true,
|
||||
[Modules.PAYMENT]: true,
|
||||
[Modules.ORDER]: true,
|
||||
[Modules.AUTH]: {
|
||||
resolve: "@medusajs/auth",
|
||||
const modules: Config["modules"] = [
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.CACHE] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.EVENT_BUS] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.WORKFLOW_ENGINE] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.STOCK_LOCATION] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.INVENTORY] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.PRODUCT] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.PRICING] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.PROMOTION] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.CUSTOMER] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.SALES_CHANNEL] },
|
||||
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.CART] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.REGION] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.API_KEY] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.STORE] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.TAX] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.CURRENCY] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.PAYMENT] },
|
||||
{ resolve: MODULE_PACKAGE_NAMES[Modules.ORDER] },
|
||||
|
||||
{
|
||||
resolve: MODULE_PACKAGE_NAMES[Modules.AUTH],
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
@@ -96,15 +160,14 @@ export function defineConfig(
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
[Modules.USER]: {
|
||||
resolve: "@medusajs/user",
|
||||
{
|
||||
resolve: MODULE_PACKAGE_NAMES[Modules.USER],
|
||||
options: {
|
||||
jwt_secret: process.env.JWT_SECRET ?? DEFAULT_SECRET,
|
||||
},
|
||||
},
|
||||
[Modules.FILE]: {
|
||||
resolve: "@medusajs/file",
|
||||
{
|
||||
resolve: MODULE_PACKAGE_NAMES[Modules.FILE],
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
@@ -114,8 +177,8 @@ export function defineConfig(
|
||||
],
|
||||
},
|
||||
},
|
||||
[Modules.FULFILLMENT]: {
|
||||
resolve: "@medusajs/fulfillment",
|
||||
{
|
||||
resolve: MODULE_PACKAGE_NAMES[Modules.FULFILLMENT],
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
@@ -125,8 +188,8 @@ export function defineConfig(
|
||||
],
|
||||
},
|
||||
},
|
||||
[Modules.NOTIFICATION]: {
|
||||
resolve: "@medusajs/notification",
|
||||
{
|
||||
resolve: MODULE_PACKAGE_NAMES[Modules.NOTIFICATION],
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
@@ -140,21 +203,95 @@ export function defineConfig(
|
||||
],
|
||||
},
|
||||
},
|
||||
...config.modules,
|
||||
]
|
||||
|
||||
/**
|
||||
* Backward compatibility for the old way of defining modules (object vs array)
|
||||
*/
|
||||
if (configModules) {
|
||||
if (isObject(configModules)) {
|
||||
const modules_ = (configModules ??
|
||||
{}) as unknown as Required<ConfigModule>["modules"]
|
||||
|
||||
Object.entries(modules_).forEach(([key, moduleConfig]) => {
|
||||
modules.push({
|
||||
key,
|
||||
...(isObject(moduleConfig)
|
||||
? moduleConfig
|
||||
: { disable: !moduleConfig }),
|
||||
})
|
||||
})
|
||||
} else if (Array.isArray(configModules)) {
|
||||
const modules_ = (configModules ?? []) as InternalModuleDeclaration[]
|
||||
modules.push(...modules_)
|
||||
} else {
|
||||
throw new Error(
|
||||
"Invalid modules configuration. Should be an array or object."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const remappedModules = modules.reduce((acc, moduleConfig) => {
|
||||
if (moduleConfig.scope === "external" && !moduleConfig.key) {
|
||||
throw new Error(
|
||||
"External modules configuration must have a 'key'. Please provide a key for the module."
|
||||
)
|
||||
}
|
||||
|
||||
if ("disable" in moduleConfig && "key" in moduleConfig) {
|
||||
acc[moduleConfig.key!] = moduleConfig
|
||||
}
|
||||
|
||||
// TODO: handle external modules later
|
||||
let serviceName: string =
|
||||
"key" in moduleConfig && moduleConfig.key ? moduleConfig.key : ""
|
||||
delete moduleConfig.key
|
||||
|
||||
if (!serviceName && "resolve" in moduleConfig) {
|
||||
if (
|
||||
isString(moduleConfig.resolve!) &&
|
||||
REVERSED_MODULE_PACKAGE_NAMES[moduleConfig.resolve!]
|
||||
) {
|
||||
serviceName = REVERSED_MODULE_PACKAGE_NAMES[moduleConfig.resolve!]
|
||||
acc[serviceName] = moduleConfig
|
||||
return acc
|
||||
}
|
||||
|
||||
let resolution = isString(moduleConfig.resolve!)
|
||||
? normalizeImportPathWithSource(moduleConfig.resolve as string)
|
||||
: moduleConfig.resolve
|
||||
|
||||
const moduleExport = isString(resolution)
|
||||
? require(resolution)
|
||||
: resolution
|
||||
|
||||
const defaultExport = resolveExports(moduleExport).default
|
||||
|
||||
const joinerConfig =
|
||||
typeof defaultExport.service.prototype.__joinerConfig === "function"
|
||||
? defaultExport.service.prototype.__joinerConfig() ?? {}
|
||||
: defaultExport.service.prototype.__joinerConfig ?? {}
|
||||
|
||||
serviceName = joinerConfig.serviceName
|
||||
|
||||
if (!serviceName) {
|
||||
throw new Error(
|
||||
`Module ${moduleConfig.resolve} doesn't have a serviceName. Please provide a 'key' for the module or check the service joiner config.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
acc[serviceName] = moduleConfig
|
||||
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
// Remove any modules set to false
|
||||
Object.keys(modules).forEach((key) => {
|
||||
if (modules[key] === false) {
|
||||
delete modules[key]
|
||||
Object.keys(remappedModules).forEach((key) => {
|
||||
if (remappedModules[key].disable) {
|
||||
delete remappedModules[key]
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
projectConfig,
|
||||
featureFlags,
|
||||
plugins: config.plugins || [],
|
||||
admin,
|
||||
modules,
|
||||
}
|
||||
return remappedModules as ConfigModule["modules"]
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("MessageAggregator", function () {
|
||||
aggregator.save({
|
||||
name: "ProductVariant.created",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "created",
|
||||
object: "ProductVariant",
|
||||
eventGroupId: "1",
|
||||
@@ -20,7 +20,7 @@ describe("MessageAggregator", function () {
|
||||
aggregator.save({
|
||||
name: "Product.created",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "created",
|
||||
object: "Product",
|
||||
eventGroupId: "1",
|
||||
@@ -30,7 +30,7 @@ describe("MessageAggregator", function () {
|
||||
aggregator.save({
|
||||
name: "ProductVariant.created",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "created",
|
||||
object: "ProductVariant",
|
||||
eventGroupId: "1",
|
||||
@@ -40,7 +40,7 @@ describe("MessageAggregator", function () {
|
||||
aggregator.save({
|
||||
name: "ProductType.detached",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "detached",
|
||||
object: "ProductType",
|
||||
eventGroupId: "1",
|
||||
@@ -50,7 +50,7 @@ describe("MessageAggregator", function () {
|
||||
aggregator.save({
|
||||
name: "ProductVariant.updated",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "updated",
|
||||
object: "ProductVariant",
|
||||
eventGroupId: "1",
|
||||
@@ -76,7 +76,7 @@ describe("MessageAggregator", function () {
|
||||
{
|
||||
name: "ProductType.detached",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "detached",
|
||||
object: "ProductType",
|
||||
eventGroupId: "1",
|
||||
@@ -89,7 +89,7 @@ describe("MessageAggregator", function () {
|
||||
{
|
||||
name: "ProductVariant.updated",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "updated",
|
||||
object: "ProductVariant",
|
||||
eventGroupId: "1",
|
||||
@@ -102,7 +102,7 @@ describe("MessageAggregator", function () {
|
||||
{
|
||||
name: "ProductVariant.created",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "created",
|
||||
object: "ProductVariant",
|
||||
eventGroupId: "1",
|
||||
@@ -112,7 +112,7 @@ describe("MessageAggregator", function () {
|
||||
{
|
||||
name: "ProductVariant.created",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "created",
|
||||
object: "ProductVariant",
|
||||
eventGroupId: "1",
|
||||
@@ -125,7 +125,7 @@ describe("MessageAggregator", function () {
|
||||
{
|
||||
name: "Product.created",
|
||||
metadata: {
|
||||
source: "Product",
|
||||
source: "product",
|
||||
action: "created",
|
||||
object: "Product",
|
||||
eventGroupId: "1",
|
||||
|
||||
@@ -1,31 +1,66 @@
|
||||
export const Modules = {
|
||||
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",
|
||||
INDEX: "Index",
|
||||
AUTH: "auth",
|
||||
CACHE: "cache",
|
||||
CART: "cart",
|
||||
CUSTOMER: "customer",
|
||||
EVENT_BUS: "event_bus",
|
||||
INVENTORY: "inventory",
|
||||
LINK: "link_modules",
|
||||
PAYMENT: "payment",
|
||||
PRICING: "pricing",
|
||||
PRODUCT: "product",
|
||||
PROMOTION: "promotion",
|
||||
SALES_CHANNEL: "sales_channel",
|
||||
TAX: "tax",
|
||||
FULFILLMENT: "fulfillment",
|
||||
STOCK_LOCATION: "stock_location",
|
||||
USER: "user",
|
||||
WORKFLOW_ENGINE: "workflows",
|
||||
REGION: "region",
|
||||
ORDER: "order",
|
||||
API_KEY: "api_key",
|
||||
STORE: "store",
|
||||
CURRENCY: "currency",
|
||||
FILE: "file",
|
||||
NOTIFICATION: "notification",
|
||||
INDEX: "index",
|
||||
} as const
|
||||
|
||||
export const MODULE_PACKAGE_NAMES = {
|
||||
[Modules.AUTH]: "@medusajs/medusa/auth",
|
||||
[Modules.CACHE]: "@medusajs/medusa/cache-inmemory",
|
||||
[Modules.CART]: "@medusajs/medusa/cart",
|
||||
[Modules.CUSTOMER]: "@medusajs/medusa/customer",
|
||||
[Modules.EVENT_BUS]: "@medusajs/medusa/event-bus-local",
|
||||
[Modules.INVENTORY]: "@medusajs/medusa/inventory-next", // TODO: To be replaced when current `@medusajs/inventory` is deprecated
|
||||
[Modules.LINK]: "@medusajs/medusa/link-modules",
|
||||
[Modules.PAYMENT]: "@medusajs/medusa/payment",
|
||||
[Modules.PRICING]: "@medusajs/medusa/pricing",
|
||||
[Modules.PRODUCT]: "@medusajs/medusa/product",
|
||||
[Modules.PROMOTION]: "@medusajs/medusa/promotion",
|
||||
[Modules.SALES_CHANNEL]: "@medusajs/medusa/sales-channel",
|
||||
[Modules.FULFILLMENT]: "@medusajs/medusa/fulfillment",
|
||||
[Modules.STOCK_LOCATION]: "@medusajs/medusa/stock-location-next", // TODO: To be replaced when current `@medusajs/stock-location` is deprecated
|
||||
[Modules.TAX]: "@medusajs/medusa/tax",
|
||||
[Modules.USER]: "@medusajs/medusa/user",
|
||||
[Modules.WORKFLOW_ENGINE]: "@medusajs/medusa/workflow-engine-inmemory",
|
||||
[Modules.REGION]: "@medusajs/medusa/region",
|
||||
[Modules.ORDER]: "@medusajs/medusa/order",
|
||||
[Modules.API_KEY]: "@medusajs/medusa/api-key",
|
||||
[Modules.STORE]: "@medusajs/medusa/store",
|
||||
[Modules.CURRENCY]: "@medusajs/medusa/currency",
|
||||
[Modules.FILE]: "@medusajs/medusa/file",
|
||||
[Modules.NOTIFICATION]: "@medusajs/medusa/notification",
|
||||
[Modules.INDEX]: "@medusajs/medusa/index-module",
|
||||
}
|
||||
|
||||
export const REVERSED_MODULE_PACKAGE_NAMES = Object.entries(
|
||||
MODULE_PACKAGE_NAMES
|
||||
).reduce((acc, [key, value]) => {
|
||||
acc[value] = key
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
/**
|
||||
* Making modules be referenced as a type as well.
|
||||
*/
|
||||
|
||||
@@ -56,7 +56,7 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
|
||||
linkable: "api_key_id",
|
||||
entity: "ApiKey",
|
||||
primaryKey: "id",
|
||||
serviceName: "ApiKey",
|
||||
serviceName: "api_key",
|
||||
field: "apiKey",
|
||||
},
|
||||
publishable_key_id: {
|
||||
@@ -64,7 +64,7 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
|
||||
entity: "ApiKey",
|
||||
linkable: "publishable_key_id",
|
||||
primaryKey: "publishable_key_id",
|
||||
serviceName: "ApiKey",
|
||||
serviceName: "api_key",
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -26,7 +26,7 @@ moduleIntegrationTestRunner<ICurrencyModuleService>({
|
||||
linkable: "currency_code",
|
||||
entity: "Currency",
|
||||
primaryKey: "code",
|
||||
serviceName: "Currency",
|
||||
serviceName: "currency",
|
||||
field: "currency",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -137,7 +137,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "fulfillment_address_id",
|
||||
entity: "FulfillmentAddress",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentAddress",
|
||||
},
|
||||
},
|
||||
@@ -146,7 +146,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "fulfillment_item_id",
|
||||
entity: "FulfillmentItem",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentItem",
|
||||
},
|
||||
},
|
||||
@@ -155,7 +155,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "fulfillment_label_id",
|
||||
entity: "FulfillmentLabel",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentLabel",
|
||||
},
|
||||
},
|
||||
@@ -164,7 +164,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "fulfillment_provider_id",
|
||||
entity: "FulfillmentProvider",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentProvider",
|
||||
},
|
||||
},
|
||||
@@ -173,7 +173,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "fulfillment_set_id",
|
||||
entity: "FulfillmentSet",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentSet",
|
||||
},
|
||||
},
|
||||
@@ -182,7 +182,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "fulfillment_id",
|
||||
entity: "Fulfillment",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillment",
|
||||
},
|
||||
},
|
||||
@@ -191,7 +191,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "geo_zone_id",
|
||||
entity: "GeoZone",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "geoZone",
|
||||
},
|
||||
},
|
||||
@@ -200,7 +200,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "service_zone_id",
|
||||
entity: "ServiceZone",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "serviceZone",
|
||||
},
|
||||
},
|
||||
@@ -209,7 +209,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "shipping_option_rule_id",
|
||||
entity: "ShippingOptionRule",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingOptionRule",
|
||||
},
|
||||
},
|
||||
@@ -218,7 +218,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "shipping_option_type_id",
|
||||
entity: "ShippingOptionType",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingOptionType",
|
||||
},
|
||||
},
|
||||
@@ -227,7 +227,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "shipping_option_id",
|
||||
entity: "ShippingOption",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingOption",
|
||||
},
|
||||
},
|
||||
@@ -236,7 +236,7 @@ moduleIntegrationTestRunner({
|
||||
linkable: "shipping_profile_id",
|
||||
entity: "ShippingProfile",
|
||||
primaryKey: "id",
|
||||
serviceName: "Fulfillment",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingProfile",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
import { Modules } from "@medusajs/utils"
|
||||
|
||||
export const defaultSchema = `
|
||||
type Product @Listeners(values: ["Product.product.created", "Product.product.updated", "Product.product.deleted"]) {
|
||||
type Product @Listeners(values: ["${Modules.PRODUCT}.product.created", "${Modules.PRODUCT}.product.updated", "${Modules.PRODUCT}.product.deleted"]) {
|
||||
id: String
|
||||
title: String
|
||||
variants: [ProductVariant]
|
||||
}
|
||||
|
||||
type ProductVariant @Listeners(values: ["Product.product-variant.created", "Product.product-variant.updated", "Product.product-variant.deleted"]) {
|
||||
type ProductVariant @Listeners(values: ["${Modules.PRODUCT}.product-variant.created", "${Modules.PRODUCT}.product-variant.updated", "${Modules.PRODUCT}.product-variant.deleted"]) {
|
||||
id: String
|
||||
product_id: String
|
||||
sku: String
|
||||
prices: [Price]
|
||||
}
|
||||
|
||||
type Price @Listeners(values: ["Pricing.price.created", "Pricing.price.updated", "Pricing.price.deleted"]) {
|
||||
type Price @Listeners(values: ["${Modules.PRICING}.price.created", "${Modules.PRICING}.price.updated", "${Modules.PRICING}.price.deleted"]) {
|
||||
amount: Int
|
||||
currency_code: String
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ moduleIntegrationTestRunner<IInventoryService>({
|
||||
entity: "InventoryItem",
|
||||
linkable: "inventory_item_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "Inventory",
|
||||
serviceName: "inventory",
|
||||
},
|
||||
},
|
||||
inventoryLevel: {
|
||||
@@ -40,7 +40,7 @@ moduleIntegrationTestRunner<IInventoryService>({
|
||||
entity: "InventoryLevel",
|
||||
linkable: "inventory_level_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "Inventory",
|
||||
serviceName: "inventory",
|
||||
},
|
||||
},
|
||||
reservationItem: {
|
||||
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner<IInventoryService>({
|
||||
entity: "ReservationItem",
|
||||
linkable: "reservation_item_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "Inventory",
|
||||
serviceName: "inventory",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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: "Pricing",
|
||||
serviceName: "pricing",
|
||||
field: "priceSet",
|
||||
},
|
||||
},
|
||||
@@ -38,7 +38,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
|
||||
linkable: "price_list_id",
|
||||
entity: "PriceList",
|
||||
primaryKey: "id",
|
||||
serviceName: "Pricing",
|
||||
serviceName: "pricing",
|
||||
field: "priceList",
|
||||
},
|
||||
},
|
||||
@@ -47,7 +47,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
|
||||
linkable: "price_id",
|
||||
entity: "Price",
|
||||
primaryKey: "id",
|
||||
serviceName: "Pricing",
|
||||
serviceName: "pricing",
|
||||
field: "price",
|
||||
},
|
||||
},
|
||||
@@ -56,7 +56,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
|
||||
linkable: "price_preference_id",
|
||||
entity: "PricePreference",
|
||||
primaryKey: "id",
|
||||
serviceName: "Pricing",
|
||||
serviceName: "pricing",
|
||||
field: "pricePreference",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -692,7 +692,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
[
|
||||
expect.objectContaining({
|
||||
data: { id: productCategoryOne.id },
|
||||
name: "Product.product-category.deleted",
|
||||
name: "product.product-category.deleted",
|
||||
metadata: {
|
||||
action: CommonEvents.DELETED,
|
||||
object: "product_category",
|
||||
|
||||
@@ -281,7 +281,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
expect(eventBusSpy).toHaveBeenCalledWith(
|
||||
[
|
||||
{
|
||||
name: "Product.product-collection.deleted",
|
||||
name: "product.product-collection.deleted",
|
||||
data: { id: collectionId },
|
||||
metadata: {
|
||||
action: CommonEvents.DELETED,
|
||||
|
||||
@@ -72,7 +72,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_id",
|
||||
entity: "Product",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "product",
|
||||
},
|
||||
},
|
||||
@@ -81,7 +81,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_variant_id",
|
||||
entity: "ProductVariant",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "productVariant",
|
||||
},
|
||||
variant_id: {
|
||||
@@ -89,7 +89,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
entity: "ProductVariant",
|
||||
linkable: "variant_id",
|
||||
primaryKey: "variant_id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
},
|
||||
},
|
||||
productOption: {
|
||||
@@ -97,7 +97,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_option_id",
|
||||
entity: "ProductOption",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "productOption",
|
||||
},
|
||||
},
|
||||
@@ -106,7 +106,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_type_id",
|
||||
entity: "ProductType",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "productType",
|
||||
},
|
||||
},
|
||||
@@ -115,7 +115,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_image_id",
|
||||
entity: "ProductImage",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "productImage",
|
||||
},
|
||||
},
|
||||
@@ -124,7 +124,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_tag_id",
|
||||
entity: "ProductTag",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "productTag",
|
||||
},
|
||||
},
|
||||
@@ -133,7 +133,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_collection_id",
|
||||
entity: "ProductCollection",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "productCollection",
|
||||
},
|
||||
},
|
||||
@@ -142,7 +142,7 @@ moduleIntegrationTestRunner<Service>({
|
||||
linkable: "product_category_id",
|
||||
entity: "ProductCategory",
|
||||
primaryKey: "id",
|
||||
serviceName: "Product",
|
||||
serviceName: "product",
|
||||
field: "productCategory",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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: "sales_channel",
|
||||
field: "salesChannel",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -30,7 +30,7 @@ moduleIntegrationTestRunner<IStockLocationService>({
|
||||
linkable: "stock_location_address_id",
|
||||
entity: "StockLocationAddress",
|
||||
primaryKey: "id",
|
||||
serviceName: "StockLocation",
|
||||
serviceName: "stock_location",
|
||||
field: "stockLocationAddress",
|
||||
},
|
||||
},
|
||||
@@ -40,13 +40,13 @@ moduleIntegrationTestRunner<IStockLocationService>({
|
||||
entity: "StockLocation",
|
||||
linkable: "stock_location_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "StockLocation",
|
||||
serviceName: "stock_location",
|
||||
},
|
||||
location_id: {
|
||||
linkable: "location_id",
|
||||
entity: "StockLocation",
|
||||
primaryKey: "location_id",
|
||||
serviceName: "StockLocation",
|
||||
serviceName: "stock_location",
|
||||
field: "stockLocation",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -57,7 +57,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
|
||||
linkable: "workflow_execution_id",
|
||||
entity: "WorkflowExecution",
|
||||
primaryKey: "id",
|
||||
serviceName: "Workflows",
|
||||
serviceName: "workflows",
|
||||
field: "workflowExecution",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -83,7 +83,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
|
||||
linkable: "workflow_execution_id",
|
||||
entity: "WorkflowExecution",
|
||||
primaryKey: "id",
|
||||
serviceName: "Workflows",
|
||||
serviceName: "workflows",
|
||||
field: "workflowExecution",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user