Feat(medusa-test-utils, utils, pricing, product, link-modules): upgrade mikro orm version to latest (#5985)

* update mikro-orm version

* add changeset

* update product tests

* add optional number serializer util

* upgrade cart mikro-orm versions

* clean up test
This commit is contained in:
Philip Korsholm
2024-01-02 17:11:55 +01:00
committed by GitHub
parent 925feea04a
commit d16d10619d
15 changed files with 181 additions and 131 deletions
+4 -4
View File
@@ -39,7 +39,7 @@
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
},
"devDependencies": {
"@mikro-orm/cli": "5.7.12",
"@mikro-orm/cli": "5.9.7",
"cross-env": "^5.2.1",
"jest": "^29.6.3",
"medusa-test-utils": "^1.1.40",
@@ -53,9 +53,9 @@
"@medusajs/modules-sdk": "^1.12.5",
"@medusajs/types": "^1.11.9",
"@medusajs/utils": "^1.11.2",
"@mikro-orm/core": "5.7.12",
"@mikro-orm/migrations": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.0",
"dotenv": "^16.1.4",
"knex": "2.4.2"
+4 -4
View File
@@ -39,7 +39,7 @@
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
},
"devDependencies": {
"@mikro-orm/cli": "5.7.12",
"@mikro-orm/cli": "5.9.7",
"cross-env": "^5.2.1",
"jest": "^29.6.3",
"medusa-test-utils": "^1.1.40",
@@ -53,9 +53,9 @@
"@medusajs/modules-sdk": "^1.12.5",
"@medusajs/types": "^1.11.9",
"@medusajs/utils": "^1.11.2",
"@mikro-orm/core": "5.7.12",
"@mikro-orm/migrations": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.0",
"dotenv": "^16.1.4",
"knex": "2.4.2"
+2 -2
View File
@@ -42,8 +42,8 @@
"@medusajs/modules-sdk": "^1.12.5",
"@medusajs/types": "^1.11.9",
"@medusajs/utils": "^1.11.2",
"@mikro-orm/core": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.0"
}
}
+2 -2
View File
@@ -30,8 +30,8 @@
"typescript": "^5.1.6"
},
"dependencies": {
"@mikro-orm/migrations": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"medusa-core-utils": "^1.2.0",
"pg-god": "^1.0.12",
"randomatic": "^3.1.1"
+4 -4
View File
@@ -39,7 +39,7 @@
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
},
"devDependencies": {
"@mikro-orm/cli": "5.7.12",
"@mikro-orm/cli": "5.9.7",
"cross-env": "^5.2.1",
"jest": "^29.6.3",
"medusa-test-utils": "^1.1.40",
@@ -53,9 +53,9 @@
"@medusajs/modules-sdk": "^1.12.5",
"@medusajs/types": "^1.11.9",
"@medusajs/utils": "^1.11.2",
"@mikro-orm/core": "5.7.12",
"@mikro-orm/migrations": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.0",
"dotenv": "^16.1.4",
"knex": "2.4.2"
@@ -181,8 +181,10 @@ describe("Product module", function () {
it("should have a connection that is the shared connection", async () => {
expect(
(module as any).baseRepository_.manager_.getConnection().client
).toEqual(sharedPgConnection)
JSON.stringify(
(module as any).baseRepository_.manager_.getConnection().client
)
).toEqual(JSON.stringify(sharedPgConnection))
})
})
@@ -265,8 +265,8 @@ describe("ProductModuleService products", function () {
sku: createdVariant.sku,
allow_backorder: false,
manage_inventory: true,
inventory_quantity: "100",
variant_rank: "0",
inventory_quantity: 100,
variant_rank: 0,
options: expect.arrayContaining([
expect.objectContaining({
id: expect.any(String),
+4 -4
View File
@@ -39,7 +39,7 @@
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
},
"devDependencies": {
"@mikro-orm/cli": "5.7.12",
"@mikro-orm/cli": "5.9.7",
"cross-env": "^5.2.1",
"faker": "^6.6.6",
"jest": "^29.6.3",
@@ -55,9 +55,9 @@
"@medusajs/modules-sdk": "^1.12.5",
"@medusajs/types": "^1.11.9",
"@medusajs/utils": "^1.11.2",
"@mikro-orm/core": "5.7.12",
"@mikro-orm/migrations": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.0",
"dotenv": "^16.1.4",
"knex": "2.4.2",
+16 -3
View File
@@ -1,4 +1,8 @@
import { DALUtils, generateEntityId } from "@medusajs/utils"
import {
DALUtils,
generateEntityId,
optionalNumericSerializer,
} from "@medusajs/utils"
import {
BeforeCreate,
Cascade,
@@ -66,7 +70,11 @@ class ProductVariant {
// Note: Upon serialization, this turns to a string. This is on purpose, because you would loose
// precision if you cast numeric to JS number, as JS number is a float.
// Ref: https://github.com/mikro-orm/mikro-orm/issues/2295
@Property({ columnType: "numeric", default: 100 })
@Property({
columnType: "numeric",
default: 100,
serializer: optionalNumericSerializer,
})
inventory_quantity?: number = 100
@Property({ columnType: "boolean", default: false })
@@ -102,7 +110,12 @@ class ProductVariant {
@Property({ columnType: "jsonb", nullable: true })
metadata?: Record<string, unknown> | null
@Property({ columnType: "numeric", nullable: true, default: 0 })
@Property({
columnType: "numeric",
nullable: true,
default: 0,
serializer: optionalNumericSerializer,
})
variant_rank?: number | null
@Property({ columnType: "text", nullable: true })
+4 -4
View File
@@ -39,7 +39,7 @@
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
},
"devDependencies": {
"@mikro-orm/cli": "5.7.12",
"@mikro-orm/cli": "5.9.7",
"cross-env": "^5.2.1",
"jest": "^29.6.3",
"medusa-test-utils": "^1.1.40",
@@ -53,9 +53,9 @@
"@medusajs/modules-sdk": "^1.12.5",
"@medusajs/types": "^1.11.9",
"@medusajs/utils": "^1.11.2",
"@mikro-orm/core": "5.7.12",
"@mikro-orm/migrations": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.0",
"dotenv": "^16.1.4",
"knex": "2.4.2"
+3 -3
View File
@@ -31,9 +31,9 @@
},
"dependencies": {
"@medusajs/types": "^1.11.9",
"@mikro-orm/core": "5.7.12",
"@mikro-orm/migrations": "5.7.12",
"@mikro-orm/postgresql": "5.7.12",
"@mikro-orm/core": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.1",
"knex": "2.4.2",
"ulid": "^2.3.0"
+1
View File
@@ -21,6 +21,7 @@ export * from "./map-object-to"
export * from "./medusa-container"
export * from "./object-from-string-path"
export * from "./object-to-string-path"
export * from "./optional-numeric-serializer"
export * from "./promise-all"
export * from "./remote-query-object-from-string"
export * from "./remote-query-object-to-string"
@@ -0,0 +1,4 @@
import { isDefined } from "./is-defined"
export const optionalNumericSerializer = (value) =>
isDefined(value) && value !== null ? Number(value) : value