chore: move to swc/jest (#7739)

* chore: move to swc

* chore: fix tax rate tests

* chore: undo failed test

* chore: fix unit tests script

* chore: use node 20

* Update scripts/run-workspace-unit-tests-in-chunks.sh
This commit is contained in:
Riqwan Thamir authored and GitHub committed 2024-06-20 12:59:33 +02:00
1 parent f61557712c
commit 03924a4ff6
136 files changed
+385 -418

No files matched your search

+1 -1
View File
@@ -58,7 +58,7 @@
"lint:path": "eslint --ignore-path .eslintignore --ext .js,.ts,.tsx", "lint:path": "eslint --ignore-path .eslintignore --ext .js,.ts,.tsx",
"prettier": "prettier", "prettier": "prettier",
"jest": "jest", "jest": "jest",
"test": "turbo run test --concurrency=50% --no-daemon --no-cache --force --filter='./packages/*' --filter='./packages/core/*' --filter='./packages/cli/*' --filter='./packages/modules/*' --filter='./packages/modules/providers/*'", "test": "turbo run test --concurrency=50% --no-daemon --no-cache --force",
"test:chunk": "./scripts/run-workspace-unit-tests-in-chunks.sh", "test:chunk": "./scripts/run-workspace-unit-tests-in-chunks.sh",
"test:integration:packages": "turbo run test:integration --concurrency=50% --no-daemon --no-cache --force --filter='./packages/*' --filter='./packages/core/*' --filter='./packages/cli/*' --filter='./packages/modules/*' --filter='./packages/modules/providers/*'", "test:integration:packages": "turbo run test:integration --concurrency=50% --no-daemon --no-cache --force --filter='./packages/*' --filter='./packages/core/*' --filter='./packages/cli/*' --filter='./packages/modules/*' --filter='./packages/modules/providers/*'",
"test:integration:api": "turbo run test:integration:chunk --concurrency=50% --no-daemon --no-cache --force --filter=integration-tests-api", "test:integration:api": "turbo run test:integration:chunk --concurrency=50% --no-daemon --no-cache --force --filter=integration-tests-api",
+1 -9
View File
@@ -1,13 +1,5 @@
module.exports = { module.exports = {
transform: { transform: { "^.+\\.[jt]s?$": "@swc/jest" },
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
testEnvironment: `node`, testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`], moduleFileExtensions: [`js`, `ts`],
} }
-1
View File
@@ -24,7 +24,6 @@
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"jest": "^29.7.0", "jest": "^29.7.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"dependencies": { "dependencies": {
@@ -84,7 +84,7 @@ export type RegisterModuleJoinerConfig =
| ModuleJoinerConfig | ModuleJoinerConfig
| ((modules: ModuleJoinerConfig[]) => ModuleJoinerConfig) | ((modules: ModuleJoinerConfig[]) => ModuleJoinerConfig)
export class MedusaModule { class MedusaModule {
private static instances_: Map<string, { [key: string]: IModuleService }> = private static instances_: Map<string, { [key: string]: IModuleService }> =
new Map() new Map()
private static modules_: Map<string, ModuleAlias[]> = new Map() private static modules_: Map<string, ModuleAlias[]> = new Map()
@@ -589,4 +589,6 @@ export class MedusaModule {
} }
global.MedusaModule ??= MedusaModule global.MedusaModule ??= MedusaModule
exports.MedusaModule = global.MedusaModule const GlobalMedusaModule = global.MedusaModule as typeof MedusaModule
export { GlobalMedusaModule as MedusaModule }
+1 -1
View File
@@ -63,7 +63,7 @@ export class RemoteLink {
) )
} }
for (const mod of modulesLoaded) { for (const mod of modulesLoaded || []) {
this.addModule(mod) this.addModule(mod)
} }
} }
@@ -39,7 +39,7 @@ export class RemoteQuery {
) )
} }
for (const mod of modulesLoaded) { for (const mod of modulesLoaded || []) {
if (!mod.__definition.isQueryable) { if (!mod.__definition.isQueryable) {
continue continue
} }
+1 -9
View File
@@ -1,13 +1,5 @@
module.exports = { module.exports = {
transform: { transform: { "^.+\\.[jt]s?$": "@swc/jest" },
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
testEnvironment: `node`, testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`], moduleFileExtensions: [`js`, `ts`],
} }
-1
View File
@@ -23,7 +23,6 @@
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"jest": "^29.7.0", "jest": "^29.7.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"dependencies": { "dependencies": {
@@ -32,7 +32,7 @@ export class GlobalWorkflow extends WorkflowManager {
} else if (Array.isArray(modulesLoaded) && modulesLoaded.length) { } else if (Array.isArray(modulesLoaded) && modulesLoaded.length) {
container = createMedusaContainer() container = createMedusaContainer()
for (const mod of modulesLoaded) { for (const mod of modulesLoaded || []) {
const registrationName = mod.__definition.registrationName const registrationName = mod.__definition.registrationName
container.register(registrationName, asValue(mod)) container.register(registrationName, asValue(mod))
} }
@@ -79,7 +79,7 @@ export class LocalWorkflow {
} else if (Array.isArray(modulesLoaded) && modulesLoaded.length) { } else if (Array.isArray(modulesLoaded) && modulesLoaded.length) {
container = createMedusaContainer() container = createMedusaContainer()
for (const mod of modulesLoaded) { for (const mod of modulesLoaded || []) {
const registrationName = mod.__definition.registrationName const registrationName = mod.__definition.registrationName
container.register(registrationName, asValue(mod)) container.register(registrationName, asValue(mod))
} }
@@ -11,7 +11,6 @@ import {
TransactionStepsDefinition, TransactionStepsDefinition,
} from "../transaction" } from "../transaction"
import { WorkflowScheduler } from "./scheduler" import { WorkflowScheduler } from "./scheduler"
import { MedusaError } from "@medusajs/utils"
export interface WorkflowDefinition { export interface WorkflowDefinition {
id: string id: string
@@ -51,7 +50,7 @@ export type WorkflowStepHandler = (
args: WorkflowStepHandlerArguments args: WorkflowStepHandlerArguments
) => Promise<unknown> ) => Promise<unknown>
export class WorkflowManager { class WorkflowManager {
protected static workflows: Map<string, WorkflowDefinition> = new Map() protected static workflows: Map<string, WorkflowDefinition> = new Map()
protected static scheduler = new WorkflowScheduler() protected static scheduler = new WorkflowScheduler()
@@ -79,10 +78,7 @@ export class WorkflowManager {
static getTransactionDefinition(workflowId): OrchestratorBuilder { static getTransactionDefinition(workflowId): OrchestratorBuilder {
if (!WorkflowManager.workflows.has(workflowId)) { if (!WorkflowManager.workflows.has(workflowId)) {
throw new MedusaError( throw new Error(`Workflow with id "${workflowId}" not found.`)
MedusaError.Types.NOT_FOUND,
`Workflow with id "${workflowId}" not found.`
)
} }
const workflow = WorkflowManager.workflows.get(workflowId)! const workflow = WorkflowManager.workflows.get(workflowId)!
@@ -232,4 +228,6 @@ export class WorkflowManager {
} }
global.WorkflowManager ??= WorkflowManager global.WorkflowManager ??= WorkflowManager
exports.WorkflowManager = global.WorkflowManager const GlobalWorkflowManager = global.WorkflowManager
export { GlobalWorkflowManager as WorkflowManager }
+1 -9
View File
@@ -1,13 +1,5 @@
module.exports = { module.exports = {
transform: { transform: { "^.+\\.[jt]s?$": "@swc/jest" },
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
testEnvironment: `node`, testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`], moduleFileExtensions: [`js`, `ts`],
} }
-1
View File
@@ -25,7 +25,6 @@
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"jest": "^29.7.0", "jest": "^29.7.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"dependencies": { "dependencies": {
@@ -2,7 +2,7 @@ import { LocalWorkflow } from "@medusajs/orchestration"
import { LoadedModule, MedusaContainer } from "@medusajs/types" import { LoadedModule, MedusaContainer } from "@medusajs/types"
import { ExportedWorkflow } from "./helper" import { ExportedWorkflow } from "./helper"
export class MedusaWorkflow { class MedusaWorkflow {
static workflows: Record< static workflows: Record<
string, string,
( (
@@ -28,4 +28,6 @@ export class MedusaWorkflow {
} }
global.MedusaWorkflow ??= MedusaWorkflow global.MedusaWorkflow ??= MedusaWorkflow
exports.MedusaWorkflow = global.MedusaWorkflow const GlobalMedusaWorkflow = global.MedusaWorkflow
export { GlobalMedusaWorkflow as MedusaWorkflow }
-1
View File
@@ -32,7 +32,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"supertest": "^4.0.2", "supertest": "^4.0.2",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3" "typescript": "^5.3.3"
}, },
"scripts": { "scripts": {
+6 -4
View File
@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types", "^@types": "<rootDir>/src/types",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
-1
View File
@@ -40,7 +40,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"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-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
@@ -1,7 +1,7 @@
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/modules-sdk" import { Modules } from "@medusajs/modules-sdk"
import { createAuthIdentities } from "../../__fixtures__/auth-identity" import { IAuthModuleService } from "@medusajs/types"
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils" import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
import { createAuthIdentities } from "../../__fixtures__/auth-identity"
jest.setTimeout(30000) jest.setTimeout(30000)
+6 -4
View File
@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types", "^@types": "<rootDir>/src/types",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
-2
View File
@@ -39,8 +39,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"medusa-test-utils": "^1.1.42", "medusa-test-utils": "^1.1.42",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
@@ -5,6 +5,7 @@ import {
OnInit, OnInit,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import { import {
@@ -52,7 +53,7 @@ export default class ProviderIdentity {
@ManyToOne(() => AuthIdentity, { @ManyToOne(() => AuthIdentity, {
persist: false, persist: false,
}) })
auth_identity: AuthIdentity auth_identity: Rel<AuthIdentity>
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
user_metadata: Record<string, unknown> | null user_metadata: Record<string, unknown> | null
@@ -24,7 +24,6 @@
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"jest": "^29.7.0", "jest": "^29.7.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"scripts": { "scripts": {
+1 -9
View File
@@ -1,13 +1,5 @@
module.exports = { module.exports = {
transform: { transform: { "^.+\\.[jt]s$": "@swc/jest" },
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
testEnvironment: `node`, testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`], moduleFileExtensions: [`js`, `ts`],
} }
@@ -24,7 +24,6 @@
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"jest": "^29.7.0", "jest": "^29.7.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"scripts": { "scripts": {
+6 -4
View File
@@ -7,11 +7,13 @@ module.exports = {
"^@utils": "<rootDir>/src/utils", "^@utils": "<rootDir>/src/utils",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
-1
View File
@@ -40,7 +40,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"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-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
+5 -4
View File
@@ -16,6 +16,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Address from "./address" import Address from "./address"
import LineItem from "./line-item" import LineItem from "./line-item"
@@ -115,7 +116,7 @@ export default class Cart {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
nullable: true, nullable: true,
}) })
shipping_address: Address | null shipping_address: Rel<Address> | null
@BillingAddressIdIndex() @BillingAddressIdIndex()
@ManyToOne({ @ManyToOne({
@@ -131,7 +132,7 @@ export default class Cart {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
nullable: true, nullable: true,
}) })
billing_address: Address | null billing_address: Rel<Address> | null
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -139,12 +140,12 @@ export default class Cart {
@OneToMany(() => LineItem, (lineItem) => lineItem.cart, { @OneToMany(() => LineItem, (lineItem) => lineItem.cart, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
}) })
items = new Collection<LineItem>(this) items = new Collection<Rel<LineItem>>(this)
@OneToMany(() => ShippingMethod, (shippingMethod) => shippingMethod.cart, { @OneToMany(() => ShippingMethod, (shippingMethod) => shippingMethod.cart, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
}) })
shipping_methods = new Collection<ShippingMethod>(this) shipping_methods = new Collection<Rel<ShippingMethod>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -11,6 +11,7 @@ import {
ManyToOne, ManyToOne,
OnInit, OnInit,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import AdjustmentLine from "./adjustment-line" import AdjustmentLine from "./adjustment-line"
import LineItem from "./line-item" import LineItem from "./line-item"
@@ -42,7 +43,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class LineItemAdjustment extends AdjustmentLine { export default class LineItemAdjustment extends AdjustmentLine {
@ManyToOne({ entity: () => LineItem, persist: false }) @ManyToOne({ entity: () => LineItem, persist: false })
item: LineItem item: Rel<LineItem>
@LineItemIdIndex() @LineItemIdIndex()
@ManyToOne({ @ManyToOne({
@@ -10,6 +10,7 @@ import {
ManyToOne, ManyToOne,
OnInit, OnInit,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import LineItem from "./line-item" import LineItem from "./line-item"
import TaxLine from "./tax-line" import TaxLine from "./tax-line"
@@ -38,7 +39,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class LineItemTaxLine extends TaxLine { export default class LineItemTaxLine extends TaxLine {
@ManyToOne({ entity: () => LineItem, persist: false }) @ManyToOne({ entity: () => LineItem, persist: false })
item: LineItem item: Rel<LineItem>
@LineItemIdIndex() @LineItemIdIndex()
@ManyToOne({ @ManyToOne({
@@ -18,6 +18,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Cart from "./cart" import Cart from "./cart"
import LineItemAdjustment from "./line-item-adjustment" import LineItemAdjustment from "./line-item-adjustment"
@@ -76,7 +77,7 @@ export default class LineItem {
cart_id: string cart_id: string
@ManyToOne({ entity: () => Cart, persist: false }) @ManyToOne({ entity: () => Cart, persist: false })
cart: Cart cart: Rel<Cart>
@Property({ columnType: "text" }) @Property({ columnType: "text" })
title: string title: string
@@ -129,13 +130,13 @@ export default class LineItem {
variant_option_values: Record<string, unknown> | null = null variant_option_values: Record<string, unknown> | null = null
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
requires_shipping = true requires_shipping: boolean = true
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
is_discountable = true is_discountable: boolean = true
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
is_tax_inclusive = false is_tax_inclusive: boolean = false
@MikroOrmBigNumberProperty({ nullable: true }) @MikroOrmBigNumberProperty({ nullable: true })
compare_at_unit_price?: BigNumber | number | null = null compare_at_unit_price?: BigNumber | number | null = null
@@ -152,12 +153,12 @@ export default class LineItem {
@OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, { @OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
}) })
tax_lines = new Collection<LineItemTaxLine>(this) tax_lines = new Collection<Rel<LineItemTaxLine>>(this)
@OneToMany(() => LineItemAdjustment, (adjustment) => adjustment.item, { @OneToMany(() => LineItemAdjustment, (adjustment) => adjustment.item, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
}) })
adjustments = new Collection<LineItemAdjustment>(this) adjustments = new Collection<Rel<LineItemAdjustment>>(this)
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -10,6 +10,7 @@ import {
ManyToOne, ManyToOne,
OnInit, OnInit,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import AdjustmentLine from "./adjustment-line" import AdjustmentLine from "./adjustment-line"
import ShippingMethod from "./shipping-method" import ShippingMethod from "./shipping-method"
@@ -38,7 +39,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class ShippingMethodAdjustment extends AdjustmentLine { export default class ShippingMethodAdjustment extends AdjustmentLine {
@ManyToOne({ entity: () => ShippingMethod, persist: false }) @ManyToOne({ entity: () => ShippingMethod, persist: false })
shipping_method: ShippingMethod shipping_method: Rel<ShippingMethod>
@ShippingMethodIdIndex() @ShippingMethodIdIndex()
@ManyToOne({ @ManyToOne({
@@ -10,6 +10,7 @@ import {
ManyToOne, ManyToOne,
OnInit, OnInit,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ShippingMethod from "./shipping-method" import ShippingMethod from "./shipping-method"
import TaxLine from "./tax-line" import TaxLine from "./tax-line"
@@ -38,7 +39,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class ShippingMethodTaxLine extends TaxLine { export default class ShippingMethodTaxLine extends TaxLine {
@ManyToOne({ entity: () => ShippingMethod, persist: false }) @ManyToOne({ entity: () => ShippingMethod, persist: false })
shipping_method: ShippingMethod shipping_method: Rel<ShippingMethod>
@ShippingMethodIdIndex() @ShippingMethodIdIndex()
@ManyToOne({ @ManyToOne({
@@ -19,6 +19,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Cart from "./cart" import Cart from "./cart"
import ShippingMethodAdjustment from "./shipping-method-adjustment" import ShippingMethodAdjustment from "./shipping-method-adjustment"
@@ -68,7 +69,7 @@ export default class ShippingMethod {
cart_id: string cart_id: string
@ManyToOne({ entity: () => Cart, persist: false }) @ManyToOne({ entity: () => Cart, persist: false })
cart: Cart cart: Rel<Cart>
@Property({ columnType: "text" }) @Property({ columnType: "text" })
name: string name: string
@@ -83,7 +84,7 @@ export default class ShippingMethod {
raw_amount: BigNumberRawValue raw_amount: BigNumberRawValue
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
is_tax_inclusive = false is_tax_inclusive: boolean = false
@ShippingOptionIdIndex() @ShippingOptionIdIndex()
@Property({ columnType: "text", nullable: true }) @Property({ columnType: "text", nullable: true })
@@ -102,7 +103,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
} }
) )
tax_lines = new Collection<ShippingMethodTaxLine>(this) tax_lines = new Collection<Rel<ShippingMethodTaxLine>>(this)
@OneToMany( @OneToMany(
() => ShippingMethodAdjustment, () => ShippingMethodAdjustment,
@@ -111,7 +112,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
} }
) )
adjustments = new Collection<ShippingMethodAdjustment>(this) adjustments = new Collection<Rel<ShippingMethodAdjustment>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
+6 -4
View File
@@ -5,11 +5,13 @@ module.exports = {
"^@repositories": "<rootDir>/src/repositories", "^@repositories": "<rootDir>/src/repositories",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
-1
View File
@@ -40,7 +40,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"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-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
@@ -1,14 +1,15 @@
import { DAL } from "@medusajs/types" import { DAL } from "@medusajs/types"
import { generateEntityId } from "@medusajs/utils" import { generateEntityId } from "@medusajs/utils"
import { import {
Cascade,
BeforeCreate, BeforeCreate,
ManyToOne, Cascade,
Entity, Entity,
ManyToOne,
OnInit, OnInit,
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Customer from "./customer" import Customer from "./customer"
import CustomerGroup from "./customer-group" import CustomerGroup from "./customer-group"
@@ -34,7 +35,7 @@ export default class CustomerGroupCustomer {
index: "IDX_customer_group_customer_customer_id", index: "IDX_customer_group_customer_customer_id",
cascade: [Cascade.REMOVE], cascade: [Cascade.REMOVE],
}) })
customer: Customer customer: Rel<Customer>
@ManyToOne({ @ManyToOne({
entity: () => CustomerGroup, entity: () => CustomerGroup,
@@ -42,7 +43,7 @@ export default class CustomerGroupCustomer {
index: "IDX_customer_group_customer_group_id", index: "IDX_customer_group_customer_group_id",
cascade: [Cascade.REMOVE], cascade: [Cascade.REMOVE],
}) })
customer_group: CustomerGroup customer_group: Rel<CustomerGroup>
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -15,6 +15,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Customer from "./customer" import Customer from "./customer"
import CustomerGroupCustomer from "./customer-group-customer" import CustomerGroupCustomer from "./customer-group-customer"
@@ -45,7 +46,7 @@ export default class CustomerGroup {
entity: () => Customer, entity: () => Customer,
pivotEntity: () => CustomerGroupCustomer, pivotEntity: () => CustomerGroupCustomer,
}) })
customers = new Collection<Customer>(this) customers = new Collection<Rel<Customer>>(this)
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -17,6 +17,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Address from "./address" import Address from "./address"
import CustomerGroup from "./customer-group" import CustomerGroup from "./customer-group"
@@ -74,12 +75,12 @@ export default class Customer {
entity: () => CustomerGroup, entity: () => CustomerGroup,
pivotEntity: () => CustomerGroupCustomer, pivotEntity: () => CustomerGroupCustomer,
}) })
groups = new Collection<CustomerGroup>(this) groups = new Collection<Rel<CustomerGroup>>(this)
@OneToMany(() => Address, (address) => address.customer, { @OneToMany(() => Address, (address) => address.customer, {
cascade: [Cascade.REMOVE], cascade: [Cascade.REMOVE],
}) })
addresses = new Collection<Address>(this) addresses = new Collection<Rel<Address>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -1,12 +1,6 @@
module.exports = { module.exports = {
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": ["@swc/jest"],
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
}, },
testEnvironment: `node`, testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`], moduleFileExtensions: [`js`, `ts`],
@@ -24,7 +24,6 @@
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"jest": "^29.7.0", "jest": "^29.7.0",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"scripts": { "scripts": {
@@ -1,13 +1,5 @@
module.exports = { module.exports = {
transform: { transform: { "^.+\\.[jt]s$": ["@swc/jest"] },
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
testEnvironment: `node`, testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`], moduleFileExtensions: [`js`, `ts`],
} }
@@ -25,7 +25,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"medusa-test-utils": "^1.1.44", "medusa-test-utils": "^1.1.44",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"scripts": { "scripts": {
+6 -4
View File
@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types", "^@types": "<rootDir>/src/types",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
-1
View File
@@ -42,7 +42,6 @@
"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",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
+6 -4
View File
@@ -7,11 +7,13 @@ module.exports = {
"^@utils": "<rootDir>/src/utils", "^@utils": "<rootDir>/src/utils",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
@@ -40,7 +40,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"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-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
@@ -16,6 +16,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Fulfillment from "./fulfillment" import Fulfillment from "./fulfillment"
@@ -86,7 +87,7 @@ export default class FulfillmentItem {
fulfillment_id: string fulfillment_id: string
@ManyToOne(() => Fulfillment, { persist: false }) @ManyToOne(() => Fulfillment, { persist: false })
fulfillment: Fulfillment fulfillment: Rel<Fulfillment>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -14,6 +14,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Fulfillment from "./fulfillment" import Fulfillment from "./fulfillment"
@@ -58,7 +59,7 @@ export default class FulfillmentLabel {
fulfillment_id: string fulfillment_id: string
@ManyToOne(() => Fulfillment, { persist: false }) @ManyToOne(() => Fulfillment, { persist: false })
fulfillment: Fulfillment fulfillment: Rel<Fulfillment>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -16,6 +16,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ServiceZone from "./service-zone" import ServiceZone from "./service-zone"
@@ -56,7 +57,7 @@ export default class FulfillmentSet {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true, orphanRemoval: true,
}) })
service_zones = new Collection<ServiceZone>(this) service_zones = new Collection<Rel<ServiceZone>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -18,6 +18,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Address from "./address" import Address from "./address"
import FulfillmentItem from "./fulfillment-item" import FulfillmentItem from "./fulfillment-item"
@@ -117,7 +118,7 @@ export default class Fulfillment {
shipping_option: ShippingOption | null shipping_option: ShippingOption | null
@ManyToOne(() => FulfillmentProvider, { persist: false }) @ManyToOne(() => FulfillmentProvider, { persist: false })
provider: FulfillmentProvider provider: Rel<FulfillmentProvider>
@OneToOne({ @OneToOne({
entity: () => Address, entity: () => Address,
@@ -126,19 +127,19 @@ export default class Fulfillment {
nullable: true, nullable: true,
onDelete: "cascade", onDelete: "cascade",
}) })
delivery_address!: Address delivery_address!: Rel<Address>
@OneToMany(() => FulfillmentItem, (item) => item.fulfillment, { @OneToMany(() => FulfillmentItem, (item) => item.fulfillment, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true, orphanRemoval: true,
}) })
items = new Collection<FulfillmentItem>(this) items = new Collection<Rel<FulfillmentItem>>(this)
@OneToMany(() => FulfillmentLabel, (label) => label.fulfillment, { @OneToMany(() => FulfillmentLabel, (label) => label.fulfillment, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true, orphanRemoval: true,
}) })
labels = new Collection<FulfillmentLabel>(this) labels = new Collection<Rel<FulfillmentLabel>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -16,6 +16,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ServiceZone from "./service-zone" import ServiceZone from "./service-zone"
@@ -92,7 +93,7 @@ export default class GeoZone {
@ManyToOne(() => ServiceZone, { @ManyToOne(() => ServiceZone, {
persist: false, persist: false,
}) })
service_zone: ServiceZone service_zone: Rel<ServiceZone>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -18,6 +18,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import FulfillmentSet from "./fulfillment-set" import FulfillmentSet from "./fulfillment-set"
import GeoZone from "./geo-zone" import GeoZone from "./geo-zone"
@@ -71,13 +72,13 @@ export default class ServiceZone {
fulfillment_set_id: string fulfillment_set_id: string
@ManyToOne(() => FulfillmentSet, { persist: false }) @ManyToOne(() => FulfillmentSet, { persist: false })
fulfillment_set: FulfillmentSet fulfillment_set: Rel<FulfillmentSet>
@OneToMany(() => GeoZone, "service_zone", { @OneToMany(() => GeoZone, "service_zone", {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true, orphanRemoval: true,
}) })
geo_zones = new Collection<GeoZone>(this) geo_zones = new Collection<Rel<GeoZone>>(this)
@OneToMany( @OneToMany(
() => ShippingOption, () => ShippingOption,
@@ -87,7 +88,7 @@ export default class ServiceZone {
orphanRemoval: true, orphanRemoval: true,
} }
) )
shipping_options = new Collection<ShippingOption>(this) shipping_options = new Collection<Rel<ShippingOption>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -15,6 +15,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ShippingOption from "./shipping-option" import ShippingOption from "./shipping-option"
@@ -64,7 +65,7 @@ export default class ShippingOptionRule {
@ManyToOne(() => ShippingOption, { @ManyToOne(() => ShippingOption, {
persist: false, persist: false,
}) })
shipping_option: ShippingOption shipping_option: Rel<ShippingOption>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -14,6 +14,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ShippingOption from "./shipping-option" import ShippingOption from "./shipping-option"
@@ -52,7 +53,7 @@ export default class ShippingOptionType {
type: "text", type: "text",
onDelete: "cascade", onDelete: "cascade",
}) })
shipping_option: ShippingOption shipping_option: Rel<ShippingOption>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -21,6 +21,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Fulfillment from "./fulfillment" import Fulfillment from "./fulfillment"
import FulfillmentProvider from "./fulfillment-provider" import FulfillmentProvider from "./fulfillment-provider"
@@ -118,17 +119,17 @@ export default class ShippingOption {
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@ManyToOne(() => ServiceZone, { persist: false }) @ManyToOne(() => ServiceZone, { persist: false })
service_zone: ServiceZone service_zone: Rel<ServiceZone>
@ManyToOne(() => ShippingProfile, { @ManyToOne(() => ShippingProfile, {
persist: false, persist: false,
}) })
shipping_profile: ShippingProfile | null shipping_profile: Rel<ShippingProfile> | null
@ManyToOne(() => FulfillmentProvider, { @ManyToOne(() => FulfillmentProvider, {
persist: false, persist: false,
}) })
provider: FulfillmentProvider | null provider: Rel<FulfillmentProvider> | null
@OneToOne(() => ShippingOptionType, (so) => so.shipping_option, { @OneToOne(() => ShippingOptionType, (so) => so.shipping_option, {
owner: true, owner: true,
@@ -137,16 +138,16 @@ export default class ShippingOption {
fieldName: "shipping_option_type_id", fieldName: "shipping_option_type_id",
onDelete: "cascade", onDelete: "cascade",
}) })
type: ShippingOptionType type: Rel<ShippingOptionType>
@OneToMany(() => ShippingOptionRule, "shipping_option", { @OneToMany(() => ShippingOptionRule, "shipping_option", {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true, orphanRemoval: true,
}) })
rules = new Collection<ShippingOptionRule>(this) rules = new Collection<Rel<ShippingOptionRule>>(this)
@OneToMany(() => Fulfillment, (fulfillment) => fulfillment.shipping_option) @OneToMany(() => Fulfillment, (fulfillment) => fulfillment.shipping_option)
fulfillments = new Collection<Fulfillment>(this) fulfillments = new Collection<Rel<Fulfillment>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -16,6 +16,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ShippingOption from "./shipping-option" import ShippingOption from "./shipping-option"
@@ -55,7 +56,7 @@ export default class ShippingProfile {
() => ShippingOption, () => ShippingOption,
(shippingOption) => shippingOption.shipping_profile (shippingOption) => shippingOption.shipping_profile
) )
shipping_options = new Collection<ShippingOption>(this) shipping_options = new Collection<Rel<ShippingOption>>(this)
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -1,10 +1,12 @@
module.exports = { module.exports = {
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
@@ -26,7 +26,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"medusa-test-utils": "^1.1.43", "medusa-test-utils": "^1.1.43",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
@@ -1,3 +1,9 @@
import {
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
Searchable,
} from "@medusajs/utils"
import { import {
BeforeCreate, BeforeCreate,
Collection, Collection,
@@ -9,13 +15,8 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import {
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
Searchable,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types" import { DAL } from "@medusajs/types"
import { InventoryLevel } from "./inventory-level" import { InventoryLevel } from "./inventory-level"
@@ -117,7 +118,7 @@ export class InventoryItem {
cascade: ["soft-remove" as any], cascade: ["soft-remove" as any],
} }
) )
location_levels = new Collection<InventoryLevel>(this) location_levels = new Collection<Rel<InventoryLevel>>(this)
@OneToMany( @OneToMany(
() => ReservationItem, () => ReservationItem,
@@ -126,7 +127,7 @@ export class InventoryItem {
cascade: ["soft-remove" as any], cascade: ["soft-remove" as any],
} }
) )
reservation_items = new Collection<ReservationItem>(this) reservation_items = new Collection<Rel<ReservationItem>>(this)
@Formula( @Formula(
(item) => (item) =>
@@ -1,3 +1,4 @@
import { DALUtils, isDefined } from "@medusajs/utils"
import { import {
BeforeCreate, BeforeCreate,
Entity, Entity,
@@ -7,12 +8,14 @@ import {
OnLoad, OnLoad,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import { DALUtils, isDefined } from "@medusajs/utils"
import {
createPsqlIndexStatementHelper,
generateEntityId,
} from "@medusajs/utils"
import { InventoryItem } from "./inventory-item" import { InventoryItem } from "./inventory-item"
import { createPsqlIndexStatementHelper } from "@medusajs/utils"
import { generateEntityId } from "@medusajs/utils"
const InventoryLevelDeletedAtIndex = createPsqlIndexStatementHelper({ const InventoryLevelDeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "inventory_level", tableName: "inventory_level",
@@ -90,7 +93,7 @@ export class InventoryLevel {
@ManyToOne(() => InventoryItem, { @ManyToOne(() => InventoryItem, {
persist: false, persist: false,
}) })
inventory_item: InventoryItem inventory_item: Rel<InventoryItem>
available_quantity: number | null = null available_quantity: number | null = null
@@ -6,6 +6,7 @@ import {
OnInit, OnInit,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import { import {
@@ -98,7 +99,7 @@ export class ReservationItem {
@ManyToOne(() => InventoryItem, { @ManyToOne(() => InventoryItem, {
persist: false, persist: false,
}) })
inventory_item: InventoryItem inventory_item: Rel<InventoryItem>
@BeforeCreate() @BeforeCreate()
private beforeCreate(): void { private beforeCreate(): void {
+6 -4
View File
@@ -1,10 +1,12 @@
module.exports = { module.exports = {
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
@@ -34,7 +34,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"pg-god": "^1.0.12", "pg-god": "^1.0.12",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
+6 -4
View File
@@ -7,11 +7,13 @@ module.exports = {
"^@utils": "<rootDir>/src/utils", "^@utils": "<rootDir>/src/utils",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
@@ -39,7 +39,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"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-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
+6 -4
View File
@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types", "^@types": "<rootDir>/src/types",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
-1
View File
@@ -40,7 +40,6 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"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-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
@@ -11,6 +11,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ClaimItem from "./claim-item" import ClaimItem from "./claim-item"
@@ -47,7 +48,7 @@ export default class ClaimItemImage {
@ManyToOne(() => ClaimItem, { @ManyToOne(() => ClaimItem, {
persist: false, persist: false,
}) })
item: ClaimItem item: Rel<ClaimItem>
@Property({ columnType: "text" }) @Property({ columnType: "text" })
url: string url: string
@@ -17,6 +17,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Claim from "./claim" import Claim from "./claim"
import ClaimItemImage from "./claim-item-image" import ClaimItemImage from "./claim-item-image"
@@ -52,10 +53,10 @@ export default class OrderClaimItem {
@OneToMany(() => ClaimItemImage, (ci) => ci.item, { @OneToMany(() => ClaimItemImage, (ci) => ci.item, {
cascade: [Cascade.PERSIST, Cascade.REMOVE], cascade: [Cascade.PERSIST, Cascade.REMOVE],
}) })
images = new Collection<ClaimItemImage>(this) images = new Collection<Rel<ClaimItemImage>>(this)
@Enum({ items: () => ClaimReason, nullable: true }) @Enum({ items: () => ClaimReason, nullable: true })
reason: ClaimReason | null = null reason: Rel<ClaimReason> | null = null
@MikroOrmBigNumberProperty() @MikroOrmBigNumberProperty()
quantity: Number | number quantity: Number | number
@@ -75,7 +76,7 @@ export default class OrderClaimItem {
@ManyToOne(() => Claim, { @ManyToOne(() => Claim, {
persist: false, persist: false,
}) })
claim: Claim claim: Rel<Claim>
@ManyToOne({ @ManyToOne({
entity: () => LineItem, entity: () => LineItem,
@@ -89,7 +90,7 @@ export default class OrderClaimItem {
@ManyToOne(() => LineItem, { @ManyToOne(() => LineItem, {
persist: false, persist: false,
}) })
item: LineItem item: Rel<LineItem>
@Property({ columnType: "boolean", default: false }) @Property({ columnType: "boolean", default: false })
is_additional_item: boolean = false is_additional_item: boolean = false
+7 -6
View File
@@ -19,6 +19,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ClaimItem from "./claim-item" import ClaimItem from "./claim-item"
import Order from "./order" import Order from "./order"
@@ -71,7 +72,7 @@ export default class OrderClaim {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@OneToOne({ @OneToOne({
entity: () => Return, entity: () => Return,
@@ -81,7 +82,7 @@ export default class OrderClaim {
nullable: true, nullable: true,
owner: true, owner: true,
}) })
return: Return return: Rel<Return>
@Property({ columnType: "text", nullable: true }) @Property({ columnType: "text", nullable: true })
@ReturnIdIndex.MikroORMIndex() @ReturnIdIndex.MikroORMIndex()
@@ -97,7 +98,7 @@ export default class OrderClaim {
display_id: number display_id: number
@Enum({ items: () => ClaimType }) @Enum({ items: () => ClaimType })
type: ClaimType type: Rel<ClaimType>
@Property({ columnType: "boolean", nullable: true }) @Property({ columnType: "boolean", nullable: true })
no_notification: boolean | null = null no_notification: boolean | null = null
@@ -113,12 +114,12 @@ export default class OrderClaim {
@OneToMany(() => ClaimItem, (item) => item.claim, { @OneToMany(() => ClaimItem, (item) => item.claim, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
additional_items = new Collection<ClaimItem>(this) additional_items = new Collection<Rel<ClaimItem>>(this)
@OneToMany(() => ClaimItem, (item) => item.claim, { @OneToMany(() => ClaimItem, (item) => item.claim, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
claim_items = new Collection<ClaimItem>(this) claim_items = new Collection<Rel<ClaimItem>>(this)
@OneToMany( @OneToMany(
() => OrderShippingMethod, () => OrderShippingMethod,
@@ -127,7 +128,7 @@ export default class OrderClaim {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
} }
) )
shipping_methods = new Collection<OrderShippingMethod>(this) shipping_methods = new Collection<Rel<OrderShippingMethod>>(this)
@OneToMany(() => Transaction, (transaction) => transaction.claim, { @OneToMany(() => Transaction, (transaction) => transaction.claim, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
@@ -17,6 +17,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import { ExchangeItem, Transaction } from "@models" import { ExchangeItem, Transaction } from "@models"
import Order from "./order" import Order from "./order"
@@ -68,7 +69,7 @@ export default class OrderExchange {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@OneToOne({ @OneToOne({
entity: () => Return, entity: () => Return,
@@ -78,7 +79,7 @@ export default class OrderExchange {
nullable: true, nullable: true,
owner: true, owner: true,
}) })
return: Return return: Rel<Return>
@Property({ columnType: "text", nullable: true }) @Property({ columnType: "text", nullable: true })
@ReturnIdIndex.MikroORMIndex() @ReturnIdIndex.MikroORMIndex()
@@ -110,7 +111,7 @@ export default class OrderExchange {
@OneToMany(() => ExchangeItem, (item) => item.exchange, { @OneToMany(() => ExchangeItem, (item) => item.exchange, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
additional_items = new Collection<ExchangeItem>(this) additional_items = new Collection<Rel<ExchangeItem>>(this)
@OneToMany( @OneToMany(
() => OrderShippingMethod, () => OrderShippingMethod,
@@ -119,7 +120,7 @@ export default class OrderExchange {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
} }
) )
shipping_methods = new Collection<OrderShippingMethod>(this) shipping_methods = new Collection<Rel<OrderShippingMethod>>(this)
@OneToMany(() => Transaction, (transaction) => transaction.exchange, { @OneToMany(() => Transaction, (transaction) => transaction.exchange, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
@@ -2,7 +2,7 @@ import {
createPsqlIndexStatementHelper, createPsqlIndexStatementHelper,
generateEntityId, generateEntityId,
} from "@medusajs/utils" } from "@medusajs/utils"
import { BeforeCreate, Entity, ManyToOne, OnInit } from "@mikro-orm/core" import { BeforeCreate, Entity, ManyToOne, OnInit, Rel } from "@mikro-orm/core"
import AdjustmentLine from "./adjustment-line" import AdjustmentLine from "./adjustment-line"
import LineItem from "./line-item" import LineItem from "./line-item"
@@ -16,7 +16,7 @@ export default class LineItemAdjustment extends AdjustmentLine {
@ManyToOne(() => LineItem, { @ManyToOne(() => LineItem, {
persist: false, persist: false,
}) })
item: LineItem item: Rel<LineItem>
@ManyToOne({ @ManyToOne({
entity: () => LineItem, entity: () => LineItem,
@@ -8,6 +8,7 @@ import {
Entity, Entity,
ManyToOne, ManyToOne,
OnInit, OnInit,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import LineItem from "./line-item" import LineItem from "./line-item"
import TaxLine from "./tax-line" import TaxLine from "./tax-line"
@@ -23,7 +24,7 @@ export default class LineItemTaxLine extends TaxLine {
fieldName: "item_id", fieldName: "item_id",
persist: false, persist: false,
}) })
item: LineItem item: Rel<LineItem>
@ManyToOne({ @ManyToOne({
entity: () => LineItem, entity: () => LineItem,
@@ -15,6 +15,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import LineItemAdjustment from "./line-item-adjustment" import LineItemAdjustment from "./line-item-adjustment"
import LineItemTaxLine from "./line-item-tax-line" import LineItemTaxLine from "./line-item-tax-line"
@@ -92,13 +93,13 @@ export default class LineItem {
variant_option_values: Record<string, unknown> | null = null variant_option_values: Record<string, unknown> | null = null
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
requires_shipping = true requires_shipping: boolean = true
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
is_discountable = true is_discountable: boolean = true
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
is_tax_inclusive = false is_tax_inclusive: boolean = false
@MikroOrmBigNumberProperty({ @MikroOrmBigNumberProperty({
nullable: true, nullable: true,
@@ -119,12 +120,12 @@ export default class LineItem {
@OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, { @OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
tax_lines = new Collection<LineItemTaxLine>(this) tax_lines = new Collection<Rel<LineItemTaxLine>>(this)
@OneToMany(() => LineItemAdjustment, (adjustment) => adjustment.item, { @OneToMany(() => LineItemAdjustment, (adjustment) => adjustment.item, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
adjustments = new Collection<LineItemAdjustment>(this) adjustments = new Collection<Rel<LineItemAdjustment>>(this)
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -13,6 +13,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import OrderClaim from "./claim" import OrderClaim from "./claim"
import OrderExchange from "./exchange" import OrderExchange from "./exchange"
@@ -90,7 +91,7 @@ export default class OrderChangeAction {
persist: false, persist: false,
nullable: true, nullable: true,
}) })
order: Order | null = null order: Rel<Order> | null = null
@ManyToOne({ @ManyToOne({
entity: () => Return, entity: () => Return,
@@ -155,7 +156,7 @@ export default class OrderChangeAction {
persist: false, persist: false,
nullable: true, nullable: true,
}) })
order_change: OrderChange | null = null order_change: Rel<OrderChange> | null = null
@Property({ @Property({
columnType: "text", columnType: "text",
@@ -15,6 +15,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import { OrderChangeStatus, OrderChangeType } from "@types" import { OrderChangeStatus, OrderChangeType } from "@types"
import OrderClaim from "./claim" import OrderClaim from "./claim"
@@ -94,7 +95,7 @@ export default class OrderChange {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@ManyToOne({ @ManyToOne({
entity: () => Return, entity: () => Return,
@@ -109,7 +110,7 @@ export default class OrderChange {
@ManyToOne(() => Return, { @ManyToOne(() => Return, {
persist: false, persist: false,
}) })
return: Return return: Rel<Return>
@ManyToOne({ @ManyToOne({
entity: () => OrderClaim, entity: () => OrderClaim,
@@ -152,7 +153,7 @@ export default class OrderChange {
@OneToMany(() => OrderChangeAction, (action) => action.order_change, { @OneToMany(() => OrderChangeAction, (action) => action.order_change, {
cascade: [Cascade.PERSIST, "sotf-remove" as Cascade], cascade: [Cascade.PERSIST, "sotf-remove" as Cascade],
}) })
actions = new Collection<OrderChangeAction>(this) actions = new Collection<Rel<OrderChangeAction>>(this)
@Property({ @Property({
columnType: "text", columnType: "text",
@@ -13,6 +13,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import LineItem from "./line-item" import LineItem from "./line-item"
import Order from "./order" import Order from "./order"
@@ -62,7 +63,7 @@ export default class OrderItem {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@Property({ columnType: "integer" }) @Property({ columnType: "integer" })
@OrderVersionIndex.MikroORMIndex() @OrderVersionIndex.MikroORMIndex()
@@ -80,7 +81,7 @@ export default class OrderItem {
@ManyToOne(() => LineItem, { @ManyToOne(() => LineItem, {
persist: false, persist: false,
}) })
item: LineItem item: Rel<LineItem>
@MikroOrmBigNumberProperty() @MikroOrmBigNumberProperty()
quantity: BigNumber | number quantity: BigNumber | number
@@ -11,6 +11,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Claim from "./claim" import Claim from "./claim"
import Exchange from "./exchange" import Exchange from "./exchange"
@@ -81,7 +82,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@ManyToOne({ @ManyToOne({
entity: () => Return, entity: () => Return,
@@ -96,7 +97,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Return, { @ManyToOne(() => Return, {
persist: false, persist: false,
}) })
return: Return return: Rel<Return>
@ManyToOne({ @ManyToOne({
entity: () => Exchange, entity: () => Exchange,
@@ -111,7 +112,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Exchange, { @ManyToOne(() => Exchange, {
persist: false, persist: false,
}) })
exchange: Exchange exchange: Rel<Exchange>
@ManyToOne({ @ManyToOne({
entity: () => Claim, entity: () => Claim,
@@ -126,7 +127,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Claim, { @ManyToOne(() => Claim, {
persist: false, persist: false,
}) })
claim: Claim claim: Rel<Claim>
@Property({ columnType: "integer" }) @Property({ columnType: "integer" })
@OrderVersionIndex.MikroORMIndex() @OrderVersionIndex.MikroORMIndex()
@@ -144,7 +145,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => ShippingMethod, { @ManyToOne(() => ShippingMethod, {
persist: false, persist: false,
}) })
shipping_method: ShippingMethod shipping_method: Rel<ShippingMethod>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -10,6 +10,7 @@ import {
OnInit, OnInit,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Order from "./order" import Order from "./order"
@@ -71,7 +72,7 @@ export default class OrderSummary {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@Property({ @Property({
columnType: "integer", columnType: "integer",
+8 -7
View File
@@ -16,6 +16,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Address from "./address" import Address from "./address"
import OrderItem from "./order-item" import OrderItem from "./order-item"
@@ -127,7 +128,7 @@ export default class Order {
columnType: "boolean", columnType: "boolean",
}) })
@IsDraftOrderIndex.MikroORMIndex() @IsDraftOrderIndex.MikroORMIndex()
is_draft_order = false is_draft_order: boolean = false
@Property({ columnType: "text", nullable: true }) @Property({ columnType: "text", nullable: true })
email: string | null = null email: string | null = null
@@ -146,7 +147,7 @@ export default class Order {
nullable: true, nullable: true,
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
shipping_address?: Address | null shipping_address?: Rel<Address> | null
@Property({ columnType: "text", nullable: true }) @Property({ columnType: "text", nullable: true })
@BillingAddressIdIndex.MikroORMIndex() @BillingAddressIdIndex.MikroORMIndex()
@@ -158,7 +159,7 @@ export default class Order {
nullable: true, nullable: true,
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
billing_address?: Address | null billing_address?: Rel<Address> | null
@Property({ columnType: "boolean", nullable: true }) @Property({ columnType: "boolean", nullable: true })
no_notification: boolean | null = null no_notification: boolean | null = null
@@ -166,7 +167,7 @@ export default class Order {
@OneToMany(() => OrderSummary, (summary) => summary.order, { @OneToMany(() => OrderSummary, (summary) => summary.order, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
summary = new Collection<OrderSummary>(this) summary = new Collection<Rel<OrderSummary>>(this)
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -174,7 +175,7 @@ export default class Order {
@OneToMany(() => OrderItem, (itemDetail) => itemDetail.order, { @OneToMany(() => OrderItem, (itemDetail) => itemDetail.order, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
items = new Collection<OrderItem>(this) items = new Collection<Rel<OrderItem>>(this)
@OneToMany( @OneToMany(
() => OrderShippingMethod, () => OrderShippingMethod,
@@ -183,12 +184,12 @@ export default class Order {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
} }
) )
shipping_methods = new Collection<OrderShippingMethod>(this) shipping_methods = new Collection<Rel<OrderShippingMethod>>(this)
@OneToMany(() => Transaction, (transaction) => transaction.order, { @OneToMany(() => Transaction, (transaction) => transaction.order, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
transactions = new Collection<Transaction>(this) transactions = new Collection<Rel<Transaction>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -13,6 +13,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
const DeletedAtIndex = createPsqlIndexStatementHelper({ const DeletedAtIndex = createPsqlIndexStatementHelper({
@@ -62,14 +63,14 @@ export default class ReturnReason {
nullable: true, nullable: true,
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
parent_return_reason?: ReturnReason | null parent_return_reason?: Rel<ReturnReason> | null
@OneToMany( @OneToMany(
() => ReturnReason, () => ReturnReason,
(return_reason) => return_reason.parent_return_reason, (return_reason) => return_reason.parent_return_reason,
{ cascade: [Cascade.PERSIST] } { cascade: [Cascade.PERSIST] }
) )
return_reason_children: ReturnReason[] return_reason_children: Rel<ReturnReason>[]
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
+5 -4
View File
@@ -19,6 +19,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import { ReturnItem, Transaction } from "@models" import { ReturnItem, Transaction } from "@models"
import Claim from "./claim" import Claim from "./claim"
@@ -78,7 +79,7 @@ export default class Return {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@OneToOne({ @OneToOne({
entity: () => Exchange, entity: () => Exchange,
@@ -86,7 +87,7 @@ export default class Return {
fieldName: "exchange_id", fieldName: "exchange_id",
nullable: true, nullable: true,
}) })
exchange: Exchange exchange: Rel<Exchange>
@Property({ columnType: "text", nullable: true }) @Property({ columnType: "text", nullable: true })
@ExchangeIdIndex.MikroORMIndex() @ExchangeIdIndex.MikroORMIndex()
@@ -98,7 +99,7 @@ export default class Return {
fieldName: "claim_id", fieldName: "claim_id",
nullable: true, nullable: true,
}) })
claim: Claim claim: Rel<Claim>
@Property({ columnType: "text", nullable: true }) @Property({ columnType: "text", nullable: true })
@ClaimIdIndex.MikroORMIndex() @ClaimIdIndex.MikroORMIndex()
@@ -130,7 +131,7 @@ export default class Return {
@OneToMany(() => ReturnItem, (itemDetail) => itemDetail.return, { @OneToMany(() => ReturnItem, (itemDetail) => itemDetail.return, {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
}) })
items = new Collection<OrderItem>(this) items = new Collection<Rel<OrderItem>>(this)
@OneToMany( @OneToMany(
() => OrderShippingMethod, () => OrderShippingMethod,
@@ -2,7 +2,7 @@ import {
createPsqlIndexStatementHelper, createPsqlIndexStatementHelper,
generateEntityId, generateEntityId,
} from "@medusajs/utils" } from "@medusajs/utils"
import { BeforeCreate, Entity, ManyToOne, OnInit } from "@mikro-orm/core" import { BeforeCreate, Entity, ManyToOne, OnInit, Rel } from "@mikro-orm/core"
import AdjustmentLine from "./adjustment-line" import AdjustmentLine from "./adjustment-line"
import ShippingMethod from "./shipping-method" import ShippingMethod from "./shipping-method"
@@ -16,7 +16,7 @@ export default class ShippingMethodAdjustment extends AdjustmentLine {
@ManyToOne(() => ShippingMethod, { @ManyToOne(() => ShippingMethod, {
persist: false, persist: false,
}) })
shipping_method: ShippingMethod shipping_method: Rel<ShippingMethod>
@ManyToOne({ @ManyToOne({
entity: () => ShippingMethod, entity: () => ShippingMethod,
@@ -2,7 +2,7 @@ import {
createPsqlIndexStatementHelper, createPsqlIndexStatementHelper,
generateEntityId, generateEntityId,
} from "@medusajs/utils" } from "@medusajs/utils"
import { BeforeCreate, Entity, ManyToOne, OnInit } from "@mikro-orm/core" import { BeforeCreate, Entity, ManyToOne, OnInit, Rel } from "@mikro-orm/core"
import ShippingMethod from "./shipping-method" import ShippingMethod from "./shipping-method"
import TaxLine from "./tax-line" import TaxLine from "./tax-line"
@@ -16,7 +16,7 @@ export default class ShippingMethodTaxLine extends TaxLine {
@ManyToOne(() => ShippingMethod, { @ManyToOne(() => ShippingMethod, {
persist: false, persist: false,
}) })
shipping_method: ShippingMethod shipping_method: Rel<ShippingMethod>
@ManyToOne({ @ManyToOne({
entity: () => ShippingMethod, entity: () => ShippingMethod,
@@ -14,6 +14,7 @@ import {
OnInit, OnInit,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import ShippingMethodAdjustment from "./shipping-method-adjustment" import ShippingMethodAdjustment from "./shipping-method-adjustment"
import ShippingMethodTaxLine from "./shipping-method-tax-line" import ShippingMethodTaxLine from "./shipping-method-tax-line"
@@ -41,7 +42,7 @@ export default class ShippingMethod {
raw_amount: BigNumberRawValue raw_amount: BigNumberRawValue
@Property({ columnType: "boolean" }) @Property({ columnType: "boolean" })
is_tax_inclusive = false is_tax_inclusive: boolean = false
@Property({ @Property({
columnType: "text", columnType: "text",
@@ -63,7 +64,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
} }
) )
tax_lines = new Collection<ShippingMethodTaxLine>(this) tax_lines = new Collection<Rel<ShippingMethodTaxLine>>(this)
@OneToMany( @OneToMany(
() => ShippingMethodAdjustment, () => ShippingMethodAdjustment,
@@ -72,7 +73,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST], cascade: [Cascade.PERSIST],
} }
) )
adjustments = new Collection<ShippingMethodAdjustment>(this) adjustments = new Collection<Rel<ShippingMethodAdjustment>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -13,6 +13,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Claim from "./claim" import Claim from "./claim"
import Exchange from "./exchange" import Exchange from "./exchange"
@@ -90,7 +91,7 @@ export default class Transaction {
@ManyToOne(() => Order, { @ManyToOne(() => Order, {
persist: false, persist: false,
}) })
order: Order order: Rel<Order>
@ManyToOne({ @ManyToOne({
entity: () => Return, entity: () => Return,
@@ -105,7 +106,7 @@ export default class Transaction {
@ManyToOne(() => Return, { @ManyToOne(() => Return, {
persist: false, persist: false,
}) })
return: Return return: Rel<Return>
@ManyToOne({ @ManyToOne({
entity: () => Exchange, entity: () => Exchange,
@@ -120,7 +121,7 @@ export default class Transaction {
@ManyToOne(() => Exchange, { @ManyToOne(() => Exchange, {
persist: false, persist: false,
}) })
exchange: Exchange exchange: Rel<Exchange>
@ManyToOne({ @ManyToOne({
entity: () => Claim, entity: () => Claim,
@@ -135,7 +136,7 @@ export default class Transaction {
@ManyToOne(() => Claim, { @ManyToOne(() => Claim, {
persist: false, persist: false,
}) })
claim: Claim claim: Rel<Claim>
@Property({ @Property({
columnType: "integer", columnType: "integer",
@@ -174,7 +174,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
expect(collection.length).toEqual(1) expect(collection.length).toEqual(1)
await service.deletePaymentCollections(["pay-col-id-1"]) await service.deletePaymentCollections("pay-col-id-1")
collection = await service.listPaymentCollections({ collection = await service.listPaymentCollections({
id: ["pay-col-id-1"], id: ["pay-col-id-1"],
@@ -19,6 +19,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Payment from "./payment" import Payment from "./payment"
import PaymentProvider from "./payment-provider" import PaymentProvider from "./payment-provider"
@@ -99,17 +100,17 @@ export default class PaymentCollection {
status: PaymentCollectionStatus = PaymentCollectionStatus.NOT_PAID status: PaymentCollectionStatus = PaymentCollectionStatus.NOT_PAID
@ManyToMany(() => PaymentProvider) @ManyToMany(() => PaymentProvider)
payment_providers = new Collection<PaymentProvider>(this) payment_providers = new Collection<Rel<PaymentProvider>>(this)
@OneToMany(() => PaymentSession, (ps) => ps.payment_collection, { @OneToMany(() => PaymentSession, (ps) => ps.payment_collection, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
}) })
payment_sessions = new Collection<PaymentSession>(this) payment_sessions = new Collection<Rel<PaymentSession>>(this)
@OneToMany(() => Payment, (payment) => payment.payment_collection, { @OneToMany(() => Payment, (payment) => payment.payment_collection, {
cascade: [Cascade.PERSIST, "soft-remove"] as any, cascade: [Cascade.PERSIST, "soft-remove"] as any,
}) })
payments = new Collection<Payment>(this) payments = new Collection<Rel<Payment>>(this)
@Property({ columnType: "jsonb", nullable: true }) @Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null metadata: Record<string, unknown> | null = null
@@ -15,6 +15,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Payment from "./payment" import Payment from "./payment"
import PaymentCollection from "./payment-collection" import PaymentCollection from "./payment-collection"
@@ -60,7 +61,7 @@ export default class PaymentSession {
@ManyToOne(() => PaymentCollection, { @ManyToOne(() => PaymentCollection, {
persist: false, persist: false,
}) })
payment_collection: PaymentCollection payment_collection: Rel<PaymentCollection>
@ManyToOne({ @ManyToOne({
entity: () => PaymentCollection, entity: () => PaymentCollection,
@@ -76,7 +77,7 @@ export default class PaymentSession {
nullable: true, nullable: true,
mappedBy: "payment_session", mappedBy: "payment_session",
}) })
payment?: Payment | null payment?: Rel<Payment> | null
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -19,6 +19,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Capture from "./capture" import Capture from "./capture"
import PaymentCollection from "./payment-collection" import PaymentCollection from "./payment-collection"
@@ -102,18 +103,18 @@ export default class Payment {
@OneToMany(() => Refund, (refund) => refund.payment, { @OneToMany(() => Refund, (refund) => refund.payment, {
cascade: [Cascade.REMOVE], cascade: [Cascade.REMOVE],
}) })
refunds = new Collection<Refund>(this) refunds = new Collection<Rel<Refund>>(this)
@OneToMany(() => Capture, (capture) => capture.payment, { @OneToMany(() => Capture, (capture) => capture.payment, {
cascade: [Cascade.REMOVE], cascade: [Cascade.REMOVE],
}) })
captures = new Collection<Capture>(this) captures = new Collection<Rel<Capture>>(this)
@ManyToOne({ @ManyToOne({
entity: () => PaymentCollection, entity: () => PaymentCollection,
persist: false, persist: false,
}) })
payment_collection: PaymentCollection payment_collection: Rel<PaymentCollection>
@ManyToOne({ @ManyToOne({
entity: () => PaymentCollection, entity: () => PaymentCollection,
@@ -125,11 +126,12 @@ export default class Payment {
payment_collection_id: string payment_collection_id: string
@OneToOne({ @OneToOne({
entity: () => PaymentSession,
owner: true, owner: true,
fieldName: "payment_session_id", fieldName: "payment_session_id",
index: "IDX_payment_payment_session_id", index: "IDX_payment_payment_session_id",
}) })
payment_session: PaymentSession payment_session: Rel<PaymentSession>
@BeforeCreate() @BeforeCreate()
onCreate() { onCreate() {
@@ -11,6 +11,7 @@ import {
OnInit, OnInit,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Payment from "./payment" import Payment from "./payment"
@@ -30,7 +31,7 @@ export default class Refund {
index: "IDX_refund_payment_id", index: "IDX_refund_payment_id",
fieldName: "payment_id", fieldName: "payment_id",
}) })
payment!: Payment payment!: Rel<Payment>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -13,6 +13,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import PriceListRule from "./price-list-rule" import PriceListRule from "./price-list-rule"
@@ -49,7 +50,7 @@ export default class PriceListRuleValue {
price_list_rule_id: string price_list_rule_id: string
@ManyToOne(() => PriceListRule, { persist: false }) @ManyToOne(() => PriceListRule, { persist: false })
price_list_rule: PriceListRule price_list_rule: Rel<PriceListRule>
@Property({ columnType: "text" }) @Property({ columnType: "text" })
value: string value: string
@@ -16,6 +16,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import PriceList from "./price-list" import PriceList from "./price-list"
import PriceListRuleValue from "./price-list-rule-value" import PriceListRuleValue from "./price-list-rule-value"
@@ -60,12 +61,12 @@ export default class PriceListRule {
rule_type_id: string rule_type_id: string
@ManyToOne(() => RuleType, { persist: false }) @ManyToOne(() => RuleType, { persist: false })
rule_type: RuleType rule_type: Rel<RuleType>
@OneToMany(() => PriceListRuleValue, (plrv) => plrv.price_list_rule, { @OneToMany(() => PriceListRuleValue, (plrv) => plrv.price_list_rule, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
price_list_rule_values = new Collection<PriceListRuleValue>(this) price_list_rule_values = new Collection<Rel<PriceListRuleValue>>(this)
@PriceListRulePriceListIdIndex.MikroORMIndex() @PriceListRulePriceListIdIndex.MikroORMIndex()
@ManyToOne(() => PriceList, { @ManyToOne(() => PriceList, {
@@ -77,7 +78,7 @@ export default class PriceListRule {
price_list_id: string price_list_id: string
@ManyToOne(() => PriceList, { persist: false }) @ManyToOne(() => PriceList, { persist: false })
price_list: PriceList price_list: Rel<PriceList>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -20,6 +20,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Price from "./price" import Price from "./price"
import PriceListRule from "./price-list-rule" import PriceListRule from "./price-list-rule"
@@ -76,18 +77,18 @@ export default class PriceList {
@OneToMany(() => Price, (price) => price.price_list, { @OneToMany(() => Price, (price) => price.price_list, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
prices = new Collection<Price>(this) prices = new Collection<Rel<Price>>(this)
@OneToMany(() => PriceListRule, (pr) => pr.price_list, { @OneToMany(() => PriceListRule, (pr) => pr.price_list, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
price_list_rules = new Collection<PriceListRule>(this) price_list_rules = new Collection<Rel<PriceListRule>>(this)
@ManyToMany({ @ManyToMany({
entity: () => RuleType, entity: () => RuleType,
pivotEntity: () => PriceListRule, pivotEntity: () => PriceListRule,
}) })
rule_types = new Collection<RuleType>(this) rule_types = new Collection<Rel<RuleType>>(this)
@Property({ columnType: "integer", default: 0 }) @Property({ columnType: "integer", default: 0 })
rules_count: number = 0 rules_count: number = 0
@@ -13,6 +13,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Price from "./price" import Price from "./price"
import PriceSet from "./price-set" import PriceSet from "./price-set"
@@ -64,7 +65,7 @@ export default class PriceRule {
price_set_id: string price_set_id: string
@ManyToOne(() => PriceSet, { persist: false }) @ManyToOne(() => PriceSet, { persist: false })
price_set: PriceSet price_set: Rel<PriceSet>
@PriceRuleRuleTypeIdIndex.MikroORMIndex() @PriceRuleRuleTypeIdIndex.MikroORMIndex()
@ManyToOne(() => RuleType, { @ManyToOne(() => RuleType, {
@@ -75,7 +76,7 @@ export default class PriceRule {
rule_type_id: string rule_type_id: string
@ManyToOne(() => RuleType, { persist: false }) @ManyToOne(() => RuleType, { persist: false })
rule_type: RuleType rule_type: Rel<RuleType>
@Property({ columnType: "text" }) @Property({ columnType: "text" })
value: string value: string
@@ -93,7 +94,7 @@ export default class PriceRule {
price_id: string price_id: string
@ManyToOne(() => Price, { persist: false }) @ManyToOne(() => Price, { persist: false })
price: Price price: Rel<Price>
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -14,6 +14,7 @@ import {
OnInit, OnInit,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import Price from "./price" import Price from "./price"
import PriceRule from "./price-rule" import PriceRule from "./price-rule"
@@ -38,19 +39,19 @@ export default class PriceSet {
@OneToMany(() => Price, (price) => price.price_set, { @OneToMany(() => Price, (price) => price.price_set, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
prices = new Collection<Price>(this) prices = new Collection<Rel<Price>>(this)
@OneToMany(() => PriceRule, (pr) => pr.price_set, { @OneToMany(() => PriceRule, (pr) => pr.price_set, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
price_rules = new Collection<PriceRule>(this) price_rules = new Collection<Rel<PriceRule>>(this)
@ManyToMany({ @ManyToMany({
entity: () => RuleType, entity: () => RuleType,
pivotEntity: () => PriceSetRuleType, pivotEntity: () => PriceSetRuleType,
cascade: ["soft-remove" as Cascade], cascade: ["soft-remove" as Cascade],
}) })
rule_types = new Collection<RuleType>(this) rule_types = new Collection<Rel<RuleType>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
+4 -3
View File
@@ -18,6 +18,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import PriceList from "./price-list" import PriceList from "./price-list"
import PriceRule from "./price-rule" import PriceRule from "./price-rule"
@@ -87,7 +88,7 @@ export default class Price {
price_set_id: string price_set_id: string
@ManyToOne(() => PriceSet, { persist: false }) @ManyToOne(() => PriceSet, { persist: false })
price_set?: PriceSet price_set?: Rel<PriceSet>
@Property({ columnType: "integer", default: 0 }) @Property({ columnType: "integer", default: 0 })
rules_count: number = 0 rules_count: number = 0
@@ -97,7 +98,7 @@ export default class Price {
mappedBy: (pr) => pr.price, mappedBy: (pr) => pr.price,
cascade: [Cascade.PERSIST, "soft-remove" as Cascade], cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
}) })
price_rules = new Collection<PriceRule>(this) price_rules = new Collection<Rel<PriceRule>>(this)
@PricePriceListIdIndex.MikroORMIndex() @PricePriceListIdIndex.MikroORMIndex()
@ManyToOne(() => PriceList, { @ManyToOne(() => PriceList, {
@@ -110,7 +111,7 @@ export default class Price {
price_list_id: string | null = null price_list_id: string | null = null
@ManyToOne(() => PriceList, { persist: false, nullable: true }) @ManyToOne(() => PriceList, { persist: false, nullable: true })
price_list: PriceList | null = null price_list: Rel<PriceList> | null = null
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
@@ -13,6 +13,7 @@ import {
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
Rel,
} from "@mikro-orm/core" } from "@mikro-orm/core"
import PriceSet from "./price-set" import PriceSet from "./price-set"
@@ -50,7 +51,7 @@ class RuleType {
default_priority: number default_priority: number
@ManyToMany(() => PriceSet, (priceSet) => priceSet.rule_types) @ManyToMany(() => PriceSet, (priceSet) => priceSet.rule_types)
price_sets = new Collection<PriceSet>(this) price_sets = new Collection<Rel<PriceSet>>(this)
@Property({ @Property({
onCreate: () => new Date(), onCreate: () => new Date(),
+6 -4
View File
@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types", "^@types": "<rootDir>/src/types",
}, },
transform: { transform: {
"^.+\\.[jt]s?$": [ "^.+\\.[jt]s$": [
"ts-jest", "@swc/jest",
{ {
tsconfig: "tsconfig.spec.json", jsc: {
isolatedModules: true, parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
}, },
], ],
}, },
-1
View File
@@ -42,7 +42,6 @@
"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",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-alias": "^1.8.6", "tsc-alias": "^1.8.6",
"typescript": "^5.1.6" "typescript": "^5.1.6"
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff. Show more