chore: make module loaders DML aware and auto generate joiner config (#7781)
* chore: make module loaders DML aware and auto generate joiner config * fixes and cleanup * improve dml entity check * add unit tests on load resources * cleanup deps * cleanup deps * cleanup Modules * finalise * fix modules-sdk jest * fix modules-sdk jest * fix import * fix import
This commit is contained in:
1 parent
03924a4ff6
commit
937a632eb6
191 files changed
+1105
-613
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
const { Modules } = require("@medusajs/modules-sdk")
|
const { Modules } = require("@medusajs/utils")
|
||||||
|
|
||||||
const DB_HOST = process.env.DB_HOST
|
const DB_HOST = process.env.DB_HOST
|
||||||
const DB_USERNAME = process.env.DB_USERNAME
|
const DB_USERNAME = process.env.DB_USERNAME
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
LinkModuleUtils,
|
LinkModuleUtils,
|
||||||
ModuleRegistrationName,
|
ModuleRegistrationName,
|
||||||
Modules,
|
|
||||||
RemoteLink,
|
RemoteLink,
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import { ICartModuleService, IPromotionModuleService } from "@medusajs/types"
|
import { ICartModuleService, IPromotionModuleService } from "@medusajs/types"
|
||||||
import { PromotionType } from "@medusajs/utils"
|
import { Modules, PromotionType } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
adminHeaders,
|
adminHeaders,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
updateLineItemsStepId,
|
updateLineItemsStepId,
|
||||||
updatePaymentCollectionStepId,
|
updatePaymentCollectionStepId,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
ICartModuleService,
|
ICartModuleService,
|
||||||
ICustomerModuleService,
|
ICustomerModuleService,
|
||||||
@@ -26,7 +26,11 @@ import {
|
|||||||
ISalesChannelModuleService,
|
ISalesChannelModuleService,
|
||||||
IStockLocationService,
|
IStockLocationService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { ContainerRegistrationKeys, RuleOperator } from "@medusajs/utils"
|
import {
|
||||||
|
ContainerRegistrationKeys,
|
||||||
|
Modules,
|
||||||
|
RuleOperator,
|
||||||
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
adminHeaders,
|
adminHeaders,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
LinkModuleUtils,
|
LinkModuleUtils,
|
||||||
ModuleRegistrationName,
|
ModuleRegistrationName,
|
||||||
Modules,
|
|
||||||
RemoteLink,
|
RemoteLink,
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import PaymentModuleService from "@medusajs/payment/dist/services/payment-module"
|
import PaymentModuleService from "@medusajs/payment/dist/services/payment-module"
|
||||||
@@ -22,6 +21,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
|
Modules,
|
||||||
ProductStatus,
|
ProductStatus,
|
||||||
PromotionRuleOperator,
|
PromotionRuleOperator,
|
||||||
PromotionType,
|
PromotionType,
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
LinkModuleUtils,
|
LinkModuleUtils,
|
||||||
ModuleRegistrationName,
|
ModuleRegistrationName,
|
||||||
Modules,
|
|
||||||
RemoteLink,
|
RemoteLink,
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import { ICartModuleService, IPromotionModuleService } from "@medusajs/types"
|
import { ICartModuleService, IPromotionModuleService } from "@medusajs/types"
|
||||||
import { PromotionType } from "@medusajs/utils"
|
import { Modules, PromotionType } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
adminHeaders,
|
adminHeaders,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
ICartModuleService,
|
ICartModuleService,
|
||||||
ICustomerModuleService,
|
ICustomerModuleService,
|
||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
ISalesChannelModuleService,
|
ISalesChannelModuleService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
IFulfillmentModuleService,
|
IFulfillmentModuleService,
|
||||||
IStockLocationService,
|
IStockLocationService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
Modules,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { IPricingModuleService, IProductModuleService } from "@medusajs/types"
|
import { IPricingModuleService, IProductModuleService } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
Modules,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
IApiKeyModuleService,
|
IApiKeyModuleService,
|
||||||
ISalesChannelModuleService,
|
ISalesChannelModuleService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { remoteQueryObjectFromString } from "@medusajs/utils"
|
import { Modules, remoteQueryObjectFromString } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { IRegionModuleService } from "@medusajs/types"
|
import { IRegionModuleService } from "@medusajs/types"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
ISalesChannelModuleService,
|
ISalesChannelModuleService,
|
||||||
IStockLocationService,
|
IStockLocationService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { remoteQueryObjectFromString } from "@medusajs/utils"
|
import { Modules, remoteQueryObjectFromString } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
IFulfillmentModuleService,
|
IFulfillmentModuleService,
|
||||||
IPricingModuleService,
|
IPricingModuleService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { MedusaApp, Modules } from "@medusajs/modules-sdk"
|
import { MedusaApp } from "@medusajs/modules-sdk"
|
||||||
import { IProductModuleService } from "@medusajs/types"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { IRegionModuleService } from "@medusajs/types"
|
import { IRegionModuleService } from "@medusajs/types"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { createAdminUser } from "../../..//helpers/create-admin-user"
|
import { createAdminUser } from "../../..//helpers/create-admin-user"
|
||||||
import { adminHeaders } from "../../../helpers/create-admin-user"
|
import { adminHeaders } from "../../../helpers/create-admin-user"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
ICartModuleService,
|
ICartModuleService,
|
||||||
IFulfillmentModuleService,
|
IFulfillmentModuleService,
|
||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
IStockLocationServiceNext,
|
IStockLocationServiceNext,
|
||||||
ITaxModuleService,
|
ITaxModuleService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
adminHeaders,
|
adminHeaders,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
createOrderFulfillmentWorkflow,
|
createOrderFulfillmentWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
Modules,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
createOrderFulfillmentWorkflow,
|
createOrderFulfillmentWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
Modules,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||||
|
|||||||
@@ -2,11 +2,7 @@ import {
|
|||||||
createReturnOrderWorkflow,
|
createReturnOrderWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import {
|
import { ModuleRegistrationName, RemoteLink } from "@medusajs/modules-sdk"
|
||||||
ModuleRegistrationName,
|
|
||||||
Modules,
|
|
||||||
RemoteLink,
|
|
||||||
} from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
FulfillmentSetDTO,
|
FulfillmentSetDTO,
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
@@ -21,6 +17,7 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
Modules,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
RuleOperator,
|
RuleOperator,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
createOrderShipmentWorkflow,
|
createOrderShipmentWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
Modules,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
RuleOperator,
|
RuleOperator,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|||||||
@@ -2,13 +2,10 @@ import {
|
|||||||
capturePaymentWorkflow,
|
capturePaymentWorkflow,
|
||||||
refundPaymentWorkflow,
|
refundPaymentWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import {
|
import { LinkModuleUtils, ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
LinkModuleUtils,
|
|
||||||
ModuleRegistrationName,
|
|
||||||
Modules,
|
|
||||||
} from "@medusajs/modules-sdk"
|
|
||||||
import { IPaymentModuleService, IRegionModuleService } from "@medusajs/types"
|
import { IPaymentModuleService, IRegionModuleService } from "@medusajs/types"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
IFulfillmentModuleService,
|
IFulfillmentModuleService,
|
||||||
IRegionModuleService,
|
IRegionModuleService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { CreateCustomerDTO, MedusaContainer } from "@medusajs/types"
|
import { CreateCustomerDTO, MedusaContainer } from "@medusajs/types"
|
||||||
|
|
||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import jwt from "jsonwebtoken"
|
import jwt from "jsonwebtoken"
|
||||||
|
|
||||||
export const createAuthenticatedCustomer = async (
|
export const createAuthenticatedCustomer = async (
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { MedusaContainer, Modules } from "@medusajs/modules-sdk"
|
import { MedusaContainer } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
CreatePriceSetDTO,
|
CreatePriceSetDTO,
|
||||||
IPricingModuleService,
|
IPricingModuleService,
|
||||||
PriceSetDTO,
|
PriceSetDTO,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const defaultPrices = [
|
const defaultPrices = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { Modules } = require("@medusajs/modules-sdk")
|
const { Modules } = require("@medusajs/utils")
|
||||||
const { FulfillmentModuleOptions } = require("@medusajs/fulfillment")
|
const { FulfillmentModuleOptions } = require("@medusajs/fulfillment")
|
||||||
const DB_HOST = process.env.DB_HOST
|
const DB_HOST = process.env.DB_HOST
|
||||||
const DB_USERNAME = process.env.DB_USERNAME
|
const DB_USERNAME = process.env.DB_USERNAME
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { LinkWorkflowInput } from "@medusajs/types/src"
|
import { LinkWorkflowInput } from "@medusajs/types/src"
|
||||||
import { ContainerRegistrationKeys, promiseAll } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules, promiseAll } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const linkSalesChannelsToApiKeyStepId = "link-sales-channels-to-api-key"
|
export const linkSalesChannelsToApiKeyStepId = "link-sales-channels-to-api-key"
|
||||||
export const linkSalesChannelsToApiKeyStep = createStep(
|
export const linkSalesChannelsToApiKeyStep = createStep(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
|
||||||
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
|
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
|
||||||
import { deleteApiKeysStep } from "../steps"
|
import { deleteApiKeysStep } from "../steps"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
type WorkflowInput = { ids: string[] }
|
type WorkflowInput = { ids: string[] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|
||||||
|
|
||||||
type StepInput = {
|
type StepInput = {
|
||||||
links: {
|
links: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LinkModuleUtils, Modules } from "@medusajs/modules-sdk"
|
import { LinkModuleUtils } from "@medusajs/modules-sdk"
|
||||||
import { CartWorkflowDTO } from "@medusajs/types"
|
import { CartWorkflowDTO } from "@medusajs/types"
|
||||||
import { isObject, remoteQueryObjectFromString } from "@medusajs/utils"
|
import { isObject, Modules, remoteQueryObjectFromString } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
interface StepInput {
|
||||||
cart_or_cart_id: string | CartWorkflowDTO
|
cart_or_cart_id: string | CartWorkflowDTO
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import {
|
import { LinkModuleUtils, ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
LinkModuleUtils,
|
|
||||||
ModuleRegistrationName,
|
|
||||||
Modules,
|
|
||||||
} from "@medusajs/modules-sdk"
|
|
||||||
import { IPromotionModuleService } from "@medusajs/types"
|
import { IPromotionModuleService } from "@medusajs/types"
|
||||||
import { PromotionActions } from "@medusajs/utils"
|
import { Modules, PromotionActions } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
interface StepInput {
|
||||||
id: string
|
id: string
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||||
import { deleteFulfillmentSetsStep } from "../steps"
|
import { deleteFulfillmentSetsStep } from "../steps"
|
||||||
import { removeRemoteLinkStep } from "../../common"
|
import { removeRemoteLinkStep } from "../../common"
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const deleteFulfillmentSetsWorkflowId =
|
export const deleteFulfillmentSetsWorkflowId =
|
||||||
"delete-fulfillment-sets-workflow"
|
"delete-fulfillment-sets-workflow"
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import {
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
DeleteEntityInput,
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
ModuleRegistrationName,
|
|
||||||
Modules,
|
|
||||||
} from "@medusajs/modules-sdk"
|
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|
||||||
|
|
||||||
import { IInventoryService } from "@medusajs/types"
|
import { IInventoryService } from "@medusajs/types"
|
||||||
import { MedusaError } from "@medusajs/utils"
|
import { MedusaError } from "@medusajs/utils"
|
||||||
|
|||||||
+6
-3
@@ -1,6 +1,9 @@
|
|||||||
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
|
import {
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
ContainerRegistrationKeys,
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
MedusaError,
|
||||||
|
Modules,
|
||||||
|
} from "@medusajs/utils"
|
||||||
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const validateInventoryItemsForCreateStepId =
|
export const validateInventoryItemsForCreateStepId =
|
||||||
"validate-inventory-items-for-create-step"
|
"validate-inventory-items-for-create-step"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { deleteInventoryItemStep } from "../steps"
|
import { deleteInventoryItemStep } from "../steps"
|
||||||
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
|
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const deleteInventoryItemWorkflowId = "delete-inventory-item-workflow"
|
export const deleteInventoryItemWorkflowId = "delete-inventory-item-workflow"
|
||||||
export const deleteInventoryItemWorkflow = createWorkflow(
|
export const deleteInventoryItemWorkflow = createWorkflow(
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { FulfillmentDTO, OrderDTO, OrderWorkflow } from "@medusajs/types"
|
import { FulfillmentDTO, OrderDTO, OrderWorkflow } from "@medusajs/types"
|
||||||
import { MedusaError } from "@medusajs/utils"
|
import { MedusaError, Modules } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
|
||||||
createStep,
|
createStep,
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
parallelize,
|
parallelize,
|
||||||
transform,
|
transform,
|
||||||
|
WorkflowData,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { useRemoteQueryStep } from "../../common"
|
import { useRemoteQueryStep } from "../../common"
|
||||||
import { cancelFulfillmentWorkflow } from "../../fulfillment"
|
import { cancelFulfillmentWorkflow } from "../../fulfillment"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
FulfillmentDTO,
|
FulfillmentDTO,
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
@@ -6,13 +5,13 @@ import {
|
|||||||
OrderWorkflow,
|
OrderWorkflow,
|
||||||
ReservationItemDTO,
|
ReservationItemDTO,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { MedusaError } from "@medusajs/utils"
|
import { MedusaError, Modules } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
|
||||||
createStep,
|
createStep,
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
parallelize,
|
parallelize,
|
||||||
transform,
|
transform,
|
||||||
|
WorkflowData,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { createRemoteLinkStep, useRemoteQueryStep } from "../../common"
|
import { createRemoteLinkStep, useRemoteQueryStep } from "../../common"
|
||||||
import { createFulfillmentWorkflow } from "../../fulfillment"
|
import { createFulfillmentWorkflow } from "../../fulfillment"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
CreateOrderShippingMethodDTO,
|
CreateOrderShippingMethodDTO,
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
@@ -8,19 +7,20 @@ import {
|
|||||||
WithCalculatedPrice,
|
WithCalculatedPrice,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
|
arrayDifference,
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
isDefined,
|
||||||
MathBN,
|
MathBN,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
arrayDifference,
|
Modules,
|
||||||
isDefined,
|
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
|
||||||
createStep,
|
createStep,
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
parallelize,
|
parallelize,
|
||||||
transform,
|
transform,
|
||||||
|
WorkflowData,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { createRemoteLinkStep, useRemoteQueryStep } from "../../common"
|
import { createRemoteLinkStep, useRemoteQueryStep } from "../../common"
|
||||||
import { createReturnFulfillmentWorkflow } from "../../fulfillment"
|
import { createReturnFulfillmentWorkflow } from "../../fulfillment"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|
||||||
|
|
||||||
type StepInput = {
|
type StepInput = {
|
||||||
links: {
|
links: {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { IProductModuleService } from "@medusajs/types"
|
|
||||||
import {
|
import {
|
||||||
|
arrayDifference,
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
arrayDifference,
|
Modules,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type StepInput = {
|
type StepInput = {
|
||||||
ids: string[]
|
ids: string[]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { LinkDefinition, Modules } from "@medusajs/modules-sdk"
|
import { LinkDefinition } from "@medusajs/modules-sdk"
|
||||||
import { InventoryTypes, PricingTypes, ProductTypes } from "@medusajs/types"
|
import { InventoryTypes, PricingTypes, ProductTypes } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
WorkflowData,
|
||||||
@@ -11,6 +11,7 @@ import { createInventoryItemsWorkflow } from "../../inventory/workflows/create-i
|
|||||||
import { createPriceSetsStep } from "../../pricing"
|
import { createPriceSetsStep } from "../../pricing"
|
||||||
import { createProductVariantsStep } from "../steps/create-product-variants"
|
import { createProductVariantsStep } from "../steps/create-product-variants"
|
||||||
import { createVariantPricingLinkStep } from "../steps/create-variant-pricing-link"
|
import { createVariantPricingLinkStep } from "../steps/create-variant-pricing-link"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
// TODO: Create separate typings for the workflow input
|
// TODO: Create separate typings for the workflow input
|
||||||
type WorkflowInput = {
|
type WorkflowInput = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { deleteProductVariantsStep } from "../steps"
|
import { deleteProductVariantsStep } from "../steps"
|
||||||
import { removeRemoteLinkStep } from "../../common"
|
import { removeRemoteLinkStep } from "../../common"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
type WorkflowInput = { ids: string[] }
|
type WorkflowInput = { ids: string[] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
parallelize,
|
parallelize,
|
||||||
transform,
|
transform,
|
||||||
|
WorkflowData,
|
||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { removeRemoteLinkStep } from "../../common"
|
import { removeRemoteLinkStep } from "../../common"
|
||||||
import { deleteProductsStep } from "../steps/delete-products"
|
import { deleteProductsStep } from "../steps/delete-products"
|
||||||
import { getProductsStep } from "../steps/get-products"
|
import { getProductsStep } from "../steps/get-products"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
type WorkflowInput = { ids: string[] }
|
type WorkflowInput = { ids: string[] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { updateProductsStep } from "../steps/update-products"
|
import { updateProductsStep } from "../steps/update-products"
|
||||||
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { ProductTypes } from "@medusajs/types"
|
import { ProductTypes } from "@medusajs/types"
|
||||||
import { arrayDifference } from "@medusajs/utils"
|
import { arrayDifference, Modules } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
transform,
|
transform,
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
|
|
||||||
interface StepInput {
|
interface StepInput {
|
||||||
links: {
|
links: {
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import { Modules, RemoteLink } from "@medusajs/modules-sdk"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
|
||||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
interface StepInput {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Modules, RemoteLink } from "@medusajs/modules-sdk"
|
import { RemoteLink } from "@medusajs/modules-sdk"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
interface StepInput {
|
interface StepInput {
|
||||||
links: {
|
links: {
|
||||||
|
|||||||
+2
-3
@@ -1,6 +1,5 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|
||||||
|
|
||||||
interface StepInput {
|
interface StepInput {
|
||||||
links: {
|
links: {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { deleteSalesChannelsStep } from "../steps/delete-sales-channels"
|
import { deleteSalesChannelsStep } from "../steps/delete-sales-channels"
|
||||||
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
|
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
type WorkflowInput = { ids: string[] }
|
type WorkflowInput = { ids: string[] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
|
|
||||||
import { deleteShippingProfilesStep } from "../steps"
|
import { deleteShippingProfilesStep } from "../steps"
|
||||||
import { removeRemoteLinkStep } from "../../common"
|
import { removeRemoteLinkStep } from "../../common"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const deleteShippingProfileWorkflowId =
|
export const deleteShippingProfileWorkflowId =
|
||||||
"delete-shipping-profile-workflow"
|
"delete-shipping-profile-workflow"
|
||||||
|
|||||||
+2
-3
@@ -1,6 +1,5 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|
||||||
|
|
||||||
interface StepInput {
|
interface StepInput {
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
DeleteEntityInput,
|
DeleteEntityInput,
|
||||||
ModuleRegistrationName,
|
ModuleRegistrationName,
|
||||||
Modules,
|
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const deleteStockLocationsStepId = "delete-stock-locations-step"
|
export const deleteStockLocationsStepId = "delete-stock-locations-step"
|
||||||
export const deleteStockLocationsStep = createStep(
|
export const deleteStockLocationsStep = createStep(
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
transform: { "^.+\\.[jt]s?$": "@swc/jest" },
|
transform: {
|
||||||
|
"^.+\\.[jt]s?$": [
|
||||||
|
"@swc/jest",
|
||||||
|
{
|
||||||
|
jsc: {
|
||||||
|
parser: { syntax: "typescript", decorators: true },
|
||||||
|
transform: { decoratorMetadata: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
testEnvironment: `node`,
|
testEnvironment: `node`,
|
||||||
moduleFileExtensions: [`js`, `ts`],
|
moduleFileExtensions: [`js`, `ts`],
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/types": "^1.11.16",
|
"@medusajs/types": "^1.11.16",
|
||||||
|
"@mikro-orm/core": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"rimraf": "^5.0.1",
|
"rimraf": "^5.0.1",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ModuleDefinition } from "@medusajs/types"
|
import { ModuleDefinition } from "@medusajs/types"
|
||||||
import { upperCaseFirst } from "@medusajs/utils"
|
import { Modules, upperCaseFirst } from "@medusajs/utils"
|
||||||
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||||
|
|
||||||
export enum LinkModuleUtils {
|
export enum LinkModuleUtils {
|
||||||
@@ -7,34 +7,6 @@ export enum LinkModuleUtils {
|
|||||||
REMOTE_LINK = "remoteLink",
|
REMOTE_LINK = "remoteLink",
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this enum and use the one from @medusajs/utils
|
|
||||||
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",
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ModuleRegistrationName {
|
export enum ModuleRegistrationName {
|
||||||
AUTH = "authModuleService",
|
AUTH = "authModuleService",
|
||||||
CACHE = "cacheService",
|
CACHE = "cacheService",
|
||||||
@@ -88,305 +60,306 @@ export const MODULE_PACKAGE_NAMES = {
|
|||||||
[Modules.NOTIFICATION]: "@medusajs/notification",
|
[Modules.NOTIFICATION]: "@medusajs/notification",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ModulesDefinition: { [key: string | Modules]: ModuleDefinition } =
|
export const ModulesDefinition: {
|
||||||
{
|
[key: string]: ModuleDefinition
|
||||||
[Modules.EVENT_BUS]: {
|
} = {
|
||||||
key: Modules.EVENT_BUS,
|
[Modules.EVENT_BUS]: {
|
||||||
registrationName: ModuleRegistrationName.EVENT_BUS,
|
key: Modules.EVENT_BUS,
|
||||||
defaultPackage: MODULE_PACKAGE_NAMES[Modules.EVENT_BUS],
|
registrationName: ModuleRegistrationName.EVENT_BUS,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.EVENT_BUS),
|
defaultPackage: MODULE_PACKAGE_NAMES[Modules.EVENT_BUS],
|
||||||
isRequired: true,
|
label: upperCaseFirst(ModuleRegistrationName.EVENT_BUS),
|
||||||
dependencies: ["logger"],
|
isRequired: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.STOCK_LOCATION]: {
|
},
|
||||||
key: Modules.STOCK_LOCATION,
|
[Modules.STOCK_LOCATION]: {
|
||||||
registrationName: ModuleRegistrationName.STOCK_LOCATION,
|
key: Modules.STOCK_LOCATION,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.STOCK_LOCATION,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.STOCK_LOCATION),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.STOCK_LOCATION),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: [ModuleRegistrationName.EVENT_BUS],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: [ModuleRegistrationName.EVENT_BUS],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.INVENTORY]: {
|
},
|
||||||
key: Modules.INVENTORY,
|
[Modules.INVENTORY]: {
|
||||||
registrationName: ModuleRegistrationName.INVENTORY,
|
key: Modules.INVENTORY,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.INVENTORY,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.INVENTORY),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.INVENTORY),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: [ModuleRegistrationName.EVENT_BUS],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: [ModuleRegistrationName.EVENT_BUS],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.CACHE]: {
|
},
|
||||||
key: Modules.CACHE,
|
[Modules.CACHE]: {
|
||||||
registrationName: ModuleRegistrationName.CACHE,
|
key: Modules.CACHE,
|
||||||
defaultPackage: MODULE_PACKAGE_NAMES[Modules.CACHE],
|
registrationName: ModuleRegistrationName.CACHE,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.CACHE),
|
defaultPackage: MODULE_PACKAGE_NAMES[Modules.CACHE],
|
||||||
isRequired: true,
|
label: upperCaseFirst(ModuleRegistrationName.CACHE),
|
||||||
defaultModuleDeclaration: {
|
isRequired: true,
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.PRODUCT]: {
|
},
|
||||||
key: Modules.PRODUCT,
|
[Modules.PRODUCT]: {
|
||||||
registrationName: ModuleRegistrationName.PRODUCT,
|
key: Modules.PRODUCT,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.PRODUCT,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.PRODUCT),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.PRODUCT),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: [ModuleRegistrationName.EVENT_BUS, "logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: [ModuleRegistrationName.EVENT_BUS, "logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.PRICING]: {
|
},
|
||||||
key: Modules.PRICING,
|
[Modules.PRICING]: {
|
||||||
registrationName: ModuleRegistrationName.PRICING,
|
key: Modules.PRICING,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.PRICING,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.PRICING),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.PRICING),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: [ModuleRegistrationName.EVENT_BUS, "logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: [ModuleRegistrationName.EVENT_BUS, "logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.PROMOTION]: {
|
},
|
||||||
key: Modules.PROMOTION,
|
[Modules.PROMOTION]: {
|
||||||
registrationName: ModuleRegistrationName.PROMOTION,
|
key: Modules.PROMOTION,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.PROMOTION,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.PROMOTION),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.PROMOTION),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.AUTH]: {
|
},
|
||||||
key: Modules.AUTH,
|
[Modules.AUTH]: {
|
||||||
registrationName: ModuleRegistrationName.AUTH,
|
key: Modules.AUTH,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.AUTH,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.AUTH),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.AUTH),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.WORKFLOW_ENGINE]: {
|
},
|
||||||
key: Modules.WORKFLOW_ENGINE,
|
[Modules.WORKFLOW_ENGINE]: {
|
||||||
registrationName: ModuleRegistrationName.WORKFLOW_ENGINE,
|
key: Modules.WORKFLOW_ENGINE,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.WORKFLOW_ENGINE,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.WORKFLOW_ENGINE),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.WORKFLOW_ENGINE),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.SALES_CHANNEL]: {
|
},
|
||||||
key: Modules.SALES_CHANNEL,
|
[Modules.SALES_CHANNEL]: {
|
||||||
registrationName: ModuleRegistrationName.SALES_CHANNEL,
|
key: Modules.SALES_CHANNEL,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.SALES_CHANNEL,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.SALES_CHANNEL),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.SALES_CHANNEL),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.FULFILLMENT]: {
|
},
|
||||||
key: Modules.FULFILLMENT,
|
[Modules.FULFILLMENT]: {
|
||||||
registrationName: ModuleRegistrationName.FULFILLMENT,
|
key: Modules.FULFILLMENT,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.FULFILLMENT,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.FULFILLMENT),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.FULFILLMENT),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger", ModuleRegistrationName.EVENT_BUS],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger", ModuleRegistrationName.EVENT_BUS],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.CART]: {
|
},
|
||||||
key: Modules.CART,
|
[Modules.CART]: {
|
||||||
registrationName: ModuleRegistrationName.CART,
|
key: Modules.CART,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.CART,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.CART),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.CART),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.CUSTOMER]: {
|
},
|
||||||
key: Modules.CUSTOMER,
|
[Modules.CUSTOMER]: {
|
||||||
registrationName: ModuleRegistrationName.CUSTOMER,
|
key: Modules.CUSTOMER,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.CUSTOMER,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.CUSTOMER),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.CUSTOMER),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.PAYMENT]: {
|
},
|
||||||
key: Modules.PAYMENT,
|
[Modules.PAYMENT]: {
|
||||||
registrationName: ModuleRegistrationName.PAYMENT,
|
key: Modules.PAYMENT,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.PAYMENT,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.PAYMENT),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.PAYMENT),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.USER]: {
|
},
|
||||||
key: Modules.USER,
|
[Modules.USER]: {
|
||||||
registrationName: ModuleRegistrationName.USER,
|
key: Modules.USER,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.USER,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.USER),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.USER),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: [ModuleRegistrationName.EVENT_BUS, "logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: [ModuleRegistrationName.EVENT_BUS, "logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.REGION]: {
|
},
|
||||||
key: Modules.REGION,
|
[Modules.REGION]: {
|
||||||
registrationName: ModuleRegistrationName.REGION,
|
key: Modules.REGION,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.REGION,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.REGION),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.REGION),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.ORDER]: {
|
},
|
||||||
key: Modules.ORDER,
|
[Modules.ORDER]: {
|
||||||
registrationName: ModuleRegistrationName.ORDER,
|
key: Modules.ORDER,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.ORDER,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.ORDER),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.ORDER),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger", ModuleRegistrationName.EVENT_BUS],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger", ModuleRegistrationName.EVENT_BUS],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.TAX]: {
|
},
|
||||||
key: Modules.TAX,
|
[Modules.TAX]: {
|
||||||
registrationName: ModuleRegistrationName.TAX,
|
key: Modules.TAX,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.TAX,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.TAX),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.TAX),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger", ModuleRegistrationName.EVENT_BUS],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger", ModuleRegistrationName.EVENT_BUS],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.API_KEY]: {
|
},
|
||||||
key: Modules.API_KEY,
|
[Modules.API_KEY]: {
|
||||||
registrationName: ModuleRegistrationName.API_KEY,
|
key: Modules.API_KEY,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.API_KEY,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.API_KEY),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.API_KEY),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.STORE]: {
|
},
|
||||||
key: Modules.STORE,
|
[Modules.STORE]: {
|
||||||
registrationName: ModuleRegistrationName.STORE,
|
key: Modules.STORE,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.STORE,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.STORE),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.STORE),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.CURRENCY]: {
|
},
|
||||||
key: Modules.CURRENCY,
|
[Modules.CURRENCY]: {
|
||||||
registrationName: ModuleRegistrationName.CURRENCY,
|
key: Modules.CURRENCY,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.CURRENCY,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.CURRENCY),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.CURRENCY),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.FILE]: {
|
},
|
||||||
key: Modules.FILE,
|
[Modules.FILE]: {
|
||||||
registrationName: ModuleRegistrationName.FILE,
|
key: Modules.FILE,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.FILE,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.FILE),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.FILE),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
[Modules.NOTIFICATION]: {
|
},
|
||||||
key: Modules.NOTIFICATION,
|
[Modules.NOTIFICATION]: {
|
||||||
registrationName: ModuleRegistrationName.NOTIFICATION,
|
key: Modules.NOTIFICATION,
|
||||||
defaultPackage: false,
|
registrationName: ModuleRegistrationName.NOTIFICATION,
|
||||||
label: upperCaseFirst(ModuleRegistrationName.NOTIFICATION),
|
defaultPackage: false,
|
||||||
isRequired: false,
|
label: upperCaseFirst(ModuleRegistrationName.NOTIFICATION),
|
||||||
isQueryable: true,
|
isRequired: false,
|
||||||
dependencies: ["logger"],
|
isQueryable: true,
|
||||||
defaultModuleDeclaration: {
|
dependencies: ["logger"],
|
||||||
scope: MODULE_SCOPE.INTERNAL,
|
defaultModuleDeclaration: {
|
||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
},
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
export const MODULE_DEFINITIONS: ModuleDefinition[] =
|
export const MODULE_DEFINITIONS: ModuleDefinition[] =
|
||||||
Object.values(ModulesDefinition)
|
Object.values(ModulesDefinition)
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export * as ModuleWithDmlMixedWithoutJoinerConfigFixtures from "./module-with-dml-mixed-without-joiner-config"
|
||||||
|
export * as ModuleWithDmlWithoutJoinerConfigFixtures from "./module-with-dml-without-joiner-config"
|
||||||
|
export * as ModuleWithoutJoinerConfigFixtures from "./module-without-joiner-config"
|
||||||
|
export * as ModuleWithJoinerConfigFixtures from "./module-with-joiner-config"
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
import { ModuleExports } from "@medusajs/types"
|
||||||
|
import { ModuleService } from "./services/module-service"
|
||||||
|
|
||||||
|
const moduleExports: ModuleExports = {
|
||||||
|
service: ModuleService,
|
||||||
|
}
|
||||||
|
|
||||||
|
export * from "./models"
|
||||||
|
export * from "./services/module-service"
|
||||||
|
|
||||||
|
export default moduleExports
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { model } from "@medusajs/utils"
|
||||||
|
|
||||||
|
export const dmlEntity = model.define("dmlEntity", {
|
||||||
|
name: model.text(),
|
||||||
|
})
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import { Entity, Property } from "@mikro-orm/core"
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class EntityModel {
|
||||||
|
@Property({ columnType: "int" })
|
||||||
|
id!: number
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./entity"
|
||||||
|
export * from "./dml-entity"
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import { IModuleService } from "@medusajs/types"
|
||||||
|
|
||||||
|
export class ModuleService implements IModuleService {}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
import { ModuleExports } from "@medusajs/types"
|
||||||
|
import { ModuleService } from "./services/module-service"
|
||||||
|
|
||||||
|
const moduleExports: ModuleExports = {
|
||||||
|
service: ModuleService,
|
||||||
|
}
|
||||||
|
|
||||||
|
export * from "./models"
|
||||||
|
export * from "./services/module-service"
|
||||||
|
|
||||||
|
export default moduleExports
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { model } from "@medusajs/utils"
|
||||||
|
|
||||||
|
export const entityModel = model.define("entityModel", {
|
||||||
|
name: model.text(),
|
||||||
|
})
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { model } from "@medusajs/utils"
|
||||||
|
|
||||||
|
export const dmlEntity = model.define("dmlEntity", {
|
||||||
|
name: model.text(),
|
||||||
|
})
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./dml-entity"
|
||||||
|
export * from "./dml-entity-model"
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import { IModuleService } from "@medusajs/types"
|
||||||
|
|
||||||
|
export class ModuleService implements IModuleService {}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
import { ModuleExports } from "@medusajs/types"
|
||||||
|
import { ModuleService } from "./services/module-service"
|
||||||
|
|
||||||
|
const moduleExports: ModuleExports = {
|
||||||
|
service: ModuleService,
|
||||||
|
}
|
||||||
|
|
||||||
|
export * from "./models"
|
||||||
|
export * from "./services/module-service"
|
||||||
|
|
||||||
|
export default moduleExports
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import { Entity, Property } from "@mikro-orm/core"
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class Entity2 {
|
||||||
|
@Property({ columnType: "int" })
|
||||||
|
id!: number
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import { Entity, Property } from "@mikro-orm/core"
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class EntityModel {
|
||||||
|
@Property({ columnType: "int" })
|
||||||
|
id!: number
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./entity"
|
||||||
|
export * from "./entity-2"
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
import { IModuleService, ModuleJoinerConfig } from "@medusajs/types"
|
||||||
|
import { defineJoinerConfig } from "@medusajs/utils"
|
||||||
|
|
||||||
|
export class ModuleService implements IModuleService {
|
||||||
|
__joinerConfig(): ModuleJoinerConfig {
|
||||||
|
return defineJoinerConfig("module-service", {
|
||||||
|
alias: [
|
||||||
|
{
|
||||||
|
name: ["custom_name"],
|
||||||
|
args: {
|
||||||
|
entity: "Custom",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
import { ModuleExports } from "@medusajs/types"
|
||||||
|
import { ModuleService } from "./services/module-service"
|
||||||
|
|
||||||
|
const moduleExports: ModuleExports = {
|
||||||
|
service: ModuleService,
|
||||||
|
}
|
||||||
|
|
||||||
|
export * from "./models"
|
||||||
|
export * from "./services/module-service"
|
||||||
|
|
||||||
|
export default moduleExports
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import { Entity, Property } from "@mikro-orm/core"
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class Entity2 {
|
||||||
|
@Property({ columnType: "int" })
|
||||||
|
id!: number
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import { Entity, Property } from "@mikro-orm/core"
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class EntityModel {
|
||||||
|
@Property({ columnType: "int" })
|
||||||
|
id!: number
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./entity"
|
||||||
|
export * from "./entity-2"
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import { IModuleService } from "@medusajs/types"
|
||||||
|
|
||||||
|
export class ModuleService implements IModuleService {}
|
||||||
@@ -0,0 +1,316 @@
|
|||||||
|
import { loadResources } from "../load-internal"
|
||||||
|
import { IModuleService, ModuleResolution } from "@medusajs/types"
|
||||||
|
import { join } from "path"
|
||||||
|
import {
|
||||||
|
ModuleWithDmlMixedWithoutJoinerConfigFixtures,
|
||||||
|
ModuleWithDmlWithoutJoinerConfigFixtures,
|
||||||
|
ModuleWithJoinerConfigFixtures,
|
||||||
|
ModuleWithoutJoinerConfigFixtures,
|
||||||
|
} from "../__fixtures__"
|
||||||
|
import { upperCaseFirst } from "@medusajs/utils"
|
||||||
|
|
||||||
|
describe("load internal - load resources", () => {
|
||||||
|
describe("when loading the module resources from a path", () => {
|
||||||
|
test("should return the correct resources and generate the correct joiner config from a mix of DML entities and mikro orm entities", async () => {
|
||||||
|
const { ModuleService, EntityModel, dmlEntity } =
|
||||||
|
ModuleWithDmlMixedWithoutJoinerConfigFixtures
|
||||||
|
|
||||||
|
const moduleResolution: ModuleResolution = {
|
||||||
|
resolutionPath: join(
|
||||||
|
__dirname,
|
||||||
|
"../__fixtures__/module-with-dml-mixed-without-joiner-config"
|
||||||
|
),
|
||||||
|
definition: {
|
||||||
|
key: "module-with-dml-mixed-without-joiner-config",
|
||||||
|
registrationName: "service",
|
||||||
|
label: "Module with DML mixed without joiner config",
|
||||||
|
defaultPackage: false,
|
||||||
|
defaultModuleDeclaration: {
|
||||||
|
scope: "internal",
|
||||||
|
resources: "shared",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(ModuleService.prototype as IModuleService).__joinerConfig
|
||||||
|
).toBeUndefined()
|
||||||
|
|
||||||
|
const resources = await loadResources(moduleResolution)
|
||||||
|
|
||||||
|
expect(resources).toBeDefined()
|
||||||
|
expect(resources.services).toHaveLength(1)
|
||||||
|
expect(resources.services[0]).toEqual(ModuleService)
|
||||||
|
expect(resources.models).toHaveLength(2)
|
||||||
|
expect(resources.models).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(dmlEntity.name) }),
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(EntityModel.name) }),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(resources.repositories).toHaveLength(0)
|
||||||
|
expect(resources.loaders).toHaveLength(2)
|
||||||
|
expect(resources.loaders).toEqual([
|
||||||
|
expect.objectContaining({ name: "connectionLoader" }),
|
||||||
|
expect.objectContaining({ name: "containerLoader" }),
|
||||||
|
])
|
||||||
|
expect(resources.moduleService).toEqual(ModuleService)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(resources.moduleService.prototype as IModuleService).__joinerConfig
|
||||||
|
).toBeDefined()
|
||||||
|
|
||||||
|
const generatedJoinerConfig = (
|
||||||
|
resources.moduleService.prototype as IModuleService
|
||||||
|
).__joinerConfig()
|
||||||
|
|
||||||
|
expect(generatedJoinerConfig).toEqual({
|
||||||
|
serviceName: "module-with-dml-mixed-without-joiner-config",
|
||||||
|
primaryKeys: ["id"],
|
||||||
|
linkableKeys: {
|
||||||
|
dml_entity_id: "DmlEntity",
|
||||||
|
entity_model_id: "EntityModel",
|
||||||
|
},
|
||||||
|
alias: [
|
||||||
|
{
|
||||||
|
name: ["dml_entity", "dml_entities"],
|
||||||
|
args: {
|
||||||
|
entity: "DmlEntity",
|
||||||
|
methodSuffix: "DmlEntities",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: ["entity_model", "entity_models"],
|
||||||
|
args: {
|
||||||
|
entity: "EntityModel",
|
||||||
|
methodSuffix: "EntityModels",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("should return the correct resources and generate the correct joiner config from DML entities", async () => {
|
||||||
|
const { ModuleService, entityModel, dmlEntity } =
|
||||||
|
ModuleWithDmlWithoutJoinerConfigFixtures
|
||||||
|
|
||||||
|
const moduleResolution: ModuleResolution = {
|
||||||
|
resolutionPath: join(
|
||||||
|
__dirname,
|
||||||
|
"../__fixtures__/module-with-dml-without-joiner-config"
|
||||||
|
),
|
||||||
|
definition: {
|
||||||
|
key: "module-with-dml-without-joiner-config",
|
||||||
|
registrationName: "service",
|
||||||
|
label: "Module with DML without joiner config",
|
||||||
|
defaultPackage: false,
|
||||||
|
defaultModuleDeclaration: {
|
||||||
|
scope: "internal",
|
||||||
|
resources: "shared",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(ModuleService.prototype as IModuleService).__joinerConfig
|
||||||
|
).toBeUndefined()
|
||||||
|
|
||||||
|
const resources = await loadResources(moduleResolution)
|
||||||
|
|
||||||
|
expect(resources).toBeDefined()
|
||||||
|
expect(resources.services).toHaveLength(1)
|
||||||
|
expect(resources.services[0]).toEqual(ModuleService)
|
||||||
|
expect(resources.models).toHaveLength(2)
|
||||||
|
expect(resources.models).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(dmlEntity.name) }),
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(entityModel.name) }),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(resources.repositories).toHaveLength(0)
|
||||||
|
expect(resources.loaders).toHaveLength(2)
|
||||||
|
expect(resources.loaders).toEqual([
|
||||||
|
expect.objectContaining({ name: "connectionLoader" }),
|
||||||
|
expect.objectContaining({ name: "containerLoader" }),
|
||||||
|
])
|
||||||
|
expect(resources.moduleService).toEqual(ModuleService)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(resources.moduleService.prototype as IModuleService).__joinerConfig
|
||||||
|
).toBeDefined()
|
||||||
|
|
||||||
|
const generatedJoinerConfig = (
|
||||||
|
resources.moduleService.prototype as IModuleService
|
||||||
|
).__joinerConfig()
|
||||||
|
|
||||||
|
expect(generatedJoinerConfig).toEqual({
|
||||||
|
serviceName: "module-with-dml-without-joiner-config",
|
||||||
|
primaryKeys: ["id"],
|
||||||
|
linkableKeys: {
|
||||||
|
entity_model_id: "EntityModel",
|
||||||
|
dml_entity_id: "DmlEntity",
|
||||||
|
},
|
||||||
|
alias: [
|
||||||
|
{
|
||||||
|
name: ["entity_model", "entity_models"],
|
||||||
|
args: {
|
||||||
|
entity: "EntityModel",
|
||||||
|
methodSuffix: "EntityModels",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: ["dml_entity", "dml_entities"],
|
||||||
|
args: {
|
||||||
|
entity: "DmlEntity",
|
||||||
|
methodSuffix: "DmlEntities",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("should return the correct resources and generate the correct joiner config from mikro orm entities", async () => {
|
||||||
|
const { ModuleService, EntityModel, Entity2 } =
|
||||||
|
ModuleWithoutJoinerConfigFixtures
|
||||||
|
|
||||||
|
const moduleResolution: ModuleResolution = {
|
||||||
|
resolutionPath: join(
|
||||||
|
__dirname,
|
||||||
|
"../__fixtures__/module-without-joiner-config"
|
||||||
|
),
|
||||||
|
definition: {
|
||||||
|
key: "module-without-joiner-config",
|
||||||
|
registrationName: "service",
|
||||||
|
label: "Module without joiner config",
|
||||||
|
defaultPackage: false,
|
||||||
|
defaultModuleDeclaration: {
|
||||||
|
scope: "internal",
|
||||||
|
resources: "shared",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(ModuleService.prototype as IModuleService).__joinerConfig
|
||||||
|
).toBeUndefined()
|
||||||
|
|
||||||
|
const resources = await loadResources(moduleResolution)
|
||||||
|
|
||||||
|
expect(resources).toBeDefined()
|
||||||
|
expect(resources.services).toHaveLength(1)
|
||||||
|
expect(resources.services[0]).toEqual(ModuleService)
|
||||||
|
expect(resources.models).toHaveLength(2)
|
||||||
|
expect(resources.models).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(EntityModel.name) }),
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(Entity2.name) }),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(resources.repositories).toHaveLength(0)
|
||||||
|
expect(resources.loaders).toHaveLength(2)
|
||||||
|
expect(resources.loaders).toEqual([
|
||||||
|
expect.objectContaining({ name: "connectionLoader" }),
|
||||||
|
expect.objectContaining({ name: "containerLoader" }),
|
||||||
|
])
|
||||||
|
expect(resources.moduleService).toEqual(ModuleService)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(resources.moduleService.prototype as IModuleService).__joinerConfig
|
||||||
|
).toBeDefined()
|
||||||
|
|
||||||
|
const generatedJoinerConfig = (
|
||||||
|
resources.moduleService.prototype as IModuleService
|
||||||
|
).__joinerConfig()
|
||||||
|
|
||||||
|
expect(generatedJoinerConfig).toEqual({
|
||||||
|
serviceName: "module-without-joiner-config",
|
||||||
|
primaryKeys: ["id"],
|
||||||
|
linkableKeys: {
|
||||||
|
entity2_id: "Entity2",
|
||||||
|
entity_model_id: "EntityModel",
|
||||||
|
},
|
||||||
|
alias: [
|
||||||
|
{
|
||||||
|
name: ["entity2", "entity2s"],
|
||||||
|
args: {
|
||||||
|
entity: "Entity2",
|
||||||
|
methodSuffix: "Entity2s",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: ["entity_model", "entity_models"],
|
||||||
|
args: {
|
||||||
|
entity: "EntityModel",
|
||||||
|
methodSuffix: "EntityModels",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("should return the correct resources and use the given joiner config", async () => {
|
||||||
|
const { ModuleService, EntityModel, Entity2 } =
|
||||||
|
ModuleWithJoinerConfigFixtures
|
||||||
|
|
||||||
|
const moduleResolution: ModuleResolution = {
|
||||||
|
resolutionPath: join(
|
||||||
|
__dirname,
|
||||||
|
"../__fixtures__/module-with-joiner-config"
|
||||||
|
),
|
||||||
|
definition: {
|
||||||
|
key: "module-without-joiner-config",
|
||||||
|
registrationName: "service",
|
||||||
|
label: "Module without joiner config",
|
||||||
|
defaultPackage: false,
|
||||||
|
defaultModuleDeclaration: {
|
||||||
|
scope: "internal",
|
||||||
|
resources: "shared",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(ModuleService.prototype as IModuleService).__joinerConfig
|
||||||
|
).toBeDefined()
|
||||||
|
|
||||||
|
const resources = await loadResources(moduleResolution)
|
||||||
|
|
||||||
|
expect(resources).toBeDefined()
|
||||||
|
expect(resources.services).toHaveLength(1)
|
||||||
|
expect(resources.services[0]).toEqual(ModuleService)
|
||||||
|
expect(resources.models).toHaveLength(2)
|
||||||
|
expect(resources.models).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(EntityModel.name) }),
|
||||||
|
expect.objectContaining({ name: upperCaseFirst(Entity2.name) }),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(resources.repositories).toHaveLength(0)
|
||||||
|
expect(resources.loaders).toHaveLength(2)
|
||||||
|
expect(resources.loaders).toEqual([
|
||||||
|
expect.objectContaining({ name: "connectionLoader" }),
|
||||||
|
expect.objectContaining({ name: "containerLoader" }),
|
||||||
|
])
|
||||||
|
expect(resources.moduleService).toEqual(ModuleService)
|
||||||
|
|
||||||
|
const generatedJoinerConfig = (
|
||||||
|
resources.moduleService.prototype as IModuleService
|
||||||
|
).__joinerConfig()
|
||||||
|
|
||||||
|
expect(generatedJoinerConfig).toEqual({
|
||||||
|
serviceName: "module-service",
|
||||||
|
primaryKeys: ["id"],
|
||||||
|
linkableKeys: {},
|
||||||
|
alias: [
|
||||||
|
{
|
||||||
|
name: ["custom_name"],
|
||||||
|
args: {
|
||||||
|
entity: "Custom",
|
||||||
|
methodSuffix: "Customs",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -10,9 +10,12 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
createMedusaContainer,
|
||||||
|
createMikrORMEntity,
|
||||||
|
defineJoinerConfig,
|
||||||
|
DmlEntity,
|
||||||
MedusaModuleType,
|
MedusaModuleType,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
createMedusaContainer,
|
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asFunction, asValue } from "awilix"
|
import { asFunction, asValue } from "awilix"
|
||||||
import { statSync } from "fs"
|
import { statSync } from "fs"
|
||||||
@@ -78,9 +81,9 @@ export async function loadInternalModule(
|
|||||||
|
|
||||||
if (resolution.resolutionPath) {
|
if (resolution.resolutionPath) {
|
||||||
moduleResources = await loadResources(
|
moduleResources = await loadResources(
|
||||||
loadedModule?.loaders ?? [],
|
|
||||||
resolution,
|
resolution,
|
||||||
logger
|
logger,
|
||||||
|
loadedModule?.loaders ?? []
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,9 +183,9 @@ export async function loadModuleMigrations(
|
|||||||
// Generate migration scripts if they are not present
|
// Generate migration scripts if they are not present
|
||||||
if (!runMigrations || !revertMigration) {
|
if (!runMigrations || !revertMigration) {
|
||||||
const moduleResources = await loadResources(
|
const moduleResources = await loadResources(
|
||||||
loadedModule?.loaders ?? [],
|
|
||||||
resolution,
|
resolution,
|
||||||
console as unknown as Logger
|
console as unknown as Logger,
|
||||||
|
loadedModule?.loaders ?? []
|
||||||
)
|
)
|
||||||
|
|
||||||
const migrationScriptOptions = {
|
const migrationScriptOptions = {
|
||||||
@@ -240,10 +243,10 @@ async function importAllFromDir(path: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadResources(
|
export async function loadResources(
|
||||||
loadedModuleLoaders: ModuleLoaderFunction[],
|
|
||||||
moduleResolution: ModuleResolution,
|
moduleResolution: ModuleResolution,
|
||||||
logger: Logger
|
logger: Logger = console as unknown as Logger,
|
||||||
|
loadedModuleLoaders?: ModuleLoaderFunction[]
|
||||||
): Promise<ModuleResource> {
|
): Promise<ModuleResource> {
|
||||||
let modulePath = moduleResolution.resolutionPath as string
|
let modulePath = moduleResolution.resolutionPath as string
|
||||||
let normalizedPath = modulePath
|
let normalizedPath = modulePath
|
||||||
@@ -267,12 +270,21 @@ async function loadResources(
|
|||||||
),
|
),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const entityBuilder = createMikrORMEntity()
|
||||||
const cleanupResources = (resources) => {
|
const cleanupResources = (resources) => {
|
||||||
return Object.values(resources).filter(
|
return Object.values(resources)
|
||||||
(resource): resource is Function => {
|
.map((resource) => {
|
||||||
return typeof resource === "function"
|
if (DmlEntity.isDmlEntity(resource)) {
|
||||||
}
|
return entityBuilder(resource as DmlEntity<any>)
|
||||||
)
|
}
|
||||||
|
|
||||||
|
if (typeof resource === "function") {
|
||||||
|
return resource
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
.filter((v): v is Function => !!v)
|
||||||
}
|
}
|
||||||
|
|
||||||
const potentialServices = [...new Set(cleanupResources(services))]
|
const potentialServices = [...new Set(cleanupResources(services))]
|
||||||
@@ -288,6 +300,12 @@ async function loadResources(
|
|||||||
migrationPath: normalizedPath + "/migrations",
|
migrationPath: normalizedPath + "/migrations",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
generateJoinerConfigIfNecessary({
|
||||||
|
moduleResolution,
|
||||||
|
service: moduleService,
|
||||||
|
models: potentialModels,
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
services: potentialServices,
|
services: potentialServices,
|
||||||
models: potentialModels,
|
models: potentialModels,
|
||||||
@@ -342,7 +360,7 @@ async function runLoaders(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function prepareLoaders({
|
function prepareLoaders({
|
||||||
loadedModuleLoaders,
|
loadedModuleLoaders = [] as ModuleLoaderFunction[],
|
||||||
models,
|
models,
|
||||||
repositories,
|
repositories,
|
||||||
services,
|
services,
|
||||||
@@ -407,3 +425,23 @@ function prepareLoaders({
|
|||||||
|
|
||||||
return finalLoaders
|
return finalLoaders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateJoinerConfigIfNecessary({
|
||||||
|
moduleResolution,
|
||||||
|
service,
|
||||||
|
models,
|
||||||
|
}: {
|
||||||
|
moduleResolution: ModuleResolution
|
||||||
|
service: Constructor<IModuleService>
|
||||||
|
models: Function[]
|
||||||
|
}) {
|
||||||
|
if (service.prototype.__joinerConfig) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
service.prototype.__joinerConfig = function () {
|
||||||
|
return defineJoinerConfig(moduleResolution.definition.key, {
|
||||||
|
entityQueryingConfig: models,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,19 +18,16 @@ import type {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
ModulesSdkUtils,
|
|
||||||
createMedusaContainer,
|
createMedusaContainer,
|
||||||
isObject,
|
isObject,
|
||||||
isString,
|
isString,
|
||||||
|
Modules,
|
||||||
|
ModulesSdkUtils,
|
||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import type { Knex } from "knex"
|
import type { Knex } from "knex"
|
||||||
import {
|
import { MODULE_PACKAGE_NAMES, ModuleRegistrationName } from "./definitions"
|
||||||
MODULE_PACKAGE_NAMES,
|
|
||||||
ModuleRegistrationName,
|
|
||||||
Modules,
|
|
||||||
} from "./definitions"
|
|
||||||
import { MedusaModule, RegisterModuleJoinerConfig } from "./medusa-module"
|
import { MedusaModule, RegisterModuleJoinerConfig } from "./medusa-module"
|
||||||
import { RemoteLink } from "./remote-link"
|
import { RemoteLink } from "./remote-link"
|
||||||
import { RemoteQuery } from "./remote-query"
|
import { RemoteQuery } from "./remote-query"
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import {
|
|||||||
ModuleJoinerRelationship,
|
ModuleJoinerRelationship,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
|
||||||
import { isObject, promiseAll, toPascalCase } from "@medusajs/utils"
|
import { isObject, Modules, promiseAll, toPascalCase } from "@medusajs/utils"
|
||||||
import { Modules } from "./definitions"
|
|
||||||
import { MedusaModule } from "./medusa-module"
|
import { MedusaModule } from "./medusa-module"
|
||||||
import { convertRecordsToLinkDefinition } from "./utils/convert-data-to-link-definition"
|
import { convertRecordsToLinkDefinition } from "./utils/convert-data-to-link-definition"
|
||||||
import { linkingErrorMessage } from "./utils/linking-error"
|
import { linkingErrorMessage } from "./utils/linking-error"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { MetadataStorage } from "@mikro-orm/core"
|
|||||||
import { EntityConstructor } from "../types"
|
import { EntityConstructor } from "../types"
|
||||||
import { EntityBuilder } from "../entity-builder"
|
import { EntityBuilder } from "../entity-builder"
|
||||||
import { createMikrORMEntity } from "../helpers/create-mikro-orm-entity"
|
import { createMikrORMEntity } from "../helpers/create-mikro-orm-entity"
|
||||||
|
import { DmlEntity } from "../entity"
|
||||||
|
|
||||||
describe("Entity builder", () => {
|
describe("Entity builder", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -10,6 +11,21 @@ describe("Entity builder", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("Entity builder | properties", () => {
|
describe("Entity builder | properties", () => {
|
||||||
|
test("should identify a DML entity correctly", () => {
|
||||||
|
const model = new EntityBuilder()
|
||||||
|
const user = model.define("user", {
|
||||||
|
id: model.number(),
|
||||||
|
username: model.text(),
|
||||||
|
email: model.text(),
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(DmlEntity.isDmlEntity(user)).toBe(true)
|
||||||
|
|
||||||
|
const nonDmlEntity = new Object()
|
||||||
|
|
||||||
|
expect(DmlEntity.isDmlEntity(nonDmlEntity)).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
test("define an entity", () => {
|
test("define an entity", () => {
|
||||||
const model = new EntityBuilder()
|
const model = new EntityBuilder()
|
||||||
const user = model.define("user", {
|
const user = model.define("user", {
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import { BelongsTo } from "./relations/belongs-to"
|
|||||||
import { DateTimeProperty } from "./properties/date-time"
|
import { DateTimeProperty } from "./properties/date-time"
|
||||||
import { ManyToMany } from "./relations/many-to-many"
|
import { ManyToMany } from "./relations/many-to-many"
|
||||||
import type {
|
import type {
|
||||||
|
PropertyType,
|
||||||
RelationshipOptions,
|
RelationshipOptions,
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
PropertyType,
|
|
||||||
} from "./types"
|
} from "./types"
|
||||||
import { NullableModifier } from "./properties/nullable"
|
import { NullableModifier } from "./properties/nullable"
|
||||||
import { IdProperty } from "./properties/id"
|
import { IdProperty } from "./properties/id"
|
||||||
@@ -179,3 +179,5 @@ export class EntityBuilder {
|
|||||||
return new ManyToMany<T>(entityBuilder, options || {})
|
return new ManyToMany<T>(entityBuilder, options || {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const model = new EntityBuilder()
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
import { BelongsTo } from "./relations/belongs-to"
|
import { BelongsTo } from "./relations/belongs-to"
|
||||||
import {
|
import {
|
||||||
PropertyType,
|
|
||||||
EntityCascades,
|
EntityCascades,
|
||||||
RelationshipType,
|
|
||||||
ExtractEntityRelations,
|
ExtractEntityRelations,
|
||||||
|
PropertyType,
|
||||||
|
RelationshipType,
|
||||||
} from "./types"
|
} from "./types"
|
||||||
|
|
||||||
|
const IsDmlEntity = Symbol("isDmlEntity")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dml entity is a representation of a DML model with a unique
|
* Dml entity is a representation of a DML model with a unique
|
||||||
* name, its schema and relationships.
|
* name, its schema and relationships.
|
||||||
@@ -13,9 +15,26 @@ import {
|
|||||||
export class DmlEntity<
|
export class DmlEntity<
|
||||||
Schema extends Record<string, PropertyType<any> | RelationshipType<any>>
|
Schema extends Record<string, PropertyType<any> | RelationshipType<any>>
|
||||||
> {
|
> {
|
||||||
|
[IsDmlEntity] = true
|
||||||
|
|
||||||
#cascades: EntityCascades<string[]> = {}
|
#cascades: EntityCascades<string[]> = {}
|
||||||
constructor(public name: string, public schema: Schema) {}
|
constructor(public name: string, public schema: Schema) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A static method to check if an entity is an instance of DmlEntity.
|
||||||
|
* It allows us to identify a specific object as being an instance of
|
||||||
|
* DmlEntity.
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
static isDmlEntity(entity: unknown): entity is DmlEntity<any> {
|
||||||
|
return (
|
||||||
|
!!entity &&
|
||||||
|
(entity instanceof DmlEntity ||
|
||||||
|
(typeof entity === "object" && entity[IsDmlEntity] === true))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse entity to get its underlying information
|
* Parse entity to get its underlying information
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -618,3 +618,5 @@ export function createMikrORMEntity() {
|
|||||||
) as Infer<T>
|
) as Infer<T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const toMikroORMEntity = createMikrORMEntity()
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from "./entity-builder"
|
export * from "./entity-builder"
|
||||||
|
export * from "./entity"
|
||||||
export * from "./helpers/create-mikro-orm-entity"
|
export * from "./helpers/create-mikro-orm-entity"
|
||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
} from "../common"
|
} from "../common"
|
||||||
import { InjectManager, MedusaContext } from "./decorators"
|
import { InjectManager, MedusaContext } from "./decorators"
|
||||||
import { ModuleRegistrationName } from "./definition"
|
import { ModuleRegistrationName } from "./definition"
|
||||||
|
import { DmlEntity } from "../dml"
|
||||||
|
|
||||||
type BaseMethods =
|
type BaseMethods =
|
||||||
| "retrieve"
|
| "retrieve"
|
||||||
@@ -83,16 +84,20 @@ type ExtractSingularName<T extends Record<any, any>, K = keyof T> = Capitalize<
|
|||||||
* @deprecated should all notion of singular and plural be removed once all modules are aligned with the convention
|
* @deprecated should all notion of singular and plural be removed once all modules are aligned with the convention
|
||||||
* The pluralize will move to where it should be used instead
|
* The pluralize will move to where it should be used instead
|
||||||
*/
|
*/
|
||||||
type ExtractPluralName<T extends Record<any, any>, K = keyof T> = T[K] extends {
|
type ExtractPluralName<T extends Record<any, any>, K = keyof T> = Capitalize<
|
||||||
plural?: string
|
T[K] extends {
|
||||||
}
|
plural?: string
|
||||||
? T[K]["plural"] & string
|
}
|
||||||
: Pluralize<K & string>
|
? T[K]["plural"] & string
|
||||||
|
: Pluralize<K & string>
|
||||||
|
>
|
||||||
|
|
||||||
// TODO: The future expected entry will be a DML object but in the meantime we have to maintain backward compatibility for ouw own modules and therefore we need to support Constructor<any> as well as this temporary object
|
// TODO: The future expected entry will be a DML object but in the meantime we have to maintain backward compatibility for ouw own modules and therefore we need to support Constructor<any> as well as this temporary object
|
||||||
type TEntityEntries<Keys = string> = Record<
|
type TEntityEntries<Keys = string> = Record<
|
||||||
Keys & string,
|
Keys & string,
|
||||||
Constructor<any> | { name?: string; singular?: string; plural?: string }
|
| Constructor<any>
|
||||||
|
| DmlEntity<any>
|
||||||
|
| { name?: string; singular?: string; plural?: string }
|
||||||
>
|
>
|
||||||
|
|
||||||
type ExtractKeysFromConfig<EntitiesConfig> = EntitiesConfig extends {
|
type ExtractKeysFromConfig<EntitiesConfig> = EntitiesConfig extends {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { IApiKeyModuleService } from "@medusajs/types"
|
import { IApiKeyModuleService } from "@medusajs/types"
|
||||||
import { ApiKeyType } from "@medusajs/utils"
|
import { ApiKeyType, Modules } from "@medusajs/utils"
|
||||||
import crypto from "crypto"
|
import crypto from "crypto"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
buildEntitiesNameToLinkableKeysMap,
|
buildEntitiesNameToLinkableKeysMap,
|
||||||
defineJoinerConfig,
|
defineJoinerConfig,
|
||||||
MapToConfig,
|
MapToConfig,
|
||||||
|
Modules,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.API_KEY)
|
export const joinerConfig = defineJoinerConfig(Modules.API_KEY)
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { IAuthModuleService } from "@medusajs/types"
|
import { IAuthModuleService } from "@medusajs/types"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
|
||||||
import { createAuthIdentities } from "../../__fixtures__/auth-identity"
|
import { createAuthIdentities } from "../../__fixtures__/auth-identity"
|
||||||
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { IAuthModuleService } from "@medusajs/types"
|
import { IAuthModuleService } from "@medusajs/types"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||||
import { resolve } from "path"
|
import { resolve } from "path"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
let moduleOptions = {
|
let moduleOptions = {
|
||||||
providers: [
|
providers: [
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import {
|
|||||||
buildEntitiesNameToLinkableKeysMap,
|
buildEntitiesNameToLinkableKeysMap,
|
||||||
defineJoinerConfig,
|
defineJoinerConfig,
|
||||||
MapToConfig,
|
MapToConfig,
|
||||||
|
Modules,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.AUTH, {
|
export const joinerConfig = defineJoinerConfig(Modules.AUTH, {
|
||||||
entityQueryingConfig: [AuthIdentity],
|
entityQueryingConfig: [AuthIdentity],
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"test": "jest --passWithNoTests"
|
"test": "jest --passWithNoTests"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.3"
|
"@medusajs/modules-sdk": "^1.12.3",
|
||||||
|
"@medusajs/utils": "^1.11.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@ import {
|
|||||||
ExternalModuleDeclaration,
|
ExternalModuleDeclaration,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
MedusaModule,
|
MedusaModule,
|
||||||
Modules,
|
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import { ICacheService } from "@medusajs/types"
|
import { ICacheService } from "@medusajs/types"
|
||||||
import { InMemoryCacheModuleOptions } from "../types"
|
import { InMemoryCacheModuleOptions } from "../types"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const initialize = async (
|
export const initialize = async (
|
||||||
options?: InMemoryCacheModuleOptions | ExternalModuleDeclaration
|
options?: InMemoryCacheModuleOptions | ExternalModuleDeclaration
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
|
"@medusajs/utils": "^1.11.9",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"ioredis": "^5.3.1"
|
"ioredis": "^5.3.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import {
|
|||||||
ExternalModuleDeclaration,
|
ExternalModuleDeclaration,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
MedusaModule,
|
MedusaModule,
|
||||||
Modules,
|
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
import { ICacheService } from "@medusajs/types"
|
import { ICacheService } from "@medusajs/types"
|
||||||
import { RedisCacheModuleOptions } from "../types"
|
import { RedisCacheModuleOptions } from "../types"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const initialize = async (
|
export const initialize = async (
|
||||||
options?: RedisCacheModuleOptions | ExternalModuleDeclaration
|
options?: RedisCacheModuleOptions | ExternalModuleDeclaration
|
||||||
|
|||||||
+2
-3
@@ -1,6 +1,5 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { ICartModuleService } from "@medusajs/types"
|
import { ICartModuleService } from "@medusajs/types"
|
||||||
import { BigNumber } from "@medusajs/utils"
|
import { BigNumber, Modules } from "@medusajs/utils"
|
||||||
import { CheckConstraintViolationException } from "@mikro-orm/core"
|
import { CheckConstraintViolationException } from "@mikro-orm/core"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ jest.setTimeout(50000)
|
|||||||
|
|
||||||
moduleIntegrationTestRunner<ICartModuleService>({
|
moduleIntegrationTestRunner<ICartModuleService>({
|
||||||
moduleName: Modules.CART,
|
moduleName: Modules.CART,
|
||||||
testSuite: ({ MikroOrmWrapper, service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Cart Module Service", () => {
|
describe("Cart Module Service", () => {
|
||||||
describe("create", () => {
|
describe("create", () => {
|
||||||
it("should throw an error when required params are not passed", async () => {
|
it("should throw an error when required params are not passed", async () => {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
buildEntitiesNameToLinkableKeysMap,
|
buildEntitiesNameToLinkableKeysMap,
|
||||||
defineJoinerConfig,
|
defineJoinerConfig,
|
||||||
MapToConfig,
|
MapToConfig,
|
||||||
|
Modules,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.CART)
|
export const joinerConfig = defineJoinerConfig(Modules.CART)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { ICurrencyModuleService } from "@medusajs/types"
|
import { ICurrencyModuleService } from "@medusajs/types"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
buildEntitiesNameToLinkableKeysMap,
|
buildEntitiesNameToLinkableKeysMap,
|
||||||
defineJoinerConfig,
|
defineJoinerConfig,
|
||||||
MapToConfig,
|
MapToConfig,
|
||||||
|
Modules,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.CURRENCY)
|
export const joinerConfig = defineJoinerConfig(Modules.CURRENCY)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { ICustomerModuleService } from "@medusajs/types"
|
import { ICustomerModuleService } from "@medusajs/types"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import {
|
import {
|
||||||
buildEntitiesNameToLinkableKeysMap,
|
buildEntitiesNameToLinkableKeysMap,
|
||||||
defineJoinerConfig,
|
defineJoinerConfig,
|
||||||
MapToConfig,
|
MapToConfig,
|
||||||
|
Modules,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.CUSTOMER, {
|
export const joinerConfig = defineJoinerConfig(Modules.CUSTOMER, {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { MedusaModule, Modules } from "@medusajs/modules-sdk"
|
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||||
import { IEventBusService } from "@medusajs/types"
|
import { IEventBusService } from "@medusajs/types"
|
||||||
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const initialize = async (): Promise<IEventBusService> => {
|
export const initialize = async (): Promise<IEventBusService> => {
|
||||||
const serviceKey = Modules.EVENT_BUS
|
const serviceKey = Modules.EVENT_BUS
|
||||||
|
|||||||
Loaded 100 of 191 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user