feat: Flatten the provider config for all modules (#7930)
This commit is contained in:
@@ -22,6 +22,7 @@ describe("modules loader", () => {
|
||||
const moduleProviders = [
|
||||
{
|
||||
resolve: "@providers/default",
|
||||
id: "default",
|
||||
options: {},
|
||||
},
|
||||
]
|
||||
@@ -47,6 +48,7 @@ describe("modules loader", () => {
|
||||
const moduleProviders = [
|
||||
{
|
||||
resolve: "@providers/default",
|
||||
id: "default",
|
||||
options: {},
|
||||
},
|
||||
]
|
||||
@@ -66,6 +68,7 @@ describe("modules loader", () => {
|
||||
const moduleProviders = [
|
||||
{
|
||||
resolve: "@providers/no-service",
|
||||
id: "default",
|
||||
options: {},
|
||||
},
|
||||
]
|
||||
@@ -83,6 +86,7 @@ describe("modules loader", () => {
|
||||
const moduleProviders = [
|
||||
{
|
||||
resolve: "@providers/no-default",
|
||||
id: "default",
|
||||
options: {},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -32,8 +32,7 @@ export async function loadModuleProvider(
|
||||
registerServiceFn?: (klass, container, moduleDetails) => Promise<void>
|
||||
) {
|
||||
let loadedProvider: any
|
||||
|
||||
const moduleName = provider.resolve ?? provider.provider_name ?? ""
|
||||
const moduleName = provider.resolve ?? ""
|
||||
|
||||
try {
|
||||
loadedProvider = provider.resolve
|
||||
@@ -60,7 +59,10 @@ export async function loadModuleProvider(
|
||||
const name = lowerCaseFirst(service.name)
|
||||
if (registerServiceFn) {
|
||||
// Used to register the specific type of service in the provider
|
||||
await registerServiceFn(service, container, provider.options)
|
||||
await registerServiceFn(service, container, {
|
||||
id: provider.id,
|
||||
options: provider.options,
|
||||
})
|
||||
} else {
|
||||
container.register({
|
||||
[name]: asFunction(
|
||||
|
||||
@@ -6,6 +6,6 @@ export type ModuleProviderExports = {
|
||||
|
||||
export type ModuleProvider = {
|
||||
resolve: string | ModuleProviderExports
|
||||
provider_name?: string
|
||||
options: Record<string, unknown>
|
||||
id: string
|
||||
options?: Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -21,11 +21,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/file-local-next",
|
||||
},
|
||||
],
|
||||
@@ -36,11 +32,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"manual": {},
|
||||
},
|
||||
},
|
||||
"id": "manual",
|
||||
"resolve": "@medusajs/fulfillment-manual",
|
||||
},
|
||||
],
|
||||
@@ -52,11 +44,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/notification-local",
|
||||
},
|
||||
],
|
||||
@@ -123,11 +111,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/file-local-next",
|
||||
},
|
||||
],
|
||||
@@ -138,11 +122,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"manual": {},
|
||||
},
|
||||
},
|
||||
"id": "manual",
|
||||
"resolve": "@medusajs/fulfillment-manual",
|
||||
},
|
||||
],
|
||||
@@ -157,11 +137,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/notification-local",
|
||||
},
|
||||
],
|
||||
@@ -228,11 +204,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/file-local-next",
|
||||
},
|
||||
],
|
||||
@@ -243,11 +215,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"manual": {},
|
||||
},
|
||||
},
|
||||
"id": "manual",
|
||||
"resolve": "@medusajs/fulfillment-manual",
|
||||
},
|
||||
],
|
||||
@@ -259,11 +227,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/notification-local",
|
||||
},
|
||||
],
|
||||
@@ -332,11 +296,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/file-local-next",
|
||||
},
|
||||
],
|
||||
@@ -347,11 +307,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"manual": {},
|
||||
},
|
||||
},
|
||||
"id": "manual",
|
||||
"resolve": "@medusajs/fulfillment-manual",
|
||||
},
|
||||
],
|
||||
@@ -363,11 +319,7 @@ describe("defineConfig", function () {
|
||||
"options": {
|
||||
"providers": [
|
||||
{
|
||||
"options": {
|
||||
"config": {
|
||||
"local": {},
|
||||
},
|
||||
},
|
||||
"id": "local",
|
||||
"resolve": "@medusajs/notification-local",
|
||||
},
|
||||
],
|
||||
|
||||
@@ -90,11 +90,7 @@ export function defineConfig(config: Partial<ConfigModule> = {}): ConfigModule {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/file-local-next",
|
||||
options: {
|
||||
config: {
|
||||
local: {},
|
||||
},
|
||||
},
|
||||
id: "local",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -105,11 +101,7 @@ export function defineConfig(config: Partial<ConfigModule> = {}): ConfigModule {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/fulfillment-manual",
|
||||
options: {
|
||||
config: {
|
||||
manual: {},
|
||||
},
|
||||
},
|
||||
id: "manual",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -120,11 +112,7 @@ export function defineConfig(config: Partial<ConfigModule> = {}): ConfigModule {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/notification-local",
|
||||
options: {
|
||||
config: {
|
||||
local: {},
|
||||
},
|
||||
},
|
||||
id: "local",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user