diff --git a/integration-tests/api/package.json b/integration-tests/api/package.json index d593ee92b6..bb79684b06 100644 --- a/integration-tests/api/package.json +++ b/integration-tests/api/package.json @@ -37,6 +37,6 @@ "form-data": "^4.0.0", "jest": "^29.7.0", "jest-environment-node": "^29.7.0", - "typescript": "^4.1.3" + "typescript": "^5.3.3" } } diff --git a/integration-tests/http/package.json b/integration-tests/http/package.json index 3746558a2b..32807ea86a 100644 --- a/integration-tests/http/package.json +++ b/integration-tests/http/package.json @@ -40,6 +40,6 @@ "@swc/jest": "^0.2.36", "jest": "^29.7.0", "jest-environment-node": "^29.7.0", - "typescript": "^4.1.3" + "typescript": "^5.3.3" } } diff --git a/integration-tests/modules/package.json b/integration-tests/modules/package.json index 788da462f0..bf4f947ff3 100644 --- a/integration-tests/modules/package.json +++ b/integration-tests/modules/package.json @@ -41,6 +41,6 @@ "@swc/jest": "^0.2.36", "jest": "^29.7.0", "jest-environment-node": "^29.7.0", - "typescript": "^4.1.3" + "typescript": "^5.3.3" } } diff --git a/packages/cli/medusa-cli/package.json b/packages/cli/medusa-cli/package.json index 4c7d989b63..8ca7c9f4c7 100644 --- a/packages/cli/medusa-cli/package.json +++ b/packages/cli/medusa-cli/package.json @@ -36,7 +36,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "dependencies": { "@medusajs/utils": "^1.11.2", diff --git a/packages/cli/medusa-dev-cli/package.json b/packages/cli/medusa-dev-cli/package.json index 0a0557a1b2..315e2d4b00 100644 --- a/packages/cli/medusa-dev-cli/package.json +++ b/packages/cli/medusa-dev-cli/package.json @@ -29,7 +29,7 @@ "@swc/jest": "^0.2.36", "cross-env": "^7.0.3", "jest": "^29.7.0", - "typescript": "^4.4.4" + "typescript": "^5.3.3" }, "homepage": "https://github.com/medusajs/medusa/tree/master/packages/medusa-dev-cli#readme", "keywords": [ diff --git a/packages/core/utils/src/bundles.ts b/packages/core/utils/src/bundles.ts index 1fc5b18f06..da46fd2d6c 100644 --- a/packages/core/utils/src/bundles.ts +++ b/packages/core/utils/src/bundles.ts @@ -1,9 +1,13 @@ +export * as ApiKeyUtils from "./api-key" export * as DALUtils from "./dal" export * as DecoratorUtils from "./decorators" export * as DefaultsUtils from "./defaults" +export * as DMLUtils from "./dml" export * as EventBusUtils from "./event-bus" export * as FeatureFlagUtils from "./feature-flags" export * as FulfillmentUtils from "./fulfillment" +export * as InventoryUtils from "./inventory" +export * as LinkUtils from "./link" export * as ModulesSdkUtils from "./modules-sdk" export * as OrchestrationUtils from "./orchestration" export * as OrderUtils from "./order" @@ -12,6 +16,3 @@ export * as PromotionUtils from "./promotion" export * as SearchUtils from "./search" export * as ShippingProfileUtils from "./shipping" export * as UserUtils from "./user" -export * as InventoryUtils from "./inventory" -export * as LinkUtils from "./link" -export * as ApiKeyUtils from "./api-key" diff --git a/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts b/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts index 0a0f56a330..47f5fdd986 100644 --- a/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts +++ b/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts @@ -1,39 +1,40 @@ import { - Enum, + BeforeCreate, Entity, - OneToMany, - Property, - OneToOne, + Enum, + Filter, ManyToMany, ManyToOne, - Filter, - PrimaryKey, - BeforeCreate, + OneToMany, + OneToOne, OnInit, + PrimaryKey, + Property, } from "@mikro-orm/core" -import { DmlEntity } from "../entity" +import { DALUtils } from "../../bundles" import { - pluralize, camelToSnakeCase, createPsqlIndexStatementHelper, - toCamelCase, generateEntityId, + isDefined, + pluralize, + toCamelCase, } from "../../common" import { upperCaseFirst } from "../../common/upper-case-first" +import { DmlEntity } from "../entity" +import { HasMany } from "../relations/has-many" +import { HasOne } from "../relations/has-one" +import { ManyToMany as DmlManyToMany } from "../relations/many-to-many" import type { - Infer, - PropertyType, EntityCascades, + EntityConstructor, + Infer, KnownDataTypes, PropertyMetadata, - RelationshipType, - EntityConstructor, + PropertyType, RelationshipMetadata, + RelationshipType, } from "../types" -import { DALUtils } from "../../bundles" -import { HasOne } from "../relations/has-one" -import { HasMany } from "../relations/has-many" -import { ManyToMany as DmlManyToMany } from "../relations/many-to-many" /** * DML entity data types to PostgreSQL data types via @@ -169,7 +170,12 @@ export function createMikrORMEntity() { Enum({ items: () => field.dataType.options!.choices, nullable: field.nullable, - default: field.defaultValue, + /** + * MikroORM does not ignore undefined values for default when generating + * the database schema SQL. Conditionally add it here to prevent undefined + * from being set as default value in SQL. + */ + ...(isDefined(field.defaultValue) && { default: field.defaultValue }), })(MikroORMEntity.prototype, field.fieldName) return } @@ -217,7 +223,12 @@ export function createMikrORMEntity() { columnType, type: propertyType, nullable: field.nullable, - default: field.defaultValue, + /** + * MikroORM does not ignore undefined values for default when generating + * the database schema SQL. Conditionally add it here to prevent undefined + * from being set as default value in SQL. + */ + ...(isDefined(field.defaultValue) && { default: field.defaultValue }), })(MikroORMEntity.prototype, field.fieldName) } diff --git a/packages/core/utils/src/dml/index.ts b/packages/core/utils/src/dml/index.ts new file mode 100644 index 0000000000..73bd0fe2c3 --- /dev/null +++ b/packages/core/utils/src/dml/index.ts @@ -0,0 +1,2 @@ +export * from "./entity-builder" +export * from "./helpers/create-mikro-orm-entity" diff --git a/packages/core/utils/src/index.ts b/packages/core/utils/src/index.ts index fa32d65f4f..d11b798b67 100644 --- a/packages/core/utils/src/index.ts +++ b/packages/core/utils/src/index.ts @@ -1,15 +1,20 @@ +export * from "./api-key" export * from "./auth" export * from "./bundles" export * from "./common" export * from "./dal" export * from "./decorators" export * from "./defaults" +export * from "./dml" export * from "./event-bus" export * from "./exceptions" export * from "./feature-flags" +export * from "./file" export * from "./fulfillment" export * from "./inventory" +export * from "./link" export * from "./modules-sdk" +export * from "./notification" export * from "./orchestration" export * from "./order" export * from "./payment" @@ -21,9 +26,5 @@ export * from "./shipping" export * from "./totals" export * from "./totals/big-number" export * from "./user" -export * from "./api-key" -export * from "./link" -export * from "./file" -export * from "./notification" export const MedusaModuleType = Symbol.for("MedusaModule") diff --git a/packages/medusa/package.json b/packages/medusa/package.json index 1f82cfe66b..573aa23197 100644 --- a/packages/medusa/package.json +++ b/packages/medusa/package.json @@ -33,7 +33,7 @@ "rimraf": "^5.0.1", "supertest": "^4.0.2", "ts-jest": "^29.1.1", - "typescript": "^4.4.4" + "typescript": "^5.3.3" }, "scripts": { "watch": "tsc --build --watch", diff --git a/packages/modules/providers/auth-emailpass/package.json b/packages/modules/providers/auth-emailpass/package.json index 118a52b279..5a30819eba 100644 --- a/packages/modules/providers/auth-emailpass/package.json +++ b/packages/modules/providers/auth-emailpass/package.json @@ -27,7 +27,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "dependencies": { "@medusajs/utils": "^1.11.7", diff --git a/packages/modules/providers/file-local/package.json b/packages/modules/providers/file-local/package.json index 0954cc9fc6..758d950704 100644 --- a/packages/modules/providers/file-local/package.json +++ b/packages/modules/providers/file-local/package.json @@ -26,7 +26,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "dependencies": { "@medusajs/utils": "^1.11.7" diff --git a/packages/modules/providers/file-s3/package.json b/packages/modules/providers/file-s3/package.json index aafa7677d3..a50e3006bc 100644 --- a/packages/modules/providers/file-s3/package.json +++ b/packages/modules/providers/file-s3/package.json @@ -28,7 +28,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "dependencies": { "@aws-sdk/client-s3": "^3.556.0", diff --git a/packages/modules/providers/fulfillment-manual/package.json b/packages/modules/providers/fulfillment-manual/package.json index ce5ae57b40..da5a999f09 100644 --- a/packages/modules/providers/fulfillment-manual/package.json +++ b/packages/modules/providers/fulfillment-manual/package.json @@ -26,7 +26,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "dependencies": { "@medusajs/utils": "^1.11.7", diff --git a/packages/modules/providers/notification-local/package.json b/packages/modules/providers/notification-local/package.json index 41604d853a..c948854dc4 100644 --- a/packages/modules/providers/notification-local/package.json +++ b/packages/modules/providers/notification-local/package.json @@ -27,7 +27,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "dependencies": { "@medusajs/utils": "^1.11.7" diff --git a/packages/modules/providers/notification-sendgrid/package.json b/packages/modules/providers/notification-sendgrid/package.json index 3a9993e7de..f68048ed87 100644 --- a/packages/modules/providers/notification-sendgrid/package.json +++ b/packages/modules/providers/notification-sendgrid/package.json @@ -29,7 +29,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "dependencies": { "@medusajs/utils": "^1.11.7", diff --git a/packages/modules/providers/payment-stripe/package.json b/packages/modules/providers/payment-stripe/package.json index 81ce5131fc..5cb866a286 100644 --- a/packages/modules/providers/payment-stripe/package.json +++ b/packages/modules/providers/payment-stripe/package.json @@ -29,7 +29,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^4.9.5" + "typescript": "^5.3.3" }, "peerDependencies": { "@medusajs/medusa": "^1.12.0" diff --git a/yarn.lock b/yarn.lock index d896ceb221..c4885bc9df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4256,7 +4256,7 @@ __metadata: jest: ^29.7.0 rimraf: ^5.0.1 scrypt-kdf: ^2.0.1 - typescript: ^4.9.5 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -4527,7 +4527,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^4.9.5 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -4542,7 +4542,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^4.9.5 + typescript: ^5.3.3 ulid: ^2.3.0 languageName: unknown linkType: soft @@ -4585,7 +4585,7 @@ __metadata: express: ^4.17.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^4.9.5 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -4755,7 +4755,7 @@ __metadata: rimraf: ^5.0.1 semver: ^7.3.8 stack-trace: ^0.0.10 - typescript: ^4.9.5 + typescript: ^5.3.3 ulid: ^2.3.0 winston: ^3.8.2 yargs: ^15.3.1 @@ -4849,7 +4849,7 @@ __metadata: rimraf: ^5.0.1 supertest: ^4.0.2 ts-jest: ^29.1.1 - typescript: ^4.4.4 + typescript: ^5.3.3 uuid: ^9.0.0 zod: 3.22.4 languageName: unknown @@ -4885,7 +4885,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^4.9.5 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -4900,7 +4900,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^4.9.5 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -4993,7 +4993,7 @@ __metadata: jest: ^29.7.0 rimraf: ^5.0.1 stripe: latest - typescript: ^4.9.5 + typescript: ^5.3.3 peerDependencies: "@medusajs/medusa": ^1.12.0 languageName: unknown @@ -18385,7 +18385,7 @@ __metadata: jest-environment-node: ^29.7.0 pg: ^8.11.0 typeorm: ^0.3.16 - typescript: ^4.1.3 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -18421,7 +18421,7 @@ __metadata: jest-environment-node: ^29.7.0 medusa-test-utils: "workspace:*" pg: ^8.11.0 - typescript: ^4.1.3 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -18458,7 +18458,7 @@ __metadata: medusa-test-utils: "workspace:*" pg: ^8.11.0 typeorm: ^0.3.16 - typescript: ^4.1.3 + typescript: ^5.3.3 languageName: unknown linkType: soft @@ -21276,7 +21276,7 @@ __metadata: jest: ^29.7.0 lodash: ^4.17.21 signal-exit: ^3.0.7 - typescript: ^4.4.4 + typescript: ^5.3.3 verdaccio: ^4.10.0 yargs: ^15.4.1 bin: @@ -28598,7 +28598,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:4.9.5, typescript@npm:^4.1.3, typescript@npm:^4.4.4, typescript@npm:^4.9.5": +"typescript@npm:4.9.5, typescript@npm:^4.1.3": version: 4.9.5 resolution: "typescript@npm:4.9.5" bin: @@ -28648,7 +28648,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@4.9.5#~builtin, typescript@patch:typescript@^4.1.3#~builtin, typescript@patch:typescript@^4.4.4#~builtin, typescript@patch:typescript@^4.9.5#~builtin": +"typescript@patch:typescript@4.9.5#~builtin, typescript@patch:typescript@^4.1.3#~builtin": version: 4.9.5 resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=7ad353" bin: