chore: Migrate modules to use the Module util (#7964)
**What** Apply the `Module` util to each module to handle the export and provide the linkable configuration object. - Most joiner config that does not have any special config are removed/cleaned up in favor of the autogenerated one or simpler one - linkable are now available in all modules - cleaned up the dependencies of the modules FIXES CORE-2410
This commit is contained in:
1 parent
eafa3560ae
commit
b368251ca3
99 files changed
+1267
-488
No files matched your search
@@ -32,7 +32,7 @@ import { accessSync } from "fs"
|
|||||||
* then it will be inferred from the entity name of the alias args.
|
* then it will be inferred from the entity name of the alias args.
|
||||||
*
|
*
|
||||||
* @param serviceName
|
* @param serviceName
|
||||||
* @param alias
|
* @param alias custom aliases will be merged with the computed aliases from the provided models. Though, if a custom alias correspond to a computed alias for the same model then the custom alias will take place. Also, note that the methodSuffix will be inferred from the entity name if not provided as part of the args.
|
||||||
* @param schema
|
* @param schema
|
||||||
* @param models
|
* @param models
|
||||||
* @param linkableKeys
|
* @param linkableKeys
|
||||||
@@ -72,11 +72,19 @@ export function defineJoinerConfig(
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
++index
|
++index
|
||||||
const fullPath = getCallerFilePath(index)
|
let fullPath = getCallerFilePath(index)
|
||||||
if (!fullPath) {
|
if (!fullPath) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle integration-tests/__tests__ path based on conventional naming
|
||||||
|
*/
|
||||||
|
if (fullPath.includes("integration-tests/__tests__")) {
|
||||||
|
const sourcePath = fullPath.split("integration-tests/__tests__")[0]
|
||||||
|
fullPath = path.join(sourcePath, "src")
|
||||||
|
}
|
||||||
|
|
||||||
const srcDir = fullPath.includes("dist") ? "dist" : "src"
|
const srcDir = fullPath.includes("dist") ? "dist" : "src"
|
||||||
const splitPath = fullPath.split(srcDir)
|
const splitPath = fullPath.split(srcDir)
|
||||||
|
|
||||||
@@ -297,10 +305,10 @@ export function buildLinkableKeysFromMikroOrmObjects(
|
|||||||
* // {
|
* // {
|
||||||
* // user: {
|
* // user: {
|
||||||
* // id: {
|
* // id: {
|
||||||
* // serviceName: 'userService',
|
* // serviceName: 'userService', // The name of the module service it originate from
|
||||||
* // field: 'user',
|
* // field: 'user', // The field name of the entity, the query field is inferred from it as kebab cased singular/plural
|
||||||
* // linkable: 'user_id',
|
* // linkable: 'user_id', // The linkable key
|
||||||
* // primaryKey: 'id'
|
* // primaryKey: 'id' // The primary key if refers to in the original object representation, it will be used to be passed to the filters of the corresponding public service method
|
||||||
* // },
|
* // },
|
||||||
* // toJSON() { ... }
|
* // toJSON() { ... }
|
||||||
* // },
|
* // },
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export function Module<
|
|||||||
} else {
|
} else {
|
||||||
linkable = buildLinkConfigFromLinkableKeys(
|
linkable = buildLinkConfigFromLinkableKeys(
|
||||||
serviceName,
|
serviceName,
|
||||||
defaultJoinerConfig.linkableKeys
|
service.prototype.__joinerConfig().linkableKeys
|
||||||
) as Linkable
|
) as Linkable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -1,11 +1,12 @@
|
|||||||
import { IApiKeyModuleService } from "@medusajs/types"
|
import { IApiKeyModuleService } from "@medusajs/types"
|
||||||
import { ApiKeyType, Modules } from "@medusajs/utils"
|
import { ApiKeyType, Module, 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 {
|
||||||
createPublishableKeyFixture,
|
createPublishableKeyFixture,
|
||||||
createSecretKeyFixture,
|
createSecretKeyFixture,
|
||||||
} from "../__fixtures__"
|
} from "../__fixtures__"
|
||||||
|
import { ApiKeyModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -39,6 +40,25 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
|
|||||||
jest.restoreAllMocks()
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.API_KEY, {
|
||||||
|
service: ApiKeyModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["apiKey"])
|
||||||
|
|
||||||
|
linkable.apiKey.toJSON = undefined
|
||||||
|
|
||||||
|
expect(linkable.apiKey).toEqual({
|
||||||
|
id: {
|
||||||
|
linkable: "api_key_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "apiKey",
|
||||||
|
field: "apiKey",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("API Key Module Service", () => {
|
describe("API Key Module Service", () => {
|
||||||
describe("creating a publishable API key", () => {
|
describe("creating a publishable API key", () => {
|
||||||
it("should create it successfully", async function () {
|
it("should create it successfully", async function () {
|
||||||
|
|||||||
@@ -45,13 +45,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { ApiKeyModuleService } from "@services"
|
import { ApiKeyModuleService } from "@services"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = { service: ApiKeyModuleService }
|
export default Module(Modules.API_KEY, {
|
||||||
export default moduleDefinition
|
service: ApiKeyModuleService,
|
||||||
|
})
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.API_KEY)
|
|
||||||
@@ -8,10 +8,8 @@ import {
|
|||||||
FindConfig,
|
FindConfig,
|
||||||
IApiKeyModuleService,
|
IApiKeyModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
import { ApiKey } from "@models"
|
import { ApiKey } from "@models"
|
||||||
import {
|
import {
|
||||||
CreateApiKeyDTO,
|
CreateApiKeyDTO,
|
||||||
@@ -38,7 +36,7 @@ type InjectedDependencies = {
|
|||||||
apiKeyService: ModulesSdkTypes.IMedusaInternalService<any>
|
apiKeyService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ApiKeyModuleService
|
export class ApiKeyModuleService
|
||||||
extends MedusaService<{
|
extends MedusaService<{
|
||||||
ApiKey: { dto: ApiKeyTypes.ApiKeyDTO }
|
ApiKey: { dto: ApiKeyTypes.ApiKeyDTO }
|
||||||
}>({ ApiKey })
|
}>({ ApiKey })
|
||||||
@@ -57,9 +55,6 @@ export default class ApiKeyModuleService
|
|||||||
this.apiKeyService_ = apiKeyService
|
this.apiKeyService_ = apiKeyService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
createApiKeys(
|
createApiKeys(
|
||||||
data: ApiKeyTypes.CreateApiKeyDTO[],
|
data: ApiKeyTypes.CreateApiKeyDTO[],
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { default as ApiKeyModuleService } from "./api-key-module-service"
|
export { ApiKeyModuleService } from "./api-key-module-service"
|
||||||
+21
-1
@@ -1,7 +1,8 @@
|
|||||||
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"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { AuthModuleService } from "@services"
|
||||||
|
|
||||||
let moduleOptions = {
|
let moduleOptions = {
|
||||||
providers: [
|
providers: [
|
||||||
@@ -36,6 +37,25 @@ moduleIntegrationTestRunner({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.AUTH, {
|
||||||
|
service: AuthModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["authIdentity"])
|
||||||
|
|
||||||
|
linkable.authIdentity.toJSON = undefined
|
||||||
|
|
||||||
|
expect(linkable.authIdentity).toEqual({
|
||||||
|
id: {
|
||||||
|
linkable: "auth_identity_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "auth",
|
||||||
|
field: "authIdentity",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("it fails if the provider does not exist", async () => {
|
it("it fails if the provider does not exist", async () => {
|
||||||
const err = await service
|
const err = await service
|
||||||
.authenticate("facebook", {
|
.authenticate("facebook", {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.14",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -45,15 +46,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/auth-emailpass": "0.0.1",
|
"@medusajs/auth-emailpass": "0.0.1",
|
||||||
"@medusajs/modules-sdk": "^1.12.9",
|
"@medusajs/modules-sdk": "^1.12.9",
|
||||||
"@medusajs/types": "^1.11.14",
|
|
||||||
"@medusajs/utils": "^1.11.7",
|
"@medusajs/utils": "^1.11.7",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"knex": "2.4.2",
|
|
||||||
"scrypt-kdf": "^2.0.1",
|
"scrypt-kdf": "^2.0.1",
|
||||||
"simple-oauth2": "^5.0.0"
|
"simple-oauth2": "^5.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { AuthModuleService } from "@services"
|
import { AuthModuleService } from "@services"
|
||||||
import loadProviders from "./loaders/providers"
|
import loadProviders from "./loaders/providers"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.AUTH, {
|
||||||
service: AuthModuleService,
|
service: AuthModuleService,
|
||||||
loaders: [loadProviders] as any,
|
loaders: [loadProviders],
|
||||||
}
|
})
|
||||||
export default moduleDefinition
|
|
||||||
+108
-1
@@ -1,7 +1,8 @@
|
|||||||
import { ICartModuleService } from "@medusajs/types"
|
import { ICartModuleService } from "@medusajs/types"
|
||||||
import { BigNumber, Modules } from "@medusajs/utils"
|
import { BigNumber, Module, 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"
|
||||||
|
import { CartModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
@@ -9,6 +10,112 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
|||||||
moduleName: Modules.CART,
|
moduleName: Modules.CART,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Cart Module Service", () => {
|
describe("Cart Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.CART, {
|
||||||
|
service: CartModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"address",
|
||||||
|
"adjustmentLine",
|
||||||
|
"cart",
|
||||||
|
"lineItemAdjustment",
|
||||||
|
"lineItemTaxLine",
|
||||||
|
"lineItem",
|
||||||
|
"shippingMethodAdjustment",
|
||||||
|
"shippingMethodTaxLine",
|
||||||
|
"shippingMethod",
|
||||||
|
"taxLine",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
address: {
|
||||||
|
id: {
|
||||||
|
linkable: "address_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "address",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
adjustmentLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "adjustment_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "adjustmentLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cart: {
|
||||||
|
id: {
|
||||||
|
linkable: "cart_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "cart",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lineItemAdjustment: {
|
||||||
|
id: {
|
||||||
|
linkable: "line_item_adjustment_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "lineItemAdjustment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lineItemTaxLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "line_item_tax_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "lineItemTaxLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lineItem: {
|
||||||
|
id: {
|
||||||
|
linkable: "line_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "lineItem",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingMethodAdjustment: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_method_adjustment_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "shippingMethodAdjustment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingMethodTaxLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_method_tax_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "shippingMethodTaxLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingMethod: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_method_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "shippingMethod",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
taxLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "tax_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "cart",
|
||||||
|
field: "taxLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
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 () => {
|
||||||
const error = await service
|
const error = await service
|
||||||
|
|||||||
@@ -45,13 +45,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { CartModuleService } from "./services"
|
import { CartModuleService } from "./services"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const service = CartModuleService
|
export default Module(Modules.CART, {
|
||||||
|
service: CartModuleService,
|
||||||
export const moduleDefinition: ModuleExports = {
|
})
|
||||||
service,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.CART)
|
|
||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
FindConfig,
|
FindConfig,
|
||||||
ICartModuleService,
|
ICartModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
@@ -39,7 +38,6 @@ import {
|
|||||||
UpdateLineItemDTO,
|
UpdateLineItemDTO,
|
||||||
UpdateShippingMethodTaxLineDTO,
|
UpdateShippingMethodTaxLineDTO,
|
||||||
} from "@types"
|
} from "@types"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
@@ -115,10 +113,6 @@ export default class CartModuleService
|
|||||||
this.lineItemTaxLineService_ = lineItemTaxLineService
|
this.lineItemTaxLineService_ = lineItemTaxLineService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
private shouldIncludeTotals(config: FindConfig<any>): boolean {
|
private shouldIncludeTotals(config: FindConfig<any>): boolean {
|
||||||
const totalFields = [
|
const totalFields = [
|
||||||
"total",
|
"total",
|
||||||
|
|||||||
+25
-1
@@ -1,6 +1,7 @@
|
|||||||
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"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { CurrencyModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -8,6 +9,29 @@ moduleIntegrationTestRunner<ICurrencyModuleService>({
|
|||||||
moduleName: Modules.CURRENCY,
|
moduleName: Modules.CURRENCY,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Currency Module Service", () => {
|
describe("Currency Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.CURRENCY, {
|
||||||
|
service: CurrencyModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["currency"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
currency: {
|
||||||
|
code: {
|
||||||
|
linkable: "currency_code",
|
||||||
|
primaryKey: "code",
|
||||||
|
serviceName: "currency",
|
||||||
|
field: "currency",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("list", () => {
|
describe("list", () => {
|
||||||
it("list currencies", async () => {
|
it("list currencies", async () => {
|
||||||
const currenciesResult = await service.listCurrencies(
|
const currenciesResult = await service.listCurrencies(
|
||||||
|
|||||||
@@ -45,13 +45,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.CURRENCY, {
|
|
||||||
primaryKeys: ["code"],
|
|
||||||
linkableKeys: {
|
|
||||||
currency_code: "currency",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@@ -7,13 +7,11 @@ import {
|
|||||||
FindConfig,
|
FindConfig,
|
||||||
ICurrencyModuleService,
|
ICurrencyModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
|
||||||
import { MedusaService } from "@medusajs/utils"
|
import { MedusaService } from "@medusajs/utils"
|
||||||
import { Currency } from "@models"
|
import { Currency } from "@models"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
@@ -41,10 +39,6 @@ export default class CurrencyModuleService
|
|||||||
this.currencyService_ = currencyService
|
this.currencyService_ = currencyService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
async retrieveCurrency(
|
async retrieveCurrency(
|
||||||
code: string,
|
code: string,
|
||||||
|
|||||||
+54
-1
@@ -1,6 +1,7 @@
|
|||||||
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/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { CustomerModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -8,6 +9,58 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
|
|||||||
moduleName: Modules.CUSTOMER,
|
moduleName: Modules.CUSTOMER,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Customer Module Service", () => {
|
describe("Customer Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.CUSTOMER, {
|
||||||
|
service: CustomerModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"address",
|
||||||
|
"customerGroupCustomer",
|
||||||
|
"customerGroup",
|
||||||
|
"customer",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
address: {
|
||||||
|
id: {
|
||||||
|
linkable: "address_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "customer",
|
||||||
|
field: "address",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
customerGroupCustomer: {
|
||||||
|
id: {
|
||||||
|
linkable: "customer_group_customer_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "customer",
|
||||||
|
field: "customerGroupCustomer",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
customerGroup: {
|
||||||
|
id: {
|
||||||
|
linkable: "customer_group_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "customer",
|
||||||
|
field: "customerGroup",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
customer: {
|
||||||
|
id: {
|
||||||
|
linkable: "customer_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "customer",
|
||||||
|
field: "customer",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("create", () => {
|
describe("create", () => {
|
||||||
it("should create a single customer", async () => {
|
it("should create a single customer", async () => {
|
||||||
const customerData = {
|
const customerData = {
|
||||||
|
|||||||
@@ -50,8 +50,6 @@
|
|||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { CustomerModuleService } from "@services"
|
import { CustomerModuleService } from "@services"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.CUSTOMER, {
|
||||||
service: CustomerModuleService,
|
service: CustomerModuleService,
|
||||||
}
|
})
|
||||||
export default moduleDefinition
|
|
||||||
@@ -2,7 +2,8 @@ import { resolve } from "path"
|
|||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { Entity, PrimaryKey } from "@mikro-orm/core"
|
import { Entity, PrimaryKey } from "@mikro-orm/core"
|
||||||
import { IFileModuleService } from "@medusajs/types"
|
import { IFileModuleService } from "@medusajs/types"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { FileModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -31,6 +32,20 @@ moduleIntegrationTestRunner<IFileModuleService>({
|
|||||||
moduleModels: [DummyEntity],
|
moduleModels: [DummyEntity],
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("File Module Service", () => {
|
describe("File Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.FILE, {
|
||||||
|
service: FileModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({})
|
||||||
|
})
|
||||||
|
|
||||||
it("creates and gets a file", async () => {
|
it("creates and gets a file", async () => {
|
||||||
const res = await service.createFiles({
|
const res = await service.createFiles({
|
||||||
filename: "test.jpg",
|
filename: "test.jpg",
|
||||||
|
|||||||
@@ -47,14 +47,11 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.10",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/utils": "^1.11.8",
|
"@medusajs/utils": "^1.11.8",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2",
|
|
||||||
"lodash": "^4.17.21"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,8 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { FileModuleService } from "@services"
|
import { FileModuleService } from "@services"
|
||||||
import loadProviders from "./loaders/providers"
|
import loadProviders from "./loaders/providers"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const loaders = [loadProviders] as any
|
export default Module(Modules.FILE, {
|
||||||
|
service: FileModuleService,
|
||||||
const service = FileModuleService
|
loaders: [loadProviders],
|
||||||
export const moduleDefinition: ModuleExports = {
|
})
|
||||||
service,
|
|
||||||
loaders,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
+55
-3
@@ -1,11 +1,11 @@
|
|||||||
import { ModulesDefinition } from "@medusajs/modules-sdk"
|
import { ModulesDefinition } from "@medusajs/modules-sdk"
|
||||||
import { FulfillmentSetDTO, IFulfillmentModuleService } from "@medusajs/types"
|
import { FulfillmentSetDTO, IFulfillmentModuleService } from "@medusajs/types"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { FulfillmentProviderService } from "@services"
|
import { FulfillmentModuleService, FulfillmentProviderService } from "@services"
|
||||||
import {
|
import {
|
||||||
SuiteOptions,
|
|
||||||
initModules,
|
initModules,
|
||||||
moduleIntegrationTestRunner,
|
moduleIntegrationTestRunner,
|
||||||
|
SuiteOptions,
|
||||||
} from "medusa-test-utils"
|
} from "medusa-test-utils"
|
||||||
import { resolve } from "path"
|
import { resolve } from "path"
|
||||||
import { createFullDataStructure } from "../../__fixtures__"
|
import { createFullDataStructure } from "../../__fixtures__"
|
||||||
@@ -103,6 +103,58 @@ moduleIntegrationTestRunner({
|
|||||||
service,
|
service,
|
||||||
}: SuiteOptions<IFulfillmentModuleService>) =>
|
}: SuiteOptions<IFulfillmentModuleService>) =>
|
||||||
describe("Fulfillment Module Service", () => {
|
describe("Fulfillment Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.FULFILLMENT, {
|
||||||
|
service: FulfillmentModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"fulfillment",
|
||||||
|
"fulfillmentSet",
|
||||||
|
"shippingOption",
|
||||||
|
"shippingOptionRule",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
fulfillment: {
|
||||||
|
id: {
|
||||||
|
linkable: "fulfillment_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "fulfillment",
|
||||||
|
field: "fulfillment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fulfillmentSet: {
|
||||||
|
id: {
|
||||||
|
linkable: "fulfillment_set_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "fulfillment",
|
||||||
|
field: "fulfillmentSet",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingOption: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_option_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "fulfillment",
|
||||||
|
field: "shippingOption",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingOptionRule: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_option_rule_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "fulfillment",
|
||||||
|
field: "shippingOptionRule",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("should load and save all the providers on bootstrap with the correct is_enabled value", async () => {
|
it("should load and save all the providers on bootstrap with the correct is_enabled value", async () => {
|
||||||
const databaseConfig = {
|
const databaseConfig = {
|
||||||
schema: "public",
|
schema: "public",
|
||||||
|
|||||||
@@ -51,8 +51,6 @@
|
|||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { FulfillmentModuleService } from "@services"
|
import { FulfillmentModuleService } from "@services"
|
||||||
import loadProviders from "./loaders/providers"
|
import loadProviders from "./loaders/providers"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const service = FulfillmentModuleService
|
export default Module(Modules.FULFILLMENT, {
|
||||||
const loaders = [loadProviders]
|
service: FulfillmentModuleService,
|
||||||
|
loaders: [loadProviders],
|
||||||
export const moduleDefinition: ModuleExports = {
|
})
|
||||||
service,
|
|
||||||
loaders,
|
|
||||||
}
|
|
||||||
export default moduleDefinition
|
|
||||||
|
|
||||||
// Module options types
|
// Module options types
|
||||||
export { FulfillmentModuleOptions } from "./types"
|
export { FulfillmentModuleOptions } from "./types"
|
||||||
+45
-1
@@ -1,6 +1,7 @@
|
|||||||
import { IInventoryService, InventoryItemDTO } from "@medusajs/types"
|
import { IInventoryService, InventoryItemDTO } from "@medusajs/types"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { InventoryModuleService } from "../../src/services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -8,6 +9,49 @@ moduleIntegrationTestRunner<IInventoryService>({
|
|||||||
moduleName: Modules.INVENTORY,
|
moduleName: Modules.INVENTORY,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Inventory Module Service", () => {
|
describe("Inventory Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.INVENTORY, {
|
||||||
|
service: InventoryModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"inventoryItem",
|
||||||
|
"inventoryLevel",
|
||||||
|
"reservationItem",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
inventoryItem: {
|
||||||
|
id: {
|
||||||
|
field: "inventoryItem",
|
||||||
|
linkable: "inventory_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "inventoryService",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
inventoryLevel: {
|
||||||
|
id: {
|
||||||
|
field: "inventoryLevel",
|
||||||
|
linkable: "inventory_level_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "inventoryService",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
reservationItem: {
|
||||||
|
id: {
|
||||||
|
field: "reservationItem",
|
||||||
|
linkable: "reservation_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "inventoryService",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("create", () => {
|
describe("create", () => {
|
||||||
it("should create an inventory item", async () => {
|
it("should create an inventory item", async () => {
|
||||||
const data = { sku: "test-sku", origin_country: "test-country" }
|
const data = { sku: "test-sku", origin_country: "test-country" }
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
moduleNameMapper: {
|
||||||
|
"^@models": "<rootDir>/src/models",
|
||||||
|
"^@services": "<rootDir>/src/services",
|
||||||
|
"^@repositories": "<rootDir>/src/repositories",
|
||||||
|
"^@types": "<rootDir>/src/types",
|
||||||
|
},
|
||||||
transform: {
|
transform: {
|
||||||
"^.+\\.[jt]s$": [
|
"^.+\\.[jt]s$": [
|
||||||
"@swc/jest",
|
"@swc/jest",
|
||||||
|
|||||||
@@ -36,9 +36,7 @@
|
|||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "tsc --build --watch",
|
"watch": "tsc --build --watch",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
import InventoryModuleService from "./services/inventory-module"
|
||||||
import InventoryService from "./services/inventory-module"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.INVENTORY, {
|
||||||
service: InventoryService,
|
service: InventoryModuleService,
|
||||||
}
|
})
|
||||||
export default moduleDefinition
|
|
||||||
@@ -9,13 +9,6 @@ export const joinerConfig = defineJoinerConfig(Modules.INVENTORY, {
|
|||||||
methodSuffix: "InventoryItems",
|
methodSuffix: "InventoryItems",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: ["inventory_level", "inventory_levels"],
|
|
||||||
args: {
|
|
||||||
entity: "InventoryLevel",
|
|
||||||
methodSuffix: "InventoryLevels",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: [
|
name: [
|
||||||
"reservation",
|
"reservation",
|
||||||
|
|||||||
+25
-1
@@ -1,7 +1,8 @@
|
|||||||
import { INotificationModuleService } from "@medusajs/types"
|
import { INotificationModuleService } from "@medusajs/types"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||||
import { resolve } from "path"
|
import { resolve } from "path"
|
||||||
|
import { NotificationModuleService } from "@services"
|
||||||
|
|
||||||
let moduleOptions = {
|
let moduleOptions = {
|
||||||
providers: [
|
providers: [
|
||||||
@@ -26,6 +27,29 @@ moduleIntegrationTestRunner({
|
|||||||
moduleOptions,
|
moduleOptions,
|
||||||
testSuite: ({ service }: SuiteOptions<INotificationModuleService>) =>
|
testSuite: ({ service }: SuiteOptions<INotificationModuleService>) =>
|
||||||
describe("Notification Module Service", () => {
|
describe("Notification Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.NOTIFICATION, {
|
||||||
|
service: NotificationModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["notification"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
notification: {
|
||||||
|
id: {
|
||||||
|
linkable: "notification_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "notification",
|
||||||
|
field: "notification",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("sends a notification and stores it in the database", async () => {
|
it("sends a notification and stores it in the database", async () => {
|
||||||
const notification = {
|
const notification = {
|
||||||
to: "admin@medusa.com",
|
to: "admin@medusa.com",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -45,13 +46,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { NotificationModuleService } from "@services"
|
import { NotificationModuleService } from "@services"
|
||||||
import loadProviders from "./loaders/providers"
|
import loadProviders from "./loaders/providers"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const moduleDefinition: ModuleExports = {
|
export default Module(Modules.NOTIFICATION, {
|
||||||
service: NotificationModuleService,
|
service: NotificationModuleService,
|
||||||
loaders: [loadProviders],
|
loaders: [loadProviders],
|
||||||
}
|
})
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.NOTIFICATION, {
|
|
||||||
models: [{ name: "Notification" }],
|
|
||||||
})
|
|
||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
InferEntityType,
|
InferEntityType,
|
||||||
INotificationModuleService,
|
INotificationModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
NotificationTypes,
|
NotificationTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
@@ -17,7 +16,6 @@ import {
|
|||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { Notification } from "@models"
|
import { Notification } from "@models"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
import NotificationProviderService from "./notification-provider"
|
import NotificationProviderService from "./notification-provider"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
@@ -55,10 +53,6 @@ export default class NotificationModuleService
|
|||||||
this.notificationProviderService_ = notificationProviderService
|
this.notificationProviderService_ = notificationProviderService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
createNotifications(
|
createNotifications(
|
||||||
data: NotificationTypes.CreateNotificationDTO[],
|
data: NotificationTypes.CreateNotificationDTO[],
|
||||||
|
|||||||
@@ -0,0 +1,243 @@
|
|||||||
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
import { IOrderModuleService } from "@medusajs/types"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { OrderModuleService } from "@services"
|
||||||
|
|
||||||
|
moduleIntegrationTestRunner<IOrderModuleService>({
|
||||||
|
moduleName: Modules.ORDER,
|
||||||
|
testSuite: () => {
|
||||||
|
describe("Order Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.ORDER, {
|
||||||
|
service: OrderModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"address",
|
||||||
|
"adjustmentLine",
|
||||||
|
"claimItemImage",
|
||||||
|
"orderClaimItem",
|
||||||
|
"orderClaim",
|
||||||
|
"orderExchangeItem",
|
||||||
|
"orderExchange",
|
||||||
|
"lineItemAdjustment",
|
||||||
|
"lineItemTaxLine",
|
||||||
|
"lineItem",
|
||||||
|
"orderChangeAction",
|
||||||
|
"orderChange",
|
||||||
|
"orderItem",
|
||||||
|
"orderShippingMethod",
|
||||||
|
"orderSummary",
|
||||||
|
"order",
|
||||||
|
"returnItem",
|
||||||
|
"returnReason",
|
||||||
|
"return",
|
||||||
|
"shippingMethodAdjustment",
|
||||||
|
"shippingMethodTaxLine",
|
||||||
|
"shippingMethod",
|
||||||
|
"taxLine",
|
||||||
|
"transaction",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
address: {
|
||||||
|
id: {
|
||||||
|
linkable: "address_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "address",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
adjustmentLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "adjustment_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "adjustmentLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
claimItemImage: {
|
||||||
|
id: {
|
||||||
|
linkable: "claim_item_image_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "claimItemImage",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderClaimItem: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_claim_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderClaimItem",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderClaim: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_claim_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderClaim",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderExchangeItem: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_exchange_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderExchangeItem",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderExchange: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_exchange_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderExchange",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lineItemAdjustment: {
|
||||||
|
id: {
|
||||||
|
linkable: "line_item_adjustment_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "lineItemAdjustment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lineItemTaxLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "line_item_tax_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "lineItemTaxLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lineItem: {
|
||||||
|
id: {
|
||||||
|
linkable: "line_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "lineItem",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderChangeAction: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_change_action_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderChangeAction",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderChange: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_change_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderChange",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderItem: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderItem",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderShippingMethod: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_shipping_method_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderShippingMethod",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderSummary: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_summary_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "orderSummary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
id: {
|
||||||
|
linkable: "order_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "order",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
returnItem: {
|
||||||
|
id: {
|
||||||
|
linkable: "return_item_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "returnItem",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
returnReason: {
|
||||||
|
id: {
|
||||||
|
linkable: "return_reason_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "returnReason",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
return: {
|
||||||
|
id: {
|
||||||
|
linkable: "return_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "return",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingMethodAdjustment: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_method_adjustment_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "shippingMethodAdjustment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingMethodTaxLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_method_tax_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "shippingMethodTaxLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingMethod: {
|
||||||
|
id: {
|
||||||
|
linkable: "shipping_method_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "shippingMethod",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
taxLine: {
|
||||||
|
id: {
|
||||||
|
linkable: "tax_line_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "taxLine",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
transaction: {
|
||||||
|
id: {
|
||||||
|
linkable: "transaction_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "order",
|
||||||
|
field: "transaction",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -50,8 +50,6 @@
|
|||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { OrderModuleService } from "@services"
|
import { OrderModuleService } from "@services"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const service = OrderModuleService
|
export default Module(Modules.ORDER, {
|
||||||
|
service: OrderModuleService,
|
||||||
export const moduleDefinition: ModuleExports = {
|
})
|
||||||
service,
|
|
||||||
}
|
|
||||||
|
|
||||||
export * from "./models"
|
|
||||||
export * from "./services"
|
|
||||||
export * from "./types"
|
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
// TODO: review configuration
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.ORDER)
|
|
||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
FindConfig,
|
FindConfig,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
OrderDTO,
|
OrderDTO,
|
||||||
OrderTypes,
|
OrderTypes,
|
||||||
@@ -65,7 +64,6 @@ import {
|
|||||||
UpdateOrderLineItemTaxLineDTO,
|
UpdateOrderLineItemTaxLineDTO,
|
||||||
UpdateOrderShippingMethodTaxLineDTO,
|
UpdateOrderShippingMethodTaxLineDTO,
|
||||||
} from "@types"
|
} from "@types"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
import {
|
import {
|
||||||
applyChangesToOrder,
|
applyChangesToOrder,
|
||||||
ApplyOrderChangeDTO,
|
ApplyOrderChangeDTO,
|
||||||
@@ -239,10 +237,6 @@ export default class OrderModuleService<
|
|||||||
this.orderExchangeService_ = orderExchangeService
|
this.orderExchangeService_ = orderExchangeService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
private shouldIncludeTotals(config: FindConfig<any>): boolean {
|
private shouldIncludeTotals(config: FindConfig<any>): boolean {
|
||||||
const totalFields = [
|
const totalFields = [
|
||||||
"total",
|
"total",
|
||||||
|
|||||||
+46
-2
@@ -1,11 +1,12 @@
|
|||||||
import { IPaymentModuleService } from "@medusajs/types"
|
import { IPaymentModuleService } from "@medusajs/types"
|
||||||
import { Modules, promiseAll } from "@medusajs/utils"
|
import { Module, Modules, promiseAll } from "@medusajs/utils"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
createPaymentCollections,
|
createPaymentCollections,
|
||||||
createPaymentSessions,
|
|
||||||
createPayments,
|
createPayments,
|
||||||
|
createPaymentSessions,
|
||||||
} from "../../../__fixtures__"
|
} from "../../../__fixtures__"
|
||||||
|
import { PaymentModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -13,6 +14,49 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
|
|||||||
moduleName: Modules.PAYMENT,
|
moduleName: Modules.PAYMENT,
|
||||||
testSuite: ({ MikroOrmWrapper, service }) => {
|
testSuite: ({ MikroOrmWrapper, service }) => {
|
||||||
describe("Payment Module Service", () => {
|
describe("Payment Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.PAYMENT, {
|
||||||
|
service: PaymentModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"payment",
|
||||||
|
"paymentCollection",
|
||||||
|
"paymentProvider",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
payment: {
|
||||||
|
id: {
|
||||||
|
linkable: "payment_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "payment",
|
||||||
|
field: "payment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
paymentCollection: {
|
||||||
|
id: {
|
||||||
|
linkable: "payment_collection_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "payment",
|
||||||
|
field: "paymentCollection",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
paymentProvider: {
|
||||||
|
id: {
|
||||||
|
linkable: "payment_provider_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "payment",
|
||||||
|
field: "paymentProvider",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("Payment Flow", () => {
|
describe("Payment Flow", () => {
|
||||||
it("complete payment flow successfully", async () => {
|
it("complete payment flow successfully", async () => {
|
||||||
let paymentCollection = await service.createPaymentCollections({
|
let paymentCollection = await service.createPaymentCollections({
|
||||||
|
|||||||
@@ -52,8 +52,6 @@
|
|||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"bignumber.js": "^9.1.2",
|
"bignumber.js": "^9.1.2"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
|
|
||||||
import { PaymentModuleService } from "@services"
|
import { PaymentModuleService } from "@services"
|
||||||
import loadProviders from "./loaders/providers"
|
import loadProviders from "./loaders/providers"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.PAYMENT, {
|
||||||
service: PaymentModuleService,
|
service: PaymentModuleService,
|
||||||
loaders: [loadProviders],
|
loaders: [loadProviders],
|
||||||
}
|
})
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
|
|
||||||
export { PaymentModuleOptions } from "./types"
|
export { PaymentModuleOptions } from "./types"
|
||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
import { IPricingModuleService } from "@medusajs/types"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { PricingModuleService } from "@services"
|
||||||
|
|
||||||
|
moduleIntegrationTestRunner<IPricingModuleService>({
|
||||||
|
moduleName: Modules.PRICING,
|
||||||
|
testSuite: () => {
|
||||||
|
describe("PricingModule Service - Calculate Price", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.PRICING, {
|
||||||
|
service: PricingModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"priceSet",
|
||||||
|
"priceList",
|
||||||
|
"price",
|
||||||
|
"pricePreference",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
priceSet: {
|
||||||
|
id: {
|
||||||
|
linkable: "price_set_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "pricingService",
|
||||||
|
field: "priceSet",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
priceList: {
|
||||||
|
id: {
|
||||||
|
linkable: "price_list_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "pricingService",
|
||||||
|
field: "priceList",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
price: {
|
||||||
|
id: {
|
||||||
|
linkable: "price_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "pricingService",
|
||||||
|
field: "price",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pricePreference: {
|
||||||
|
id: {
|
||||||
|
linkable: "price_preference_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "pricingService",
|
||||||
|
field: "pricePreference",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -45,14 +46,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { PricingModuleService } from "@services"
|
import { PricingModuleService } from "@services"
|
||||||
|
|
||||||
const service = PricingModuleService
|
export default Module(Modules.PRICING, {
|
||||||
|
service: PricingModuleService,
|
||||||
export const moduleDefinition: ModuleExports = {
|
})
|
||||||
service,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
|
|
||||||
export * from "./types"
|
export * from "./types"
|
||||||
@@ -3,10 +3,4 @@ import { Price, PriceList, PricePreference, PriceSet } from "@models"
|
|||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.PRICING, {
|
export const joinerConfig = defineJoinerConfig(Modules.PRICING, {
|
||||||
models: [PriceSet, PriceList, Price, PricePreference],
|
models: [PriceSet, PriceList, Price, PricePreference],
|
||||||
linkableKeys: {
|
|
||||||
price_set_id: PriceSet.name,
|
|
||||||
price_list_id: PriceList.name,
|
|
||||||
price_id: Price.name,
|
|
||||||
price_preference_id: PricePreference.name,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
@@ -9,9 +9,13 @@ import {
|
|||||||
} from "../__fixtures__/product"
|
} from "../__fixtures__/product"
|
||||||
|
|
||||||
import { IProductModuleService, ProductDTO } from "@medusajs/types"
|
import { IProductModuleService, ProductDTO } from "@medusajs/types"
|
||||||
import { kebabCase, Modules, ProductStatus } from "@medusajs/utils"
|
import { kebabCase, Module, Modules, ProductStatus } from "@medusajs/utils"
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
import { ProductCategoryService, ProductService } from "@services"
|
import {
|
||||||
|
ProductCategoryService,
|
||||||
|
ProductModuleService,
|
||||||
|
ProductService,
|
||||||
|
} from "@services"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
categoriesData,
|
categoriesData,
|
||||||
@@ -37,6 +41,94 @@ moduleIntegrationTestRunner<Service>({
|
|||||||
categoryService = moduleService.productCategoryService_
|
categoryService = moduleService.productCategoryService_
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.PRODUCT, {
|
||||||
|
service: ProductModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"product",
|
||||||
|
"productVariant",
|
||||||
|
"productOption",
|
||||||
|
"productType",
|
||||||
|
"productImage",
|
||||||
|
"productTag",
|
||||||
|
"productCollection",
|
||||||
|
"productCategory",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
product: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "product",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
productVariant: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_variant_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "productVariant",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
productOption: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_option_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "productOption",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
productType: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_type_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "productType",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
productImage: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_image_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "productImage",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
productTag: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_tag_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "productTag",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
productCollection: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_collection_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "productCollection",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
productCategory: {
|
||||||
|
id: {
|
||||||
|
linkable: "product_category_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "productService",
|
||||||
|
field: "productCategory",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("Product Service", () => {
|
describe("Product Service", () => {
|
||||||
let testManager: SqlEntityManager
|
let testManager: SqlEntityManager
|
||||||
let products!: Product[]
|
let products!: Product[]
|
||||||
|
|||||||
@@ -47,14 +47,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2",
|
|
||||||
"lodash": "^4.17.21"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { ProductModuleService } from "@services"
|
import { ProductModuleService } from "@services"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.PRODUCT, {
|
||||||
service: ProductModuleService,
|
service: ProductModuleService,
|
||||||
}
|
})
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,56 +1,33 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
Product,
|
||||||
|
ProductCategory,
|
||||||
|
ProductCollection,
|
||||||
|
ProductOption,
|
||||||
|
ProductTag,
|
||||||
|
ProductType,
|
||||||
|
ProductVariant,
|
||||||
|
} from "@models"
|
||||||
|
import ProductImage from "./models/product-image"
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.PRODUCT, {
|
export const joinerConfig = defineJoinerConfig(Modules.PRODUCT, {
|
||||||
|
models: [
|
||||||
|
Product,
|
||||||
|
ProductVariant,
|
||||||
|
ProductOption,
|
||||||
|
ProductType,
|
||||||
|
ProductImage,
|
||||||
|
ProductTag,
|
||||||
|
ProductCollection,
|
||||||
|
ProductCategory,
|
||||||
|
],
|
||||||
primaryKeys: ["id", "handle"],
|
primaryKeys: ["id", "handle"],
|
||||||
// This module provides more alias than the default config builder
|
|
||||||
alias: [
|
alias: [
|
||||||
{
|
|
||||||
name: ["product", "products"],
|
|
||||||
args: {
|
|
||||||
entity: "Product",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: ["product_variant", "product_variants", "variant", "variants"],
|
name: ["product_variant", "product_variants", "variant", "variants"],
|
||||||
args: {
|
args: {
|
||||||
entity: "ProductVariant",
|
entity: "ProductVariant",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: ["product_option", "product_options"],
|
|
||||||
args: {
|
|
||||||
entity: "ProductOption",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: ["product_type", "product_types"],
|
|
||||||
args: {
|
|
||||||
entity: "ProductType",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: ["product_image", "product_images"],
|
|
||||||
args: {
|
|
||||||
entity: "ProductImage",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: ["product_tag", "product_tags"],
|
|
||||||
args: {
|
|
||||||
entity: "ProductTag",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: ["product_collection", "product_collections"],
|
|
||||||
args: {
|
|
||||||
entity: "ProductCollection",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: ["product_category", "product_categories"],
|
|
||||||
args: {
|
|
||||||
entity: "ProductCategory",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
+45
@@ -2,6 +2,7 @@ import { IPromotionModuleService } from "@medusajs/types"
|
|||||||
import {
|
import {
|
||||||
ApplicationMethodType,
|
ApplicationMethodType,
|
||||||
CampaignBudgetType,
|
CampaignBudgetType,
|
||||||
|
Module,
|
||||||
Modules,
|
Modules,
|
||||||
PromotionType,
|
PromotionType,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
@@ -12,6 +13,7 @@ import {
|
|||||||
createDefaultPromotions,
|
createDefaultPromotions,
|
||||||
createPromotions,
|
createPromotions,
|
||||||
} from "../../../__fixtures__/promotion"
|
} from "../../../__fixtures__/promotion"
|
||||||
|
import { PromotionModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -26,6 +28,49 @@ moduleIntegrationTestRunner({
|
|||||||
await createCampaigns(MikroOrmWrapper.forkManager())
|
await createCampaigns(MikroOrmWrapper.forkManager())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.PROMOTION, {
|
||||||
|
service: PromotionModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"promotion",
|
||||||
|
"campaign",
|
||||||
|
"promotionRule",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
promotion: {
|
||||||
|
id: {
|
||||||
|
linkable: "promotion_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "promotion",
|
||||||
|
field: "promotion",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
campaign: {
|
||||||
|
id: {
|
||||||
|
linkable: "campaign_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "promotion",
|
||||||
|
field: "campaign",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
promotionRule: {
|
||||||
|
id: {
|
||||||
|
linkable: "promotion_rule_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "promotion",
|
||||||
|
field: "promotionRule",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
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 () => {
|
||||||
const error = await createDefaultPromotion(service, {
|
const error = await createDefaultPromotion(service, {
|
||||||
|
|||||||
@@ -46,13 +46,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "1.11.9",
|
"@medusajs/utils": "1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { PromotionModuleService } from "@services"
|
import { PromotionModuleService } from "@services"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.PROMOTION, {
|
||||||
service: PromotionModuleService,
|
service: PromotionModuleService,
|
||||||
}
|
})
|
||||||
export default moduleDefinition
|
|
||||||
@@ -3,9 +3,4 @@ import { Campaign, Promotion, PromotionRule } from "@models"
|
|||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.PROMOTION, {
|
export const joinerConfig = defineJoinerConfig(Modules.PROMOTION, {
|
||||||
models: [Promotion, Campaign, PromotionRule],
|
models: [Promotion, Campaign, PromotionRule],
|
||||||
linkableKeys: {
|
|
||||||
promotion_id: Promotion.name,
|
|
||||||
campaign_id: Campaign.name,
|
|
||||||
promotion_rule_id: PromotionRule.name,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { IRegionModuleService } from "@medusajs/types"
|
import { IRegionModuleService } from "@medusajs/types"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
import { RegionModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -8,6 +9,37 @@ moduleIntegrationTestRunner<IRegionModuleService>({
|
|||||||
moduleName: Modules.REGION,
|
moduleName: Modules.REGION,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Region Module Service", () => {
|
describe("Region Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.REGION, {
|
||||||
|
service: RegionModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["region", "country"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
region: {
|
||||||
|
id: {
|
||||||
|
linkable: "region_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "region",
|
||||||
|
field: "region",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
country: {
|
||||||
|
iso_2: {
|
||||||
|
linkable: "country_iso_2",
|
||||||
|
primaryKey: "iso_2",
|
||||||
|
serviceName: "region",
|
||||||
|
field: "country",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("should create countries on application start", async () => {
|
it("should create countries on application start", async () => {
|
||||||
const countries = await service.listCountries({}, { take: null })
|
const countries = await service.listCountries({}, { take: null })
|
||||||
expect(countries.length).toEqual(250)
|
expect(countries.length).toEqual(250)
|
||||||
|
|||||||
@@ -45,13 +45,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.REGION)
|
|
||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
InferEntityType,
|
InferEntityType,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
IRegionModuleService,
|
IRegionModuleService,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
RegionCountryDTO,
|
RegionCountryDTO,
|
||||||
RegionDTO,
|
RegionDTO,
|
||||||
@@ -28,7 +27,6 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { Country, Region } from "@models"
|
import { Country, Region } from "@models"
|
||||||
import { UpdateRegionInput } from "@types"
|
import { UpdateRegionInput } from "@types"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
@@ -68,10 +66,6 @@ export default class RegionModuleService
|
|||||||
this.countryService_ = countryService
|
this.countryService_ = countryService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
async createRegions(
|
async createRegions(
|
||||||
data: CreateRegionDTO[],
|
data: CreateRegionDTO[],
|
||||||
|
|||||||
+25
-1
@@ -1,6 +1,7 @@
|
|||||||
import { ISalesChannelModuleService } from "@medusajs/types"
|
import { ISalesChannelModuleService } from "@medusajs/types"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { SalesChannelModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -33,6 +34,29 @@ moduleIntegrationTestRunner<ISalesChannelModuleService>({
|
|||||||
await service.createSalesChannels(salesChannelData)
|
await service.createSalesChannels(salesChannelData)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.SALES_CHANNEL, {
|
||||||
|
service: SalesChannelModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["salesChannel"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
salesChannel: {
|
||||||
|
id: {
|
||||||
|
linkable: "sales_channel_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "salesChannel",
|
||||||
|
field: "salesChannel",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("create", () => {
|
describe("create", () => {
|
||||||
it("should create a SalesChannel successfully", async () => {
|
it("should create a SalesChannel successfully", async () => {
|
||||||
const [created] = await service.createSalesChannels([
|
const [created] = await service.createSalesChannels([
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.14",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -44,14 +45,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.9",
|
|
||||||
"@medusajs/types": "^1.11.14",
|
|
||||||
"@medusajs/utils": "^1.11.7",
|
"@medusajs/utils": "^1.11.7",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
import { SalesChannelModuleService } from "@services"
|
import { SalesChannelModuleService } from "@services"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.SALES_CHANNEL, {
|
||||||
service: SalesChannelModuleService,
|
service: SalesChannelModuleService,
|
||||||
}
|
})
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.SALES_CHANNEL)
|
|
||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
FilterableSalesChannelProps,
|
FilterableSalesChannelProps,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ISalesChannelModuleService,
|
ISalesChannelModuleService,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
SalesChannelDTO,
|
SalesChannelDTO,
|
||||||
UpdateSalesChannelDTO,
|
UpdateSalesChannelDTO,
|
||||||
@@ -22,7 +21,6 @@ import {
|
|||||||
|
|
||||||
import { SalesChannel } from "@models"
|
import { SalesChannel } from "@models"
|
||||||
import { UpdateSalesChanneInput } from "@types"
|
import { UpdateSalesChanneInput } from "@types"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
@@ -48,10 +46,6 @@ export default class SalesChannelModuleService
|
|||||||
this.salesChannelService_ = salesChannelService
|
this.salesChannelService_ = salesChannelService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
async createSalesChannels(
|
async createSalesChannels(
|
||||||
data: CreateSalesChannelDTO[],
|
data: CreateSalesChannelDTO[],
|
||||||
|
|||||||
+25
-1
@@ -1,7 +1,8 @@
|
|||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
import { IStockLocationService } from "@medusajs/types"
|
import { IStockLocationService } from "@medusajs/types"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { StockLocationModuleService } from "../../src/services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -9,6 +10,29 @@ moduleIntegrationTestRunner<IStockLocationService>({
|
|||||||
moduleName: Modules.STOCK_LOCATION,
|
moduleName: Modules.STOCK_LOCATION,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Stock Location Module Service", () => {
|
describe("Stock Location Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.STOCK_LOCATION, {
|
||||||
|
service: StockLocationModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["stockLocation"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
stockLocation: {
|
||||||
|
location_id: {
|
||||||
|
linkable: "location_id",
|
||||||
|
primaryKey: "location_id",
|
||||||
|
serviceName: "stockLocationService",
|
||||||
|
field: "stockLocation",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("create", () => {
|
describe("create", () => {
|
||||||
it("should create a stock location", async () => {
|
it("should create a stock location", async () => {
|
||||||
const data = { name: "location" }
|
const data = { name: "location" }
|
||||||
|
|||||||
@@ -36,9 +36,7 @@
|
|||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "tsc --build --watch",
|
"watch": "tsc --build --watch",
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { IStoreModuleService } from "@medusajs/types"
|
import { IStoreModuleService } from "@medusajs/types"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { createStoreFixture } from "../__fixtures__"
|
import { createStoreFixture } from "../__fixtures__"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { StoreModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -9,6 +10,37 @@ moduleIntegrationTestRunner<IStoreModuleService>({
|
|||||||
moduleName: Modules.STORE,
|
moduleName: Modules.STORE,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("Store Module Service", () => {
|
describe("Store Module Service", () => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.STORE, {
|
||||||
|
service: StoreModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["storeCurrency", "store"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
storeCurrency: {
|
||||||
|
id: {
|
||||||
|
linkable: "store_currency_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "store",
|
||||||
|
field: "storeCurrency",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
store: {
|
||||||
|
id: {
|
||||||
|
linkable: "store_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "store",
|
||||||
|
field: "store",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("creating a store", () => {
|
describe("creating a store", () => {
|
||||||
it("should get created successfully", async function () {
|
it("should get created successfully", async function () {
|
||||||
const store = await service.createStores(createStoreFixture)
|
const store = await service.createStores(createStoreFixture)
|
||||||
|
|||||||
@@ -45,13 +45,10 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import { StoreModuleService } from "@services"
|
import { StoreModuleService } from "@services"
|
||||||
import { ModuleExports } from "@medusajs/types"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const moduleDefinition: ModuleExports = {
|
export default Module(Modules.STORE, {
|
||||||
service: StoreModuleService,
|
service: StoreModuleService,
|
||||||
}
|
})
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.STORE)
|
|
||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
DAL,
|
DAL,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
IStoreModuleService,
|
IStoreModuleService,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
StoreTypes,
|
StoreTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
@@ -20,7 +19,6 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
import { Store, StoreCurrency } from "@models"
|
import { Store, StoreCurrency } from "@models"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
import { UpdateStoreInput } from "@types"
|
import { UpdateStoreInput } from "@types"
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
@@ -48,10 +46,6 @@ export default class StoreModuleService
|
|||||||
this.storeService_ = storeService
|
this.storeService_ = storeService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
async createStores(
|
async createStores(
|
||||||
data: StoreTypes.CreateStoreDTO[],
|
data: StoreTypes.CreateStoreDTO[],
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { ITaxModuleService } from "@medusajs/types"
|
import { ITaxModuleService } from "@medusajs/types"
|
||||||
import { setupTaxStructure } from "../utils/setup-tax-structure"
|
import { setupTaxStructure } from "../utils/setup-tax-structure"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { TaxModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -9,6 +10,58 @@ moduleIntegrationTestRunner<ITaxModuleService>({
|
|||||||
moduleName: Modules.TAX,
|
moduleName: Modules.TAX,
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
describe("TaxModuleService", function () {
|
describe("TaxModuleService", function () {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.TAX, {
|
||||||
|
service: TaxModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual([
|
||||||
|
"taxProvider",
|
||||||
|
"taxRateRule",
|
||||||
|
"taxRate",
|
||||||
|
"taxRegion",
|
||||||
|
])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
taxProvider: {
|
||||||
|
id: {
|
||||||
|
linkable: "tax_provider_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "tax",
|
||||||
|
field: "taxProvider",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
taxRateRule: {
|
||||||
|
id: {
|
||||||
|
linkable: "tax_rate_rule_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "tax",
|
||||||
|
field: "taxRateRule",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
taxRate: {
|
||||||
|
id: {
|
||||||
|
linkable: "tax_rate_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "tax",
|
||||||
|
field: "taxRate",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
taxRegion: {
|
||||||
|
id: {
|
||||||
|
linkable: "tax_region_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "tax",
|
||||||
|
field: "taxRegion",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("should create tax rates and update them", async () => {
|
it("should create tax rates and update them", async () => {
|
||||||
const region = await service.createTaxRegions({
|
const region = await service.createTaxRegions({
|
||||||
country_code: "US",
|
country_code: "US",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.14",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -45,13 +46,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.9",
|
"@medusajs/modules-sdk": "^1.12.9",
|
||||||
"@medusajs/types": "^1.11.14",
|
|
||||||
"@medusajs/utils": "^1.11.7",
|
"@medusajs/utils": "^1.11.7",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,8 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { TaxModuleService } from "@services"
|
import { TaxModuleService } from "@services"
|
||||||
import loadProviders from "./loaders/providers"
|
import loadProviders from "./loaders/providers"
|
||||||
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const service = TaxModuleService
|
export default Module(Modules.TAX, {
|
||||||
const loaders = [loadProviders]
|
service: TaxModuleService,
|
||||||
|
loaders: [loadProviders],
|
||||||
export const moduleDefinition: ModuleExports = {
|
})
|
||||||
service,
|
|
||||||
loaders,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.TAX)
|
|
||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ITaxModuleService,
|
ITaxModuleService,
|
||||||
ITaxProvider,
|
ITaxProvider,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
TaxRegionDTO,
|
TaxRegionDTO,
|
||||||
TaxTypes,
|
TaxTypes,
|
||||||
@@ -20,7 +19,6 @@ import {
|
|||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { TaxProvider, TaxRate, TaxRateRule, TaxRegion } from "@models"
|
import { TaxProvider, TaxRate, TaxRateRule, TaxRegion } from "@models"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
@@ -75,10 +73,6 @@ export default class TaxModuleService
|
|||||||
this.taxProviderService_ = taxProviderService
|
this.taxProviderService_ = taxProviderService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
async createTaxRates(
|
async createTaxRates(
|
||||||
data: TaxTypes.CreateTaxRateDTO[],
|
data: TaxTypes.CreateTaxRateDTO[],
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { IUserModuleService } from "@medusajs/types"
|
import { IUserModuleService } from "@medusajs/types"
|
||||||
import { Modules, UserEvents } from "@medusajs/utils"
|
import { Module, Modules, UserEvents } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
MockEventBusService,
|
MockEventBusService,
|
||||||
moduleIntegrationTestRunner,
|
moduleIntegrationTestRunner,
|
||||||
} from "medusa-test-utils"
|
} from "medusa-test-utils"
|
||||||
|
import { UserModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -27,6 +28,37 @@ moduleIntegrationTestRunner<IUserModuleService>({
|
|||||||
eventBusModuleService: new MockEventBusService(),
|
eventBusModuleService: new MockEventBusService(),
|
||||||
},
|
},
|
||||||
testSuite: ({ service }) => {
|
testSuite: ({ service }) => {
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.USER, {
|
||||||
|
service: UserModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["invite", "user"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
invite: {
|
||||||
|
id: {
|
||||||
|
linkable: "invite_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "user",
|
||||||
|
field: "invite",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
id: {
|
||||||
|
linkable: "user_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "user",
|
||||||
|
field: "user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("UserModuleService - User", () => {
|
describe("UserModuleService - User", () => {
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
|
|||||||
@@ -47,14 +47,11 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.10",
|
|
||||||
"@medusajs/utils": "^1.11.8",
|
"@medusajs/utils": "^1.11.8",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"dotenv": "^16.4.5",
|
"jsonwebtoken": "^9.0.2"
|
||||||
"jsonwebtoken": "^9.0.2",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { UserModuleService } from "@services"
|
import { UserModuleService } from "@services"
|
||||||
import { ModuleExports } from "@medusajs/types"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
const moduleDefinition: ModuleExports = {
|
export default Module(Modules.USER, {
|
||||||
service: UserModuleService,
|
service: UserModuleService,
|
||||||
}
|
})
|
||||||
export default moduleDefinition
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.USER)
|
|
||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
DAL,
|
DAL,
|
||||||
IEventBusModuleService,
|
IEventBusModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
UserTypes,
|
UserTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
@@ -19,7 +18,6 @@ import {
|
|||||||
UserEvents,
|
UserEvents,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import jwt, { JwtPayload } from "jsonwebtoken"
|
import jwt, { JwtPayload } from "jsonwebtoken"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
import crypto from "node:crypto"
|
import crypto from "node:crypto"
|
||||||
|
|
||||||
import { Invite, User } from "@models"
|
import { Invite, User } from "@models"
|
||||||
@@ -44,10 +42,6 @@ export default class UserModuleService
|
|||||||
}>({ User, Invite })
|
}>({ User, Invite })
|
||||||
implements UserTypes.IUserModuleService
|
implements UserTypes.IUserModuleService
|
||||||
{
|
{
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
|
|
||||||
protected readonly userService_: ModulesSdkTypes.IMedusaInternalService<User>
|
protected readonly userService_: ModulesSdkTypes.IMedusaInternalService<User>
|
||||||
|
|||||||
+25
-1
@@ -4,7 +4,7 @@ import {
|
|||||||
IWorkflowEngineService,
|
IWorkflowEngineService,
|
||||||
RemoteQueryFunction,
|
RemoteQueryFunction,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { Modules, TransactionHandlerType } from "@medusajs/utils"
|
import { Module, Modules, TransactionHandlerType } from "@medusajs/utils"
|
||||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { setTimeout as setTimeoutPromise } from "timers/promises"
|
import { setTimeout as setTimeoutPromise } from "timers/promises"
|
||||||
import "../__fixtures__"
|
import "../__fixtures__"
|
||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
workflowEventGroupIdStep2Mock,
|
workflowEventGroupIdStep2Mock,
|
||||||
} from "../__fixtures__/workflow_event_group_id"
|
} from "../__fixtures__/workflow_event_group_id"
|
||||||
import { createScheduled } from "../__fixtures__/workflow_scheduled"
|
import { createScheduled } from "../__fixtures__/workflow_scheduled"
|
||||||
|
import { WorkflowsModuleService } from "@services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -34,6 +35,29 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
|
|||||||
query = medusaApp.query
|
query = medusaApp.query
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.WORKFLOW_ENGINE, {
|
||||||
|
service: WorkflowsModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["workflowExecution"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
workflowExecution: {
|
||||||
|
id: {
|
||||||
|
linkable: "workflow_execution_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "workflows",
|
||||||
|
field: "workflowExecution",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("should execute an async workflow keeping track of the event group id provided in the context", async () => {
|
it("should execute an async workflow keeping track of the event group id provided in the context", async () => {
|
||||||
const eventGroupId = "event-group-id"
|
const eventGroupId = "event-group-id"
|
||||||
|
|
||||||
|
|||||||
@@ -45,15 +45,12 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@medusajs/workflows-sdk": "^0.1.6",
|
"@medusajs/workflows-sdk": "^0.1.6",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"cron-parser": "^4.9.0",
|
"cron-parser": "^4.9.0"
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"knex": "2.4.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { moduleDefinition } from "./module-definition"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { WorkflowsModuleService } from "@services"
|
||||||
|
import { loadUtils } from "./loaders"
|
||||||
|
|
||||||
export default moduleDefinition
|
export default Module(Modules.WORKFLOW_ENGINE, {
|
||||||
|
service: WorkflowsModuleService,
|
||||||
export * from "./loaders"
|
loaders: [loadUtils],
|
||||||
export * from "./models"
|
})
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.WORKFLOW_ENGINE)
|
|
||||||
@@ -1 +1 @@
|
|||||||
export * from "./utils"
|
export { default as loadUtils } from "./utils"
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { WorkflowsModuleService } from "@services"
|
|
||||||
import loadUtils from "./loaders/utils"
|
|
||||||
|
|
||||||
const service = WorkflowsModuleService
|
|
||||||
const loaders = [loadUtils]
|
|
||||||
|
|
||||||
export const moduleDefinition: ModuleExports = {
|
|
||||||
service,
|
|
||||||
loaders,
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ import {
|
|||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
WorkflowsSdkTypes,
|
WorkflowsSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
@@ -17,7 +16,6 @@ import type {
|
|||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { WorkflowExecution } from "@models"
|
import { WorkflowExecution } from "@models"
|
||||||
import { WorkflowOrchestratorService } from "@services"
|
import { WorkflowOrchestratorService } from "@services"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
@@ -50,10 +48,6 @@ export class WorkflowsModuleService<
|
|||||||
this.workflowOrchestratorService_ = workflowOrchestratorService
|
this.workflowOrchestratorService_ = workflowOrchestratorService
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
@InjectSharedContext()
|
@InjectSharedContext()
|
||||||
async run<TWorkflow extends string | ReturnWorkflow<any, any, any>>(
|
async run<TWorkflow extends string | ReturnWorkflow<any, any, any>>(
|
||||||
workflowIdOrWorkflow: TWorkflow,
|
workflowIdOrWorkflow: TWorkflow,
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
createMedusaContainer,
|
||||||
|
Module,
|
||||||
|
Modules,
|
||||||
TransactionHandlerType,
|
TransactionHandlerType,
|
||||||
TransactionStepState,
|
TransactionStepState,
|
||||||
createMedusaContainer,
|
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import { knex } from "knex"
|
import { knex } from "knex"
|
||||||
@@ -21,6 +23,7 @@ import { setTimeout } from "timers/promises"
|
|||||||
import "../__fixtures__"
|
import "../__fixtures__"
|
||||||
import { createScheduled } from "../__fixtures__/workflow_scheduled"
|
import { createScheduled } from "../__fixtures__/workflow_scheduled"
|
||||||
import { DB_URL, TestDatabase } from "../utils"
|
import { DB_URL, TestDatabase } from "../utils"
|
||||||
|
import { WorkflowsModuleService } from "@medusajs/workflow-engine-inmemory/dist/services"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -78,6 +81,29 @@ describe("Workflow Orchestrator module", function () {
|
|||||||
workflowOrcModule = modules.workflows as unknown as IWorkflowEngineService
|
workflowOrcModule = modules.workflows as unknown as IWorkflowEngineService
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it(`should export the appropriate linkable configuration`, () => {
|
||||||
|
const linkable = Module(Modules.WORKFLOW_ENGINE, {
|
||||||
|
service: WorkflowsModuleService,
|
||||||
|
}).linkable
|
||||||
|
|
||||||
|
expect(Object.keys(linkable)).toEqual(["workflowExecution"])
|
||||||
|
|
||||||
|
Object.keys(linkable).forEach((key) => {
|
||||||
|
delete linkable[key].toJSON
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(linkable).toEqual({
|
||||||
|
workflowExecution: {
|
||||||
|
id: {
|
||||||
|
linkable: "workflow_execution_id",
|
||||||
|
primaryKey: "id",
|
||||||
|
serviceName: "workflows",
|
||||||
|
field: "workflowExecution",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("Testing basic workflow", function () {
|
describe("Testing basic workflow", function () {
|
||||||
afterEach(afterEach_)
|
afterEach(afterEach_)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { moduleDefinition } from "./module-definition"
|
import { Module, Modules } from "@medusajs/utils"
|
||||||
|
import { WorkflowsModuleService } from "@services"
|
||||||
|
import { loadUtils, redisConnection } from "./loaders"
|
||||||
|
|
||||||
export default moduleDefinition
|
export default Module(Modules.WORKFLOW_ENGINE, {
|
||||||
|
service: WorkflowsModuleService,
|
||||||
export * from "./loaders"
|
loaders: [loadUtils, redisConnection] as any[],
|
||||||
export * from "./models"
|
})
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
|
||||||
|
|
||||||
export const joinerConfig = defineJoinerConfig(Modules.WORKFLOW_ENGINE)
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
export * from "./redis"
|
export { default as redisConnection } from "./redis"
|
||||||
export * from "./utils"
|
export { default as loadUtils } from "./utils"
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { ModuleExports } from "@medusajs/types"
|
|
||||||
import { WorkflowsModuleService } from "@services"
|
|
||||||
import redisConnection from "./loaders/redis"
|
|
||||||
import loadUtils from "./loaders/utils"
|
|
||||||
|
|
||||||
const service = WorkflowsModuleService
|
|
||||||
const loaders = [loadUtils, redisConnection] as any
|
|
||||||
|
|
||||||
export const moduleDefinition: ModuleExports = {
|
|
||||||
service,
|
|
||||||
loaders,
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ import {
|
|||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
WorkflowsSdkTypes,
|
WorkflowsSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
@@ -17,7 +16,6 @@ import type {
|
|||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { WorkflowExecution } from "@models"
|
import { WorkflowExecution } from "@models"
|
||||||
import { WorkflowOrchestratorService } from "@services"
|
import { WorkflowOrchestratorService } from "@services"
|
||||||
import { joinerConfig } from "../joiner-config"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
@@ -54,10 +52,6 @@ export class WorkflowsModuleService<
|
|||||||
this.redisDisconnectHandler_ = redisDisconnectHandler
|
this.redisDisconnectHandler_ = redisDisconnectHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
__joinerConfig(): ModuleJoinerConfig {
|
|
||||||
return joinerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
__hooks = {
|
__hooks = {
|
||||||
onApplicationShutdown: async () => {
|
onApplicationShutdown: async () => {
|
||||||
await this.workflowOrchestratorService_.onApplicationShutdown()
|
await this.workflowOrchestratorService_.onApplicationShutdown()
|
||||||
|
|||||||
@@ -4226,7 +4226,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/api-key@workspace:packages/modules/api-key"
|
resolution: "@medusajs/api-key@workspace:packages/modules/api-key"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -4235,9 +4234,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4289,10 +4286,8 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
jsonwebtoken: ^9.0.2
|
jsonwebtoken: ^9.0.2
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.42
|
medusa-test-utils: ^1.1.42
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
scrypt-kdf: ^2.0.1
|
scrypt-kdf: ^2.0.1
|
||||||
@@ -4336,7 +4331,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/cart@workspace:packages/modules/cart"
|
resolution: "@medusajs/cart@workspace:packages/modules/cart"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": "workspace:^"
|
"@medusajs/types": "workspace:^"
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -4345,9 +4339,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4380,7 +4372,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/currency@workspace:packages/modules/currency"
|
resolution: "@medusajs/currency@workspace:packages/modules/currency"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -4389,9 +4380,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: "workspace:^"
|
medusa-test-utils: "workspace:^"
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4413,9 +4402,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4544,7 +4531,7 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/file@workspace:packages/modules/file"
|
resolution: "@medusajs/file@workspace:packages/modules/file"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.10
|
"@medusajs/modules-sdk": ^1.12.11
|
||||||
"@medusajs/types": ^1.11.15
|
"@medusajs/types": ^1.11.15
|
||||||
"@medusajs/utils": ^1.11.8
|
"@medusajs/utils": ^1.11.8
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -4553,11 +4540,8 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
faker: ^5.5.3
|
faker: ^5.5.3
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
lodash: ^4.17.21
|
|
||||||
medusa-test-utils: ^1.1.43
|
medusa-test-utils: ^1.1.43
|
||||||
pg-god: ^1.0.12
|
pg-god: ^1.0.12
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
@@ -4595,9 +4579,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4653,9 +4635,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.43
|
medusa-test-utils: ^1.1.43
|
||||||
rimraf: ^5.0.1
|
rimraf: ^5.0.1
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4905,9 +4885,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4953,9 +4931,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -4998,9 +4974,7 @@ __metadata:
|
|||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
bignumber.js: ^9.1.2
|
bignumber.js: ^9.1.2
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-jest: ^29.1.1
|
ts-jest: ^29.1.1
|
||||||
@@ -5014,7 +4988,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/pricing@workspace:packages/modules/pricing"
|
resolution: "@medusajs/pricing@workspace:packages/modules/pricing"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -5023,9 +4996,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-jest: ^29.1.1
|
ts-jest: ^29.1.1
|
||||||
@@ -5039,7 +5010,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/product@workspace:packages/modules/product"
|
resolution: "@medusajs/product@workspace:packages/modules/product"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -5048,11 +5018,8 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
faker: ^5.5.3
|
faker: ^5.5.3
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
lodash: ^4.17.21
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
pg-god: ^1.0.12
|
pg-god: ^1.0.12
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
@@ -5066,7 +5033,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/promotion@workspace:packages/modules/promotion"
|
resolution: "@medusajs/promotion@workspace:packages/modules/promotion"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": 1.11.9
|
"@medusajs/utils": 1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -5075,9 +5041,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-jest: ^29.1.1
|
ts-jest: ^29.1.1
|
||||||
@@ -5091,7 +5055,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/region@workspace:packages/modules/region"
|
resolution: "@medusajs/region@workspace:packages/modules/region"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -5100,9 +5063,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: "workspace:^"
|
medusa-test-utils: "workspace:^"
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -5115,7 +5076,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/sales-channel@workspace:packages/modules/sales-channel"
|
resolution: "@medusajs/sales-channel@workspace:packages/modules/sales-channel"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.9
|
|
||||||
"@medusajs/types": ^1.11.14
|
"@medusajs/types": ^1.11.14
|
||||||
"@medusajs/utils": ^1.11.7
|
"@medusajs/utils": ^1.11.7
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -5124,9 +5084,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.42
|
medusa-test-utils: ^1.1.42
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -5148,9 +5106,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^5.0.1
|
rimraf: ^5.0.1
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -5163,7 +5119,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/store@workspace:packages/modules/store"
|
resolution: "@medusajs/store@workspace:packages/modules/store"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -5172,9 +5127,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: "workspace:^"
|
medusa-test-utils: "workspace:^"
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -5196,9 +5149,7 @@ __metadata:
|
|||||||
"@mikro-orm/postgresql": 5.9.7
|
"@mikro-orm/postgresql": 5.9.7
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.42
|
medusa-test-utils: ^1.1.42
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -5343,7 +5294,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/user@workspace:packages/modules/user"
|
resolution: "@medusajs/user@workspace:packages/modules/user"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.10
|
|
||||||
"@medusajs/types": ^1.11.15
|
"@medusajs/types": ^1.11.15
|
||||||
"@medusajs/utils": ^1.11.8
|
"@medusajs/utils": ^1.11.8
|
||||||
"@mikro-orm/cli": 5.9.7
|
"@mikro-orm/cli": 5.9.7
|
||||||
@@ -5354,10 +5304,8 @@ __metadata:
|
|||||||
"@swc/jest": ^0.2.36
|
"@swc/jest": ^0.2.36
|
||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
jsonwebtoken: ^9.0.2
|
jsonwebtoken: ^9.0.2
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.43
|
medusa-test-utils: ^1.1.43
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
@@ -5395,7 +5343,6 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/workflow-engine-inmemory@workspace:packages/modules/workflow-engine-inmemory"
|
resolution: "@medusajs/workflow-engine-inmemory@workspace:packages/modules/workflow-engine-inmemory"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@medusajs/modules-sdk": ^1.12.11
|
|
||||||
"@medusajs/types": ^1.11.16
|
"@medusajs/types": ^1.11.16
|
||||||
"@medusajs/utils": ^1.11.9
|
"@medusajs/utils": ^1.11.9
|
||||||
"@medusajs/workflows-sdk": ^0.1.6
|
"@medusajs/workflows-sdk": ^0.1.6
|
||||||
@@ -5406,9 +5353,7 @@ __metadata:
|
|||||||
awilix: ^8.0.0
|
awilix: ^8.0.0
|
||||||
cron-parser: ^4.9.0
|
cron-parser: ^4.9.0
|
||||||
cross-env: ^5.2.1
|
cross-env: ^5.2.1
|
||||||
dotenv: ^16.4.5
|
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
knex: 2.4.2
|
|
||||||
medusa-test-utils: ^1.1.44
|
medusa-test-utils: ^1.1.44
|
||||||
rimraf: ^3.0.2
|
rimraf: ^3.0.2
|
||||||
ts-node: ^10.9.1
|
ts-node: ^10.9.1
|
||||||
|
|||||||
Reference in new issue
Block a user