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
2024-06-20 12:59:33 +02:00
committed by GitHub
parent f61557712c
commit 03924a4ff6
137 changed files with 386 additions and 419 deletions

View File

@@ -58,7 +58,7 @@
"lint:path": "eslint --ignore-path .eslintignore --ext .js,.ts,.tsx",
"prettier": "prettier",
"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: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",

View File

@@ -1,13 +1,5 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
transform: { "^.+\\.[jt]s?$": "@swc/jest" },
testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`],
}

View File

@@ -24,7 +24,6 @@
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"dependencies": {

View File

@@ -84,7 +84,7 @@ export type RegisterModuleJoinerConfig =
| ModuleJoinerConfig
| ((modules: ModuleJoinerConfig[]) => ModuleJoinerConfig)
export class MedusaModule {
class MedusaModule {
private static instances_: Map<string, { [key: string]: IModuleService }> =
new Map()
private static modules_: Map<string, ModuleAlias[]> = new Map()
@@ -589,4 +589,6 @@ export class MedusaModule {
}
global.MedusaModule ??= MedusaModule
exports.MedusaModule = global.MedusaModule
const GlobalMedusaModule = global.MedusaModule as typeof MedusaModule
export { GlobalMedusaModule as MedusaModule }

View File

@@ -63,7 +63,7 @@ export class RemoteLink {
)
}
for (const mod of modulesLoaded) {
for (const mod of modulesLoaded || []) {
this.addModule(mod)
}
}

View File

@@ -39,7 +39,7 @@ export class RemoteQuery {
)
}
for (const mod of modulesLoaded) {
for (const mod of modulesLoaded || []) {
if (!mod.__definition.isQueryable) {
continue
}

View File

@@ -1,13 +1,5 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
transform: { "^.+\\.[jt]s?$": "@swc/jest" },
testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`],
}

View File

@@ -23,7 +23,6 @@
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"dependencies": {

View File

@@ -32,7 +32,7 @@ export class GlobalWorkflow extends WorkflowManager {
} else if (Array.isArray(modulesLoaded) && modulesLoaded.length) {
container = createMedusaContainer()
for (const mod of modulesLoaded) {
for (const mod of modulesLoaded || []) {
const registrationName = mod.__definition.registrationName
container.register(registrationName, asValue(mod))
}

View File

@@ -79,7 +79,7 @@ export class LocalWorkflow {
} else if (Array.isArray(modulesLoaded) && modulesLoaded.length) {
container = createMedusaContainer()
for (const mod of modulesLoaded) {
for (const mod of modulesLoaded || []) {
const registrationName = mod.__definition.registrationName
container.register(registrationName, asValue(mod))
}

View File

@@ -11,7 +11,6 @@ import {
TransactionStepsDefinition,
} from "../transaction"
import { WorkflowScheduler } from "./scheduler"
import { MedusaError } from "@medusajs/utils"
export interface WorkflowDefinition {
id: string
@@ -51,7 +50,7 @@ export type WorkflowStepHandler = (
args: WorkflowStepHandlerArguments
) => Promise<unknown>
export class WorkflowManager {
class WorkflowManager {
protected static workflows: Map<string, WorkflowDefinition> = new Map()
protected static scheduler = new WorkflowScheduler()
@@ -79,10 +78,7 @@ export class WorkflowManager {
static getTransactionDefinition(workflowId): OrchestratorBuilder {
if (!WorkflowManager.workflows.has(workflowId)) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Workflow with id "${workflowId}" not found.`
)
throw new Error(`Workflow with id "${workflowId}" not found.`)
}
const workflow = WorkflowManager.workflows.get(workflowId)!
@@ -232,4 +228,6 @@ export class WorkflowManager {
}
global.WorkflowManager ??= WorkflowManager
exports.WorkflowManager = global.WorkflowManager
const GlobalWorkflowManager = global.WorkflowManager
export { GlobalWorkflowManager as WorkflowManager }

View File

@@ -1,13 +1,5 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
transform: { "^.+\\.[jt]s?$": "@swc/jest" },
testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`],
}

View File

@@ -25,7 +25,6 @@
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"dependencies": {

View File

@@ -2,7 +2,7 @@ import { LocalWorkflow } from "@medusajs/orchestration"
import { LoadedModule, MedusaContainer } from "@medusajs/types"
import { ExportedWorkflow } from "./helper"
export class MedusaWorkflow {
class MedusaWorkflow {
static workflows: Record<
string,
(
@@ -28,4 +28,6 @@ export class MedusaWorkflow {
}
global.MedusaWorkflow ??= MedusaWorkflow
exports.MedusaWorkflow = global.MedusaWorkflow
const GlobalMedusaWorkflow = global.MedusaWorkflow
export { GlobalMedusaWorkflow as MedusaWorkflow }

View File

@@ -32,7 +32,6 @@
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"supertest": "^4.0.2",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
},
"scripts": {

View File

@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -40,7 +40,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.44",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -1,7 +1,7 @@
import { IAuthModuleService } from "@medusajs/types"
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 { createAuthIdentities } from "../../__fixtures__/auth-identity"
jest.setTimeout(30000)

View File

@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -39,8 +39,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.42",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"
},

View File

@@ -5,6 +5,7 @@ import {
OnInit,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import {
@@ -52,7 +53,7 @@ export default class ProviderIdentity {
@ManyToOne(() => AuthIdentity, {
persist: false,
})
auth_identity: AuthIdentity
auth_identity: Rel<AuthIdentity>
@Property({ columnType: "jsonb", nullable: true })
user_metadata: Record<string, unknown> | null

View File

@@ -24,7 +24,6 @@
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,13 +1,5 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
transform: { "^.+\\.[jt]s$": "@swc/jest" },
testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`],
}

View File

@@ -24,7 +24,6 @@
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -7,11 +7,13 @@ module.exports = {
"^@utils": "<rootDir>/src/utils",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -40,7 +40,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.44",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -16,6 +16,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Address from "./address"
import LineItem from "./line-item"
@@ -115,7 +116,7 @@ export default class Cart {
cascade: [Cascade.PERSIST],
nullable: true,
})
shipping_address: Address | null
shipping_address: Rel<Address> | null
@BillingAddressIdIndex()
@ManyToOne({
@@ -131,7 +132,7 @@ export default class Cart {
cascade: [Cascade.PERSIST],
nullable: true,
})
billing_address: Address | null
billing_address: Rel<Address> | null
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null
@@ -139,12 +140,12 @@ export default class Cart {
@OneToMany(() => LineItem, (lineItem) => lineItem.cart, {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
})
items = new Collection<LineItem>(this)
items = new Collection<Rel<LineItem>>(this)
@OneToMany(() => ShippingMethod, (shippingMethod) => shippingMethod.cart, {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
})
shipping_methods = new Collection<ShippingMethod>(this)
shipping_methods = new Collection<Rel<ShippingMethod>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -11,6 +11,7 @@ import {
ManyToOne,
OnInit,
Property,
Rel,
} from "@mikro-orm/core"
import AdjustmentLine from "./adjustment-line"
import LineItem from "./line-item"
@@ -42,7 +43,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class LineItemAdjustment extends AdjustmentLine {
@ManyToOne({ entity: () => LineItem, persist: false })
item: LineItem
item: Rel<LineItem>
@LineItemIdIndex()
@ManyToOne({

View File

@@ -10,6 +10,7 @@ import {
ManyToOne,
OnInit,
Property,
Rel,
} from "@mikro-orm/core"
import LineItem from "./line-item"
import TaxLine from "./tax-line"
@@ -38,7 +39,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class LineItemTaxLine extends TaxLine {
@ManyToOne({ entity: () => LineItem, persist: false })
item: LineItem
item: Rel<LineItem>
@LineItemIdIndex()
@ManyToOne({

View File

@@ -18,6 +18,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Cart from "./cart"
import LineItemAdjustment from "./line-item-adjustment"
@@ -76,7 +77,7 @@ export default class LineItem {
cart_id: string
@ManyToOne({ entity: () => Cart, persist: false })
cart: Cart
cart: Rel<Cart>
@Property({ columnType: "text" })
title: string
@@ -129,13 +130,13 @@ export default class LineItem {
variant_option_values: Record<string, unknown> | null = null
@Property({ columnType: "boolean" })
requires_shipping = true
requires_shipping: boolean = true
@Property({ columnType: "boolean" })
is_discountable = true
is_discountable: boolean = true
@Property({ columnType: "boolean" })
is_tax_inclusive = false
is_tax_inclusive: boolean = false
@MikroOrmBigNumberProperty({ nullable: true })
compare_at_unit_price?: BigNumber | number | null = null
@@ -152,12 +153,12 @@ export default class LineItem {
@OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, {
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, {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
})
adjustments = new Collection<LineItemAdjustment>(this)
adjustments = new Collection<Rel<LineItemAdjustment>>(this)
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null

View File

@@ -10,6 +10,7 @@ import {
ManyToOne,
OnInit,
Property,
Rel,
} from "@mikro-orm/core"
import AdjustmentLine from "./adjustment-line"
import ShippingMethod from "./shipping-method"
@@ -38,7 +39,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class ShippingMethodAdjustment extends AdjustmentLine {
@ManyToOne({ entity: () => ShippingMethod, persist: false })
shipping_method: ShippingMethod
shipping_method: Rel<ShippingMethod>
@ShippingMethodIdIndex()
@ManyToOne({

View File

@@ -10,6 +10,7 @@ import {
ManyToOne,
OnInit,
Property,
Rel,
} from "@mikro-orm/core"
import ShippingMethod from "./shipping-method"
import TaxLine from "./tax-line"
@@ -38,7 +39,7 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class ShippingMethodTaxLine extends TaxLine {
@ManyToOne({ entity: () => ShippingMethod, persist: false })
shipping_method: ShippingMethod
shipping_method: Rel<ShippingMethod>
@ShippingMethodIdIndex()
@ManyToOne({

View File

@@ -19,6 +19,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Cart from "./cart"
import ShippingMethodAdjustment from "./shipping-method-adjustment"
@@ -68,7 +69,7 @@ export default class ShippingMethod {
cart_id: string
@ManyToOne({ entity: () => Cart, persist: false })
cart: Cart
cart: Rel<Cart>
@Property({ columnType: "text" })
name: string
@@ -83,7 +84,7 @@ export default class ShippingMethod {
raw_amount: BigNumberRawValue
@Property({ columnType: "boolean" })
is_tax_inclusive = false
is_tax_inclusive: boolean = false
@ShippingOptionIdIndex()
@Property({ columnType: "text", nullable: true })
@@ -102,7 +103,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
}
)
tax_lines = new Collection<ShippingMethodTaxLine>(this)
tax_lines = new Collection<Rel<ShippingMethodTaxLine>>(this)
@OneToMany(
() => ShippingMethodAdjustment,
@@ -111,7 +112,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
}
)
adjustments = new Collection<ShippingMethodAdjustment>(this)
adjustments = new Collection<Rel<ShippingMethodAdjustment>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -5,11 +5,13 @@ module.exports = {
"^@repositories": "<rootDir>/src/repositories",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -40,7 +40,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.44",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -1,14 +1,15 @@
import { DAL } from "@medusajs/types"
import { generateEntityId } from "@medusajs/utils"
import {
Cascade,
BeforeCreate,
ManyToOne,
Cascade,
Entity,
ManyToOne,
OnInit,
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Customer from "./customer"
import CustomerGroup from "./customer-group"
@@ -34,7 +35,7 @@ export default class CustomerGroupCustomer {
index: "IDX_customer_group_customer_customer_id",
cascade: [Cascade.REMOVE],
})
customer: Customer
customer: Rel<Customer>
@ManyToOne({
entity: () => CustomerGroup,
@@ -42,7 +43,7 @@ export default class CustomerGroupCustomer {
index: "IDX_customer_group_customer_group_id",
cascade: [Cascade.REMOVE],
})
customer_group: CustomerGroup
customer_group: Rel<CustomerGroup>
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null

View File

@@ -15,6 +15,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Customer from "./customer"
import CustomerGroupCustomer from "./customer-group-customer"
@@ -45,7 +46,7 @@ export default class CustomerGroup {
entity: () => Customer,
pivotEntity: () => CustomerGroupCustomer,
})
customers = new Collection<Customer>(this)
customers = new Collection<Rel<Customer>>(this)
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null

View File

@@ -17,6 +17,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Address from "./address"
import CustomerGroup from "./customer-group"
@@ -74,12 +75,12 @@ export default class Customer {
entity: () => CustomerGroup,
pivotEntity: () => CustomerGroupCustomer,
})
groups = new Collection<CustomerGroup>(this)
groups = new Collection<Rel<CustomerGroup>>(this)
@OneToMany(() => Address, (address) => address.customer, {
cascade: [Cascade.REMOVE],
})
addresses = new Collection<Address>(this)
addresses = new Collection<Rel<Address>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -1,12 +1,6 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
"^.+\\.[jt]s$": ["@swc/jest"],
},
testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`],

View File

@@ -24,7 +24,6 @@
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,13 +1,5 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
},
],
},
transform: { "^.+\\.[jt]s$": ["@swc/jest"] },
testEnvironment: `node`,
moduleFileExtensions: [`js`, `ts`],
}

View File

@@ -25,7 +25,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.44",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -42,7 +42,6 @@
"medusa-test-utils": "^1.1.43",
"pg-god": "^1.0.12",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -7,11 +7,13 @@ module.exports = {
"^@utils": "<rootDir>/src/utils",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -40,7 +40,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.44",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -16,6 +16,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Fulfillment from "./fulfillment"
@@ -86,7 +87,7 @@ export default class FulfillmentItem {
fulfillment_id: string
@ManyToOne(() => Fulfillment, { persist: false })
fulfillment: Fulfillment
fulfillment: Rel<Fulfillment>
@Property({
onCreate: () => new Date(),

View File

@@ -14,6 +14,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Fulfillment from "./fulfillment"
@@ -58,7 +59,7 @@ export default class FulfillmentLabel {
fulfillment_id: string
@ManyToOne(() => Fulfillment, { persist: false })
fulfillment: Fulfillment
fulfillment: Rel<Fulfillment>
@Property({
onCreate: () => new Date(),

View File

@@ -16,6 +16,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ServiceZone from "./service-zone"
@@ -56,7 +57,7 @@ export default class FulfillmentSet {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true,
})
service_zones = new Collection<ServiceZone>(this)
service_zones = new Collection<Rel<ServiceZone>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -18,6 +18,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Address from "./address"
import FulfillmentItem from "./fulfillment-item"
@@ -117,7 +118,7 @@ export default class Fulfillment {
shipping_option: ShippingOption | null
@ManyToOne(() => FulfillmentProvider, { persist: false })
provider: FulfillmentProvider
provider: Rel<FulfillmentProvider>
@OneToOne({
entity: () => Address,
@@ -126,19 +127,19 @@ export default class Fulfillment {
nullable: true,
onDelete: "cascade",
})
delivery_address!: Address
delivery_address!: Rel<Address>
@OneToMany(() => FulfillmentItem, (item) => item.fulfillment, {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true,
})
items = new Collection<FulfillmentItem>(this)
items = new Collection<Rel<FulfillmentItem>>(this)
@OneToMany(() => FulfillmentLabel, (label) => label.fulfillment, {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true,
})
labels = new Collection<FulfillmentLabel>(this)
labels = new Collection<Rel<FulfillmentLabel>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -16,6 +16,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ServiceZone from "./service-zone"
@@ -92,7 +93,7 @@ export default class GeoZone {
@ManyToOne(() => ServiceZone, {
persist: false,
})
service_zone: ServiceZone
service_zone: Rel<ServiceZone>
@Property({
onCreate: () => new Date(),

View File

@@ -18,6 +18,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import FulfillmentSet from "./fulfillment-set"
import GeoZone from "./geo-zone"
@@ -71,13 +72,13 @@ export default class ServiceZone {
fulfillment_set_id: string
@ManyToOne(() => FulfillmentSet, { persist: false })
fulfillment_set: FulfillmentSet
fulfillment_set: Rel<FulfillmentSet>
@OneToMany(() => GeoZone, "service_zone", {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true,
})
geo_zones = new Collection<GeoZone>(this)
geo_zones = new Collection<Rel<GeoZone>>(this)
@OneToMany(
() => ShippingOption,
@@ -87,7 +88,7 @@ export default class ServiceZone {
orphanRemoval: true,
}
)
shipping_options = new Collection<ShippingOption>(this)
shipping_options = new Collection<Rel<ShippingOption>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -15,6 +15,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ShippingOption from "./shipping-option"
@@ -64,7 +65,7 @@ export default class ShippingOptionRule {
@ManyToOne(() => ShippingOption, {
persist: false,
})
shipping_option: ShippingOption
shipping_option: Rel<ShippingOption>
@Property({
onCreate: () => new Date(),

View File

@@ -14,6 +14,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ShippingOption from "./shipping-option"
@@ -52,7 +53,7 @@ export default class ShippingOptionType {
type: "text",
onDelete: "cascade",
})
shipping_option: ShippingOption
shipping_option: Rel<ShippingOption>
@Property({
onCreate: () => new Date(),

View File

@@ -21,6 +21,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Fulfillment from "./fulfillment"
import FulfillmentProvider from "./fulfillment-provider"
@@ -118,17 +119,17 @@ export default class ShippingOption {
metadata: Record<string, unknown> | null = null
@ManyToOne(() => ServiceZone, { persist: false })
service_zone: ServiceZone
service_zone: Rel<ServiceZone>
@ManyToOne(() => ShippingProfile, {
persist: false,
})
shipping_profile: ShippingProfile | null
shipping_profile: Rel<ShippingProfile> | null
@ManyToOne(() => FulfillmentProvider, {
persist: false,
})
provider: FulfillmentProvider | null
provider: Rel<FulfillmentProvider> | null
@OneToOne(() => ShippingOptionType, (so) => so.shipping_option, {
owner: true,
@@ -137,16 +138,16 @@ export default class ShippingOption {
fieldName: "shipping_option_type_id",
onDelete: "cascade",
})
type: ShippingOptionType
type: Rel<ShippingOptionType>
@OneToMany(() => ShippingOptionRule, "shipping_option", {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
orphanRemoval: true,
})
rules = new Collection<ShippingOptionRule>(this)
rules = new Collection<Rel<ShippingOptionRule>>(this)
@OneToMany(() => Fulfillment, (fulfillment) => fulfillment.shipping_option)
fulfillments = new Collection<Fulfillment>(this)
fulfillments = new Collection<Rel<Fulfillment>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -16,6 +16,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ShippingOption from "./shipping-option"
@@ -55,7 +56,7 @@ export default class ShippingProfile {
() => ShippingOption,
(shippingOption) => shippingOption.shipping_profile
)
shipping_options = new Collection<ShippingOption>(this)
shipping_options = new Collection<Rel<ShippingOption>>(this)
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null

View File

@@ -1,10 +1,12 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -26,7 +26,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.43",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -1,3 +1,9 @@
import {
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
Searchable,
} from "@medusajs/utils"
import {
BeforeCreate,
Collection,
@@ -9,13 +15,8 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import {
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
Searchable,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import { InventoryLevel } from "./inventory-level"
@@ -117,7 +118,7 @@ export class InventoryItem {
cascade: ["soft-remove" as any],
}
)
location_levels = new Collection<InventoryLevel>(this)
location_levels = new Collection<Rel<InventoryLevel>>(this)
@OneToMany(
() => ReservationItem,
@@ -126,7 +127,7 @@ export class InventoryItem {
cascade: ["soft-remove" as any],
}
)
reservation_items = new Collection<ReservationItem>(this)
reservation_items = new Collection<Rel<ReservationItem>>(this)
@Formula(
(item) =>

View File

@@ -1,3 +1,4 @@
import { DALUtils, isDefined } from "@medusajs/utils"
import {
BeforeCreate,
Entity,
@@ -7,12 +8,14 @@ import {
OnLoad,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import { DALUtils, isDefined } from "@medusajs/utils"
import {
createPsqlIndexStatementHelper,
generateEntityId,
} from "@medusajs/utils"
import { InventoryItem } from "./inventory-item"
import { createPsqlIndexStatementHelper } from "@medusajs/utils"
import { generateEntityId } from "@medusajs/utils"
const InventoryLevelDeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "inventory_level",
@@ -90,7 +93,7 @@ export class InventoryLevel {
@ManyToOne(() => InventoryItem, {
persist: false,
})
inventory_item: InventoryItem
inventory_item: Rel<InventoryItem>
available_quantity: number | null = null

View File

@@ -6,6 +6,7 @@ import {
OnInit,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import {
@@ -98,7 +99,7 @@ export class ReservationItem {
@ManyToOne(() => InventoryItem, {
persist: false,
})
inventory_item: InventoryItem
inventory_item: Rel<InventoryItem>
@BeforeCreate()
private beforeCreate(): void {

View File

@@ -1,10 +1,12 @@
module.exports = {
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -34,7 +34,6 @@
"jest": "^29.7.0",
"pg-god": "^1.0.12",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -7,11 +7,13 @@ module.exports = {
"^@utils": "<rootDir>/src/utils",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -39,7 +39,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.44",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -40,7 +40,6 @@
"jest": "^29.7.0",
"medusa-test-utils": "^1.1.44",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

View File

@@ -11,6 +11,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ClaimItem from "./claim-item"
@@ -47,7 +48,7 @@ export default class ClaimItemImage {
@ManyToOne(() => ClaimItem, {
persist: false,
})
item: ClaimItem
item: Rel<ClaimItem>
@Property({ columnType: "text" })
url: string

View File

@@ -17,6 +17,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Claim from "./claim"
import ClaimItemImage from "./claim-item-image"
@@ -52,10 +53,10 @@ export default class OrderClaimItem {
@OneToMany(() => ClaimItemImage, (ci) => ci.item, {
cascade: [Cascade.PERSIST, Cascade.REMOVE],
})
images = new Collection<ClaimItemImage>(this)
images = new Collection<Rel<ClaimItemImage>>(this)
@Enum({ items: () => ClaimReason, nullable: true })
reason: ClaimReason | null = null
reason: Rel<ClaimReason> | null = null
@MikroOrmBigNumberProperty()
quantity: Number | number
@@ -75,7 +76,7 @@ export default class OrderClaimItem {
@ManyToOne(() => Claim, {
persist: false,
})
claim: Claim
claim: Rel<Claim>
@ManyToOne({
entity: () => LineItem,
@@ -89,7 +90,7 @@ export default class OrderClaimItem {
@ManyToOne(() => LineItem, {
persist: false,
})
item: LineItem
item: Rel<LineItem>
@Property({ columnType: "boolean", default: false })
is_additional_item: boolean = false

View File

@@ -19,6 +19,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ClaimItem from "./claim-item"
import Order from "./order"
@@ -71,7 +72,7 @@ export default class OrderClaim {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@OneToOne({
entity: () => Return,
@@ -81,7 +82,7 @@ export default class OrderClaim {
nullable: true,
owner: true,
})
return: Return
return: Rel<Return>
@Property({ columnType: "text", nullable: true })
@ReturnIdIndex.MikroORMIndex()
@@ -97,7 +98,7 @@ export default class OrderClaim {
display_id: number
@Enum({ items: () => ClaimType })
type: ClaimType
type: Rel<ClaimType>
@Property({ columnType: "boolean", nullable: true })
no_notification: boolean | null = null
@@ -113,12 +114,12 @@ export default class OrderClaim {
@OneToMany(() => ClaimItem, (item) => item.claim, {
cascade: [Cascade.PERSIST],
})
additional_items = new Collection<ClaimItem>(this)
additional_items = new Collection<Rel<ClaimItem>>(this)
@OneToMany(() => ClaimItem, (item) => item.claim, {
cascade: [Cascade.PERSIST],
})
claim_items = new Collection<ClaimItem>(this)
claim_items = new Collection<Rel<ClaimItem>>(this)
@OneToMany(
() => OrderShippingMethod,
@@ -127,7 +128,7 @@ export default class OrderClaim {
cascade: [Cascade.PERSIST],
}
)
shipping_methods = new Collection<OrderShippingMethod>(this)
shipping_methods = new Collection<Rel<OrderShippingMethod>>(this)
@OneToMany(() => Transaction, (transaction) => transaction.claim, {
cascade: [Cascade.PERSIST],

View File

@@ -17,6 +17,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import { ExchangeItem, Transaction } from "@models"
import Order from "./order"
@@ -68,7 +69,7 @@ export default class OrderExchange {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@OneToOne({
entity: () => Return,
@@ -78,7 +79,7 @@ export default class OrderExchange {
nullable: true,
owner: true,
})
return: Return
return: Rel<Return>
@Property({ columnType: "text", nullable: true })
@ReturnIdIndex.MikroORMIndex()
@@ -110,7 +111,7 @@ export default class OrderExchange {
@OneToMany(() => ExchangeItem, (item) => item.exchange, {
cascade: [Cascade.PERSIST],
})
additional_items = new Collection<ExchangeItem>(this)
additional_items = new Collection<Rel<ExchangeItem>>(this)
@OneToMany(
() => OrderShippingMethod,
@@ -119,7 +120,7 @@ export default class OrderExchange {
cascade: [Cascade.PERSIST],
}
)
shipping_methods = new Collection<OrderShippingMethod>(this)
shipping_methods = new Collection<Rel<OrderShippingMethod>>(this)
@OneToMany(() => Transaction, (transaction) => transaction.exchange, {
cascade: [Cascade.PERSIST],

View File

@@ -2,7 +2,7 @@ import {
createPsqlIndexStatementHelper,
generateEntityId,
} 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 LineItem from "./line-item"
@@ -16,7 +16,7 @@ export default class LineItemAdjustment extends AdjustmentLine {
@ManyToOne(() => LineItem, {
persist: false,
})
item: LineItem
item: Rel<LineItem>
@ManyToOne({
entity: () => LineItem,

View File

@@ -8,6 +8,7 @@ import {
Entity,
ManyToOne,
OnInit,
Rel,
} from "@mikro-orm/core"
import LineItem from "./line-item"
import TaxLine from "./tax-line"
@@ -23,7 +24,7 @@ export default class LineItemTaxLine extends TaxLine {
fieldName: "item_id",
persist: false,
})
item: LineItem
item: Rel<LineItem>
@ManyToOne({
entity: () => LineItem,

View File

@@ -15,6 +15,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import LineItemAdjustment from "./line-item-adjustment"
import LineItemTaxLine from "./line-item-tax-line"
@@ -92,13 +93,13 @@ export default class LineItem {
variant_option_values: Record<string, unknown> | null = null
@Property({ columnType: "boolean" })
requires_shipping = true
requires_shipping: boolean = true
@Property({ columnType: "boolean" })
is_discountable = true
is_discountable: boolean = true
@Property({ columnType: "boolean" })
is_tax_inclusive = false
is_tax_inclusive: boolean = false
@MikroOrmBigNumberProperty({
nullable: true,
@@ -119,12 +120,12 @@ export default class LineItem {
@OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, {
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, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
})
adjustments = new Collection<LineItemAdjustment>(this)
adjustments = new Collection<Rel<LineItemAdjustment>>(this)
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null

View File

@@ -13,6 +13,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import OrderClaim from "./claim"
import OrderExchange from "./exchange"
@@ -90,7 +91,7 @@ export default class OrderChangeAction {
persist: false,
nullable: true,
})
order: Order | null = null
order: Rel<Order> | null = null
@ManyToOne({
entity: () => Return,
@@ -155,7 +156,7 @@ export default class OrderChangeAction {
persist: false,
nullable: true,
})
order_change: OrderChange | null = null
order_change: Rel<OrderChange> | null = null
@Property({
columnType: "text",

View File

@@ -15,6 +15,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import { OrderChangeStatus, OrderChangeType } from "@types"
import OrderClaim from "./claim"
@@ -94,7 +95,7 @@ export default class OrderChange {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@ManyToOne({
entity: () => Return,
@@ -109,7 +110,7 @@ export default class OrderChange {
@ManyToOne(() => Return, {
persist: false,
})
return: Return
return: Rel<Return>
@ManyToOne({
entity: () => OrderClaim,
@@ -152,7 +153,7 @@ export default class OrderChange {
@OneToMany(() => OrderChangeAction, (action) => action.order_change, {
cascade: [Cascade.PERSIST, "sotf-remove" as Cascade],
})
actions = new Collection<OrderChangeAction>(this)
actions = new Collection<Rel<OrderChangeAction>>(this)
@Property({
columnType: "text",

View File

@@ -13,6 +13,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import LineItem from "./line-item"
import Order from "./order"
@@ -62,7 +63,7 @@ export default class OrderItem {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@Property({ columnType: "integer" })
@OrderVersionIndex.MikroORMIndex()
@@ -80,7 +81,7 @@ export default class OrderItem {
@ManyToOne(() => LineItem, {
persist: false,
})
item: LineItem
item: Rel<LineItem>
@MikroOrmBigNumberProperty()
quantity: BigNumber | number

View File

@@ -11,6 +11,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Claim from "./claim"
import Exchange from "./exchange"
@@ -81,7 +82,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@ManyToOne({
entity: () => Return,
@@ -96,7 +97,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Return, {
persist: false,
})
return: Return
return: Rel<Return>
@ManyToOne({
entity: () => Exchange,
@@ -111,7 +112,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Exchange, {
persist: false,
})
exchange: Exchange
exchange: Rel<Exchange>
@ManyToOne({
entity: () => Claim,
@@ -126,7 +127,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => Claim, {
persist: false,
})
claim: Claim
claim: Rel<Claim>
@Property({ columnType: "integer" })
@OrderVersionIndex.MikroORMIndex()
@@ -144,7 +145,7 @@ export default class OrderShippingMethod {
@ManyToOne(() => ShippingMethod, {
persist: false,
})
shipping_method: ShippingMethod
shipping_method: Rel<ShippingMethod>
@Property({
onCreate: () => new Date(),

View File

@@ -10,6 +10,7 @@ import {
OnInit,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Order from "./order"
@@ -71,7 +72,7 @@ export default class OrderSummary {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@Property({
columnType: "integer",

View File

@@ -16,6 +16,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Address from "./address"
import OrderItem from "./order-item"
@@ -127,7 +128,7 @@ export default class Order {
columnType: "boolean",
})
@IsDraftOrderIndex.MikroORMIndex()
is_draft_order = false
is_draft_order: boolean = false
@Property({ columnType: "text", nullable: true })
email: string | null = null
@@ -146,7 +147,7 @@ export default class Order {
nullable: true,
cascade: [Cascade.PERSIST],
})
shipping_address?: Address | null
shipping_address?: Rel<Address> | null
@Property({ columnType: "text", nullable: true })
@BillingAddressIdIndex.MikroORMIndex()
@@ -158,7 +159,7 @@ export default class Order {
nullable: true,
cascade: [Cascade.PERSIST],
})
billing_address?: Address | null
billing_address?: Rel<Address> | null
@Property({ columnType: "boolean", nullable: true })
no_notification: boolean | null = null
@@ -166,7 +167,7 @@ export default class Order {
@OneToMany(() => OrderSummary, (summary) => summary.order, {
cascade: [Cascade.PERSIST],
})
summary = new Collection<OrderSummary>(this)
summary = new Collection<Rel<OrderSummary>>(this)
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null
@@ -174,7 +175,7 @@ export default class Order {
@OneToMany(() => OrderItem, (itemDetail) => itemDetail.order, {
cascade: [Cascade.PERSIST],
})
items = new Collection<OrderItem>(this)
items = new Collection<Rel<OrderItem>>(this)
@OneToMany(
() => OrderShippingMethod,
@@ -183,12 +184,12 @@ export default class Order {
cascade: [Cascade.PERSIST],
}
)
shipping_methods = new Collection<OrderShippingMethod>(this)
shipping_methods = new Collection<Rel<OrderShippingMethod>>(this)
@OneToMany(() => Transaction, (transaction) => transaction.order, {
cascade: [Cascade.PERSIST],
})
transactions = new Collection<Transaction>(this)
transactions = new Collection<Rel<Transaction>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -13,6 +13,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
const DeletedAtIndex = createPsqlIndexStatementHelper({
@@ -62,14 +63,14 @@ export default class ReturnReason {
nullable: true,
cascade: [Cascade.PERSIST],
})
parent_return_reason?: ReturnReason | null
parent_return_reason?: Rel<ReturnReason> | null
@OneToMany(
() => ReturnReason,
(return_reason) => return_reason.parent_return_reason,
{ cascade: [Cascade.PERSIST] }
)
return_reason_children: ReturnReason[]
return_reason_children: Rel<ReturnReason>[]
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null

View File

@@ -19,6 +19,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import { ReturnItem, Transaction } from "@models"
import Claim from "./claim"
@@ -78,7 +79,7 @@ export default class Return {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@OneToOne({
entity: () => Exchange,
@@ -86,7 +87,7 @@ export default class Return {
fieldName: "exchange_id",
nullable: true,
})
exchange: Exchange
exchange: Rel<Exchange>
@Property({ columnType: "text", nullable: true })
@ExchangeIdIndex.MikroORMIndex()
@@ -98,7 +99,7 @@ export default class Return {
fieldName: "claim_id",
nullable: true,
})
claim: Claim
claim: Rel<Claim>
@Property({ columnType: "text", nullable: true })
@ClaimIdIndex.MikroORMIndex()
@@ -130,7 +131,7 @@ export default class Return {
@OneToMany(() => ReturnItem, (itemDetail) => itemDetail.return, {
cascade: [Cascade.PERSIST],
})
items = new Collection<OrderItem>(this)
items = new Collection<Rel<OrderItem>>(this)
@OneToMany(
() => OrderShippingMethod,

View File

@@ -2,7 +2,7 @@ import {
createPsqlIndexStatementHelper,
generateEntityId,
} 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 ShippingMethod from "./shipping-method"
@@ -16,7 +16,7 @@ export default class ShippingMethodAdjustment extends AdjustmentLine {
@ManyToOne(() => ShippingMethod, {
persist: false,
})
shipping_method: ShippingMethod
shipping_method: Rel<ShippingMethod>
@ManyToOne({
entity: () => ShippingMethod,

View File

@@ -2,7 +2,7 @@ import {
createPsqlIndexStatementHelper,
generateEntityId,
} 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 TaxLine from "./tax-line"
@@ -16,7 +16,7 @@ export default class ShippingMethodTaxLine extends TaxLine {
@ManyToOne(() => ShippingMethod, {
persist: false,
})
shipping_method: ShippingMethod
shipping_method: Rel<ShippingMethod>
@ManyToOne({
entity: () => ShippingMethod,

View File

@@ -14,6 +14,7 @@ import {
OnInit,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import ShippingMethodAdjustment from "./shipping-method-adjustment"
import ShippingMethodTaxLine from "./shipping-method-tax-line"
@@ -41,7 +42,7 @@ export default class ShippingMethod {
raw_amount: BigNumberRawValue
@Property({ columnType: "boolean" })
is_tax_inclusive = false
is_tax_inclusive: boolean = false
@Property({
columnType: "text",
@@ -63,7 +64,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST],
}
)
tax_lines = new Collection<ShippingMethodTaxLine>(this)
tax_lines = new Collection<Rel<ShippingMethodTaxLine>>(this)
@OneToMany(
() => ShippingMethodAdjustment,
@@ -72,7 +73,7 @@ export default class ShippingMethod {
cascade: [Cascade.PERSIST],
}
)
adjustments = new Collection<ShippingMethodAdjustment>(this)
adjustments = new Collection<Rel<ShippingMethodAdjustment>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -13,6 +13,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Claim from "./claim"
import Exchange from "./exchange"
@@ -90,7 +91,7 @@ export default class Transaction {
@ManyToOne(() => Order, {
persist: false,
})
order: Order
order: Rel<Order>
@ManyToOne({
entity: () => Return,
@@ -105,7 +106,7 @@ export default class Transaction {
@ManyToOne(() => Return, {
persist: false,
})
return: Return
return: Rel<Return>
@ManyToOne({
entity: () => Exchange,
@@ -120,7 +121,7 @@ export default class Transaction {
@ManyToOne(() => Exchange, {
persist: false,
})
exchange: Exchange
exchange: Rel<Exchange>
@ManyToOne({
entity: () => Claim,
@@ -135,7 +136,7 @@ export default class Transaction {
@ManyToOne(() => Claim, {
persist: false,
})
claim: Claim
claim: Rel<Claim>
@Property({
columnType: "integer",

View File

@@ -174,7 +174,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
expect(collection.length).toEqual(1)
await service.deletePaymentCollections(["pay-col-id-1"])
await service.deletePaymentCollections("pay-col-id-1")
collection = await service.listPaymentCollections({
id: ["pay-col-id-1"],

View File

@@ -19,6 +19,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Payment from "./payment"
import PaymentProvider from "./payment-provider"
@@ -99,17 +100,17 @@ export default class PaymentCollection {
status: PaymentCollectionStatus = PaymentCollectionStatus.NOT_PAID
@ManyToMany(() => PaymentProvider)
payment_providers = new Collection<PaymentProvider>(this)
payment_providers = new Collection<Rel<PaymentProvider>>(this)
@OneToMany(() => PaymentSession, (ps) => ps.payment_collection, {
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, {
cascade: [Cascade.PERSIST, "soft-remove"] as any,
})
payments = new Collection<Payment>(this)
payments = new Collection<Rel<Payment>>(this)
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null

View File

@@ -15,6 +15,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Payment from "./payment"
import PaymentCollection from "./payment-collection"
@@ -60,7 +61,7 @@ export default class PaymentSession {
@ManyToOne(() => PaymentCollection, {
persist: false,
})
payment_collection: PaymentCollection
payment_collection: Rel<PaymentCollection>
@ManyToOne({
entity: () => PaymentCollection,
@@ -76,7 +77,7 @@ export default class PaymentSession {
nullable: true,
mappedBy: "payment_session",
})
payment?: Payment | null
payment?: Rel<Payment> | null
@Property({
onCreate: () => new Date(),

View File

@@ -19,6 +19,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Capture from "./capture"
import PaymentCollection from "./payment-collection"
@@ -102,18 +103,18 @@ export default class Payment {
@OneToMany(() => Refund, (refund) => refund.payment, {
cascade: [Cascade.REMOVE],
})
refunds = new Collection<Refund>(this)
refunds = new Collection<Rel<Refund>>(this)
@OneToMany(() => Capture, (capture) => capture.payment, {
cascade: [Cascade.REMOVE],
})
captures = new Collection<Capture>(this)
captures = new Collection<Rel<Capture>>(this)
@ManyToOne({
entity: () => PaymentCollection,
persist: false,
})
payment_collection: PaymentCollection
payment_collection: Rel<PaymentCollection>
@ManyToOne({
entity: () => PaymentCollection,
@@ -125,11 +126,12 @@ export default class Payment {
payment_collection_id: string
@OneToOne({
entity: () => PaymentSession,
owner: true,
fieldName: "payment_session_id",
index: "IDX_payment_payment_session_id",
})
payment_session: PaymentSession
payment_session: Rel<PaymentSession>
@BeforeCreate()
onCreate() {

View File

@@ -11,6 +11,7 @@ import {
OnInit,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Payment from "./payment"
@@ -30,7 +31,7 @@ export default class Refund {
index: "IDX_refund_payment_id",
fieldName: "payment_id",
})
payment!: Payment
payment!: Rel<Payment>
@Property({
onCreate: () => new Date(),

View File

@@ -13,6 +13,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import PriceListRule from "./price-list-rule"
@@ -49,7 +50,7 @@ export default class PriceListRuleValue {
price_list_rule_id: string
@ManyToOne(() => PriceListRule, { persist: false })
price_list_rule: PriceListRule
price_list_rule: Rel<PriceListRule>
@Property({ columnType: "text" })
value: string

View File

@@ -16,6 +16,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import PriceList from "./price-list"
import PriceListRuleValue from "./price-list-rule-value"
@@ -60,12 +61,12 @@ export default class PriceListRule {
rule_type_id: string
@ManyToOne(() => RuleType, { persist: false })
rule_type: RuleType
rule_type: Rel<RuleType>
@OneToMany(() => PriceListRuleValue, (plrv) => plrv.price_list_rule, {
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()
@ManyToOne(() => PriceList, {
@@ -77,7 +78,7 @@ export default class PriceListRule {
price_list_id: string
@ManyToOne(() => PriceList, { persist: false })
price_list: PriceList
price_list: Rel<PriceList>
@Property({
onCreate: () => new Date(),

View File

@@ -20,6 +20,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Price from "./price"
import PriceListRule from "./price-list-rule"
@@ -76,18 +77,18 @@ export default class PriceList {
@OneToMany(() => Price, (price) => price.price_list, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
})
prices = new Collection<Price>(this)
prices = new Collection<Rel<Price>>(this)
@OneToMany(() => PriceListRule, (pr) => pr.price_list, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
})
price_list_rules = new Collection<PriceListRule>(this)
price_list_rules = new Collection<Rel<PriceListRule>>(this)
@ManyToMany({
entity: () => RuleType,
pivotEntity: () => PriceListRule,
})
rule_types = new Collection<RuleType>(this)
rule_types = new Collection<Rel<RuleType>>(this)
@Property({ columnType: "integer", default: 0 })
rules_count: number = 0

View File

@@ -13,6 +13,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Price from "./price"
import PriceSet from "./price-set"
@@ -64,7 +65,7 @@ export default class PriceRule {
price_set_id: string
@ManyToOne(() => PriceSet, { persist: false })
price_set: PriceSet
price_set: Rel<PriceSet>
@PriceRuleRuleTypeIdIndex.MikroORMIndex()
@ManyToOne(() => RuleType, {
@@ -75,7 +76,7 @@ export default class PriceRule {
rule_type_id: string
@ManyToOne(() => RuleType, { persist: false })
rule_type: RuleType
rule_type: Rel<RuleType>
@Property({ columnType: "text" })
value: string
@@ -93,7 +94,7 @@ export default class PriceRule {
price_id: string
@ManyToOne(() => Price, { persist: false })
price: Price
price: Rel<Price>
@Property({
onCreate: () => new Date(),

View File

@@ -14,6 +14,7 @@ import {
OnInit,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Price from "./price"
import PriceRule from "./price-rule"
@@ -38,19 +39,19 @@ export default class PriceSet {
@OneToMany(() => Price, (price) => price.price_set, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
})
prices = new Collection<Price>(this)
prices = new Collection<Rel<Price>>(this)
@OneToMany(() => PriceRule, (pr) => pr.price_set, {
cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
})
price_rules = new Collection<PriceRule>(this)
price_rules = new Collection<Rel<PriceRule>>(this)
@ManyToMany({
entity: () => RuleType,
pivotEntity: () => PriceSetRuleType,
cascade: ["soft-remove" as Cascade],
})
rule_types = new Collection<RuleType>(this)
rule_types = new Collection<Rel<RuleType>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -18,6 +18,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import PriceList from "./price-list"
import PriceRule from "./price-rule"
@@ -87,7 +88,7 @@ export default class Price {
price_set_id: string
@ManyToOne(() => PriceSet, { persist: false })
price_set?: PriceSet
price_set?: Rel<PriceSet>
@Property({ columnType: "integer", default: 0 })
rules_count: number = 0
@@ -97,7 +98,7 @@ export default class Price {
mappedBy: (pr) => pr.price,
cascade: [Cascade.PERSIST, "soft-remove" as Cascade],
})
price_rules = new Collection<PriceRule>(this)
price_rules = new Collection<Rel<PriceRule>>(this)
@PricePriceListIdIndex.MikroORMIndex()
@ManyToOne(() => PriceList, {
@@ -110,7 +111,7 @@ export default class Price {
price_list_id: string | null = null
@ManyToOne(() => PriceList, { persist: false, nullable: true })
price_list: PriceList | null = null
price_list: Rel<PriceList> | null = null
@Property({
onCreate: () => new Date(),

View File

@@ -13,6 +13,7 @@ import {
OptionalProps,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import PriceSet from "./price-set"
@@ -50,7 +51,7 @@ class RuleType {
default_priority: number
@ManyToMany(() => PriceSet, (priceSet) => priceSet.rule_types)
price_sets = new Collection<PriceSet>(this)
price_sets = new Collection<Rel<PriceSet>>(this)
@Property({
onCreate: () => new Date(),

View File

@@ -6,11 +6,13 @@ module.exports = {
"^@types": "<rootDir>/src/types",
},
transform: {
"^.+\\.[jt]s?$": [
"ts-jest",
"^.+\\.[jt]s$": [
"@swc/jest",
{
tsconfig: "tsconfig.spec.json",
isolatedModules: true,
jsc: {
parser: { syntax: "typescript", decorators: true },
transform: { decoratorMetadata: true },
},
},
],
},

View File

@@ -42,7 +42,6 @@
"medusa-test-utils": "^1.1.44",
"pg-god": "^1.0.12",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.6"

Some files were not shown because too many files have changed in this diff Show More