chore(order): dml (#10292)
* ../../core/types/src/dml/index.ts * ../../core/types/src/dml/index.ts * fix: relationships mapping * handle nullable foreign keys types * handle nullable foreign keys types * handle nullable foreign keys types * continue to update product category repository * fix all product category repositories issues * fix product category service types * fix product module service types * fix product module service types * fix repository template type * refactor: use a singleton DMLToMikroORM factory instance Since the MikroORM MetadataStorage is global, we will also have to turn DML to MikroORM entities conversion use a global bucket as well * refactor: update product module to use DML in tests * wip: tests * WIP product linkable fixes * continue type fixing and start test fixing * test: fix more tests * fix repository * fix pivot table computaion + fix mikro orm repository * fix many to many management and configuration * fix many to many management and configuration * fix many to many management and configuration * update product tag relation configuration * Introduce experimental dml hooks to fix some issues with categories * more fixes * fix product tests * add missing id prefixes * fix product category handle management * test: fix more failing tests * test: make it all green * test: fix breaking tests * fix: build issues * fix: build issues * fix: more breaking tests * refactor: fix issues after merge * refactor: fix issues after merge * refactor: surpress types error * test: fix DML failing tests * improve many to many inference + tests * Wip fix columns from product entity * remove product model before create hook and manage handle validation and transformation at the service level * test: fix breaking unit tests * fix: product module service to not update handle on product update * fix define link and joiner config * test: fix joiner config test * test: fix joiner config test * fix joiner config primary keys * Fix joiner config builder * Fix joiner config builder * test: remove only modifier from test * refactor: remove hooks usage from product collection * refactor: remove hooks usage from product-option * refactor: remove hooks usage for computing category handle * refactor: remove hooks usage from productCategory model * refactor: remove hooks from DML * refactor: remove cruft * order dml * cleanup * re add foerign key indexes * wip * chore: remove unused types * wip * changes * rm raw * autoincrement * wip * rel * refactor: cleanup * migration and models configuration adjustments * cleanup * number searchable * fix random ordering * fix * test: fix product-category tests * test: update breaking DML tests * test: array assertion to not care about ordering * fix: temporarily apply id ordering for products * types * wip * WIP type improvements * update order models * partially fix types temporarely * rel * fix: recursive type issue * improve type inference breaks * improve type inference breaks * update models * rm nullable * default value * repository * update default value handling * fix unit tests * WIP * toMikroORM * fix relations * cascades * fix * experimental dml hooks * rm migration * serial * nullable autoincrement * fix model * model changes * fix one to one DML * order test * fix addresses * fix unit tests * Re align dml entity name inference * update model table name config * update model table name config * revert * update return relation * WIP * hasOne * models * fix * model * initial commit * cart service * order module * utils unit test * index engine * changeset * merge * fix hasOne with fk * update * free text filter per entity * tests * prod category * property string many to many * fix big number * link modules migration set names * merge * shipping option rules * serializer * unit test * fix test mikro orm init * fix test mikro orm init * Maintain merge object properties * fix test mikro orm init * prevent unit test from connecting to db * wip * fix test * fix test * link test * schema * models * auto increment * hook * model hooks * order * wip * orm version * request return field * fix return configuration on order model * workflows * core flows * unit test * test * base repo * test * base repo * test fix * inventory move * locking inventory * test * free text fix * rm timeout mock * migrate fulfillment values * v6.4.3 * cleanup * link-modules update sql * revert test * remove fake timers --------- Co-authored-by: adrien2p <adrien.deperetti@gmail.com> Co-authored-by: Harminder Virk <virk.officials@gmail.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
178 files changed
+5731
-7120
No files matched your search
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/locking-postgres": minor
|
||||||
|
"@medusajs/workflow-engine-inmemory": minor
|
||||||
|
"@medusajs/workflow-engine-redis": minor
|
||||||
|
"@medusajs/stock-location": minor
|
||||||
|
"@medusajs/sales-channel": minor
|
||||||
|
"@medusajs/link-modules": minor
|
||||||
|
"@medusajs/notification": minor
|
||||||
|
"@medusajs/fulfillment": minor
|
||||||
|
"@medusajs/orchestration": minor
|
||||||
|
"@medusajs/workflows-sdk": minor
|
||||||
|
"@medusajs/test-utils": minor
|
||||||
|
"@medusajs/inventory": minor
|
||||||
|
"@medusajs/promotion": minor
|
||||||
|
"@medusajs/modules-sdk": minor
|
||||||
|
"@medusajs/currency": minor
|
||||||
|
"@medusajs/customer": minor
|
||||||
|
"@medusajs/core-flows": minor
|
||||||
|
"@medusajs/api-key": minor
|
||||||
|
"@medusajs/locking": minor
|
||||||
|
"@medusajs/payment": minor
|
||||||
|
"@medusajs/pricing": minor
|
||||||
|
"@medusajs/product": minor
|
||||||
|
"@medusajs/cli": minor
|
||||||
|
"@medusajs/framework": minor
|
||||||
|
"@medusajs/region": minor
|
||||||
|
"integration-tests-http": minor
|
||||||
|
"@medusajs/index": minor
|
||||||
|
"@medusajs/order": minor
|
||||||
|
"@medusajs/store": minor
|
||||||
|
"@medusajs/auth": minor
|
||||||
|
"@medusajs/cart": minor
|
||||||
|
"@medusajs/file": minor
|
||||||
|
"@medusajs/user": minor
|
||||||
|
"@medusajs/tax": minor
|
||||||
|
"@medusajs/types": minor
|
||||||
|
"@medusajs/utils": minor
|
||||||
|
"@medusajs/medusa": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: upgrade to mikro-orm 6
|
||||||
@@ -388,7 +388,7 @@ medusaIntegrationTestRunner({
|
|||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
attribute: "enabled_in_store",
|
attribute: "enabled_in_store",
|
||||||
value: '"true"',
|
value: "true",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1779,7 +1779,7 @@ medusaIntegrationTestRunner({
|
|||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
attribute: "enabled_in_store",
|
attribute: "enabled_in_store",
|
||||||
value: '"true"',
|
value: "true",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -2150,7 +2150,7 @@ medusaIntegrationTestRunner({
|
|||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
attribute: "enabled_in_store",
|
attribute: "enabled_in_store",
|
||||||
value: '"true"',
|
value: "true",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ medusaIntegrationTestRunner({
|
|||||||
await api
|
await api
|
||||||
.post("/admin/customer-groups", payload, adminHeaders)
|
.post("/admin/customer-groups", payload, adminHeaders)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err)
|
|
||||||
// BREAKING: Duplicate error is now 400
|
// BREAKING: Duplicate error is now 400
|
||||||
expect(err.response.status).toEqual(400)
|
expect(err.response.status).toEqual(400)
|
||||||
expect(err.response.data.type).toEqual("invalid_data")
|
expect(err.response.data.type).toEqual("invalid_data")
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
Modules,
|
Modules,
|
||||||
RuleOperator,
|
RuleOperator,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
import {
|
import {
|
||||||
adminHeaders,
|
adminHeaders,
|
||||||
createAdminUser,
|
createAdminUser,
|
||||||
} from "../../../helpers/create-admin-user"
|
} from "../../../helpers/create-admin-user"
|
||||||
import { setupTaxStructure } from "../../../modules/__tests__/fixtures/tax"
|
import { setupTaxStructure } from "../../../modules/__tests__/fixtures/tax"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(300000)
|
||||||
|
|
||||||
medusaIntegrationTestRunner({
|
medusaIntegrationTestRunner({
|
||||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ClaimType, Modules, RuleOperator } from "@medusajs/utils"
|
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
|
import { ClaimType, Modules, RuleOperator } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
adminHeaders,
|
adminHeaders,
|
||||||
createAdminUser,
|
createAdminUser,
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
import { setupTaxStructure } from "../../../../modules/__tests__/fixtures"
|
import { setupTaxStructure } from "../../../../modules/__tests__/fixtures"
|
||||||
import { createOrderSeeder } from "../../fixtures/order"
|
import { createOrderSeeder } from "../../fixtures/order"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(300000)
|
||||||
|
|
||||||
medusaIntegrationTestRunner({
|
medusaIntegrationTestRunner({
|
||||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||||
@@ -268,6 +268,7 @@ medusaIntegrationTestRunner({
|
|||||||
{
|
{
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
|
title: "new ITEM",
|
||||||
variant_id: order.items[0].variant_id,
|
variant_id: order.items[0].variant_id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
@@ -480,6 +481,7 @@ medusaIntegrationTestRunner({
|
|||||||
{
|
{
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
|
title: "Test item 2",
|
||||||
variant_id: order.items[0].variant_id,
|
variant_id: order.items[0].variant_id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
@@ -551,7 +553,7 @@ medusaIntegrationTestRunner({
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
inboundItem = orderResult.items[0]
|
inboundItem = orderResult.items[1]
|
||||||
|
|
||||||
await api.post(
|
await api.post(
|
||||||
`/admin/claims/${claimWithInboundAndOutbound.id}/inbound/items`,
|
`/admin/claims/${claimWithInboundAndOutbound.id}/inbound/items`,
|
||||||
|
|||||||
@@ -968,6 +968,7 @@ medusaIntegrationTestRunner({
|
|||||||
sales_channel_id: expect.stringContaining("sc_"),
|
sales_channel_id: expect.stringContaining("sc_"),
|
||||||
currency_code: "usd",
|
currency_code: "usd",
|
||||||
region_id: expect.stringContaining("reg_"),
|
region_id: expect.stringContaining("reg_"),
|
||||||
|
shipping_address: null,
|
||||||
item_total: 0,
|
item_total: 0,
|
||||||
total: 0,
|
total: 0,
|
||||||
email: null,
|
email: null,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getMigrationPlanner, initialize } from "@medusajs/link-modules"
|
import { getMigrationPlanner, initialize } from "@medusajs/link-modules"
|
||||||
import { MedusaModule } from "@medusajs/modules-sdk"
|
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||||
import { ModuleJoinerConfig } from "@medusajs/types"
|
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
|
import { ModuleJoinerConfig } from "@medusajs/types"
|
||||||
|
|
||||||
jest.setTimeout(5000000)
|
jest.setTimeout(5000000)
|
||||||
|
|
||||||
@@ -74,6 +74,7 @@ medusaIntegrationTestRunner({
|
|||||||
|
|
||||||
const planner = getMigrationPlanner(dbConfig, linkDefinition)
|
const planner = getMigrationPlanner(dbConfig, linkDefinition)
|
||||||
await planner.executePlan(await planner.createPlan())
|
await planner.executePlan(await planner.createPlan())
|
||||||
|
|
||||||
links = await initialize(dbConfig, linkDefinition)
|
links = await initialize(dbConfig, linkDefinition)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ medusaIntegrationTestRunner({
|
|||||||
summary: expect.objectContaining({
|
summary: expect.objectContaining({
|
||||||
// TODO: add summary fields
|
// TODO: add summary fields
|
||||||
}),
|
}),
|
||||||
items: [
|
items: expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
title: "Test variant",
|
title: "Test variant",
|
||||||
subtitle: "Test product",
|
subtitle: "Test product",
|
||||||
@@ -335,7 +335,7 @@ medusaIntegrationTestRunner({
|
|||||||
value: "1",
|
value: "1",
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
],
|
]),
|
||||||
shipping_address: expect.objectContaining({
|
shipping_address: expect.objectContaining({
|
||||||
last_name: "Test",
|
last_name: "Test",
|
||||||
address_1: "Test",
|
address_1: "Test",
|
||||||
|
|||||||
@@ -362,6 +362,7 @@ medusaIntegrationTestRunner({
|
|||||||
metadata: null,
|
metadata: null,
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
|
deleted_at: null,
|
||||||
},
|
},
|
||||||
billing_address: {
|
billing_address: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
@@ -379,6 +380,7 @@ medusaIntegrationTestRunner({
|
|||||||
metadata: null,
|
metadata: null,
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
|
deleted_at: null,
|
||||||
},
|
},
|
||||||
shipping_methods: [
|
shipping_methods: [
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
orderClaimRequestItemReturnWorkflow,
|
orderClaimRequestItemReturnWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
@@ -19,7 +20,6 @@ import {
|
|||||||
RuleOperator,
|
RuleOperator,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
|
|
||||||
jest.setTimeout(500000)
|
jest.setTimeout(500000)
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ async function prepareDataFixtures({ container }) {
|
|||||||
{
|
{
|
||||||
attribute: "is_return",
|
attribute: "is_return",
|
||||||
operator: RuleOperator.EQ,
|
operator: RuleOperator.EQ,
|
||||||
value: '"true"',
|
value: "true",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
orderExchangeAddNewItemWorkflow,
|
orderExchangeAddNewItemWorkflow,
|
||||||
orderExchangeRequestItemReturnWorkflow,
|
orderExchangeRequestItemReturnWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IRegionModuleService,
|
IRegionModuleService,
|
||||||
@@ -21,7 +22,6 @@ import {
|
|||||||
RuleOperator,
|
RuleOperator,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
|
|
||||||
jest.setTimeout(500000)
|
jest.setTimeout(500000)
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ async function prepareDataFixtures({ container }) {
|
|||||||
{
|
{
|
||||||
attribute: "is_return",
|
attribute: "is_return",
|
||||||
operator: RuleOperator.EQ,
|
operator: RuleOperator.EQ,
|
||||||
value: '"true"',
|
value: "true",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
beginReturnOrderWorkflow,
|
beginReturnOrderWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
@@ -17,7 +18,6 @@ import {
|
|||||||
RuleOperator,
|
RuleOperator,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
|
|
||||||
jest.setTimeout(500000)
|
jest.setTimeout(500000)
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ async function prepareDataFixtures({ container }) {
|
|||||||
{
|
{
|
||||||
attribute: "is_return",
|
attribute: "is_return",
|
||||||
operator: RuleOperator.EQ,
|
operator: RuleOperator.EQ,
|
||||||
value: '"true"',
|
value: "true",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import { RemoteLink } from "@medusajs/modules-sdk"
|
import { RemoteLink } from "@medusajs/modules-sdk"
|
||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
FulfillmentSetDTO,
|
FulfillmentSetDTO,
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
@@ -21,7 +22,6 @@ import {
|
|||||||
RuleOperator,
|
RuleOperator,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
|
|
||||||
jest.setTimeout(500000)
|
jest.setTimeout(500000)
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ async function prepareDataFixtures({ container }) {
|
|||||||
{
|
{
|
||||||
attribute: "is_return",
|
attribute: "is_return",
|
||||||
operator: RuleOperator.EQ,
|
operator: RuleOperator.EQ,
|
||||||
value: '"true"',
|
value: "true",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
createOrderFulfillmentWorkflow,
|
createOrderFulfillmentWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
@@ -20,7 +21,6 @@ import {
|
|||||||
Modules,
|
Modules,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
|
|
||||||
jest.setTimeout(500000)
|
jest.setTimeout(500000)
|
||||||
|
|
||||||
@@ -305,12 +305,15 @@ async function createOrderFixture({ container, product, location }) {
|
|||||||
|
|
||||||
const inventoryModule = container.resolve(Modules.INVENTORY)
|
const inventoryModule = container.resolve(Modules.INVENTORY)
|
||||||
|
|
||||||
|
const itemWithInventory = order.items!.find(
|
||||||
|
(o) => o.variant_sku === variantSkuWithInventory
|
||||||
|
)!
|
||||||
const reservation = await inventoryModule.createReservationItems([
|
const reservation = await inventoryModule.createReservationItems([
|
||||||
{
|
{
|
||||||
line_item_id: order.items![0].id,
|
line_item_id: itemWithInventory.id,
|
||||||
inventory_item_id: inventoryItem.id,
|
inventory_item_id: inventoryItem.id,
|
||||||
location_id: location.id,
|
location_id: location.id,
|
||||||
quantity: order.items![0].quantity,
|
quantity: itemWithInventory.quantity,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -440,7 +443,6 @@ medusaIntegrationTestRunner({
|
|||||||
id: order.id,
|
id: order.id,
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
"*",
|
|
||||||
"items.*",
|
"items.*",
|
||||||
"shipping_methods.*",
|
"shipping_methods.*",
|
||||||
"total",
|
"total",
|
||||||
@@ -458,14 +460,15 @@ medusaIntegrationTestRunner({
|
|||||||
)!
|
)!
|
||||||
|
|
||||||
expect(orderFulfillAfterCancelled.fulfillments).toHaveLength(1)
|
expect(orderFulfillAfterCancelled.fulfillments).toHaveLength(1)
|
||||||
expect(orderFulfillItemWithInventory.detail.fulfilled_quantity).toEqual(
|
expect(
|
||||||
0
|
orderFulfillItemWithInventory.detail.fulfilled_quantity.valueOf()
|
||||||
)
|
).toEqual(0)
|
||||||
|
|
||||||
const stockAvailabilityAfterCancelled =
|
const stockAvailabilityAfterCancelled =
|
||||||
await inventoryModule.retrieveStockedQuantity(inventoryItem.id, [
|
await inventoryModule.retrieveStockedQuantity(inventoryItem.id, [
|
||||||
location.id,
|
location.id,
|
||||||
])
|
])
|
||||||
|
|
||||||
expect(stockAvailabilityAfterCancelled.valueOf()).toEqual(2)
|
expect(stockAvailabilityAfterCancelled.valueOf()).toEqual(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
createOrderShipmentWorkflow,
|
createOrderShipmentWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
FulfillmentWorkflow,
|
FulfillmentWorkflow,
|
||||||
IOrderModuleService,
|
IOrderModuleService,
|
||||||
@@ -20,7 +21,6 @@ import {
|
|||||||
RuleOperator,
|
RuleOperator,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
|
|
||||||
jest.setTimeout(500000)
|
jest.setTimeout(500000)
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ async function prepareDataFixtures({ container }) {
|
|||||||
{
|
{
|
||||||
attribute: "is_return",
|
attribute: "is_return",
|
||||||
operator: RuleOperator.EQ,
|
operator: RuleOperator.EQ,
|
||||||
value: '"true"',
|
value: "true",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,9 @@ medusaIntegrationTestRunner({
|
|||||||
throwOnError: false,
|
throwOnError: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(error.error.message).toEqual(`Order id not found: ${order.id}`)
|
expect(error.error.message).toEqual(
|
||||||
|
`Return id not found: ${returnOrder.id}`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw an error if order change does not exist", async () => {
|
it("should throw an error if order change does not exist", async () => {
|
||||||
|
|||||||
+3
-3
@@ -2,6 +2,7 @@ import {
|
|||||||
batchShippingOptionRulesWorkflow,
|
batchShippingOptionRulesWorkflow,
|
||||||
createShippingOptionsWorkflow,
|
createShippingOptionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||||
import {
|
import {
|
||||||
BatchWorkflowInput,
|
BatchWorkflowInput,
|
||||||
CreateShippingOptionRuleDTO,
|
CreateShippingOptionRuleDTO,
|
||||||
@@ -19,7 +20,6 @@ import {
|
|||||||
RuleOperator,
|
RuleOperator,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ medusaIntegrationTestRunner({
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
attribute: "new_attribute",
|
attribute: "new_attribute",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
value: 100,
|
value: "100",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
expect(updatedRule).toEqual(
|
expect(updatedRule).toEqual(
|
||||||
@@ -345,7 +345,7 @@ medusaIntegrationTestRunner({
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
attribute: "total",
|
attribute: "total",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
value: 100,
|
value: "100",
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,10 +21,10 @@
|
|||||||
"scrypt-kdf": "^2.0.1",
|
"scrypt-kdf": "^2.0.1",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"@medusajs/framework": "^1.0.1",
|
"@medusajs/framework": "^1.0.1",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"ioredis": "^5.4.1",
|
"ioredis": "^5.4.1",
|
||||||
"pg": "^8.13.0",
|
"pg": "^8.13.0",
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
"author": "Sebastian Rindom",
|
"author": "Sebastian Rindom",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"@types/yargs": "^15.0.15",
|
"@types/yargs": "^15.0.15",
|
||||||
@@ -72,10 +72,10 @@
|
|||||||
"yargs": "^15.3.1"
|
"yargs": "^15.3.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"pg": "^8.13.0"
|
"pg": "^8.13.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,10 +27,10 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IInventoryService, InventoryTypes } from "@medusajs/framework/types"
|
import { InventoryTypes } from "@medusajs/framework/types"
|
||||||
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
||||||
|
|
||||||
import { MathBN, Modules } from "@medusajs/framework/utils"
|
import { MathBN, Modules } from "@medusajs/framework/utils"
|
||||||
@@ -29,20 +29,22 @@ export const adjustInventoryLevelsStep = createStep(
|
|||||||
input: AdjustInventoryLevelsStepInput,
|
input: AdjustInventoryLevelsStepInput,
|
||||||
{ container }
|
{ container }
|
||||||
) => {
|
) => {
|
||||||
const inventoryService: IInventoryService = container.resolve(
|
const inventoryService = container.resolve(Modules.INVENTORY)
|
||||||
Modules.INVENTORY
|
const locking = container.resolve(Modules.LOCKING)
|
||||||
)
|
const inventoryItemIds = input.map((item) => item.inventory_item_id)
|
||||||
|
|
||||||
const adjustedLevels: InventoryTypes.InventoryLevelDTO[] =
|
const adjustedLevels: InventoryTypes.InventoryLevelDTO[] =
|
||||||
await inventoryService.adjustInventory(
|
await locking.execute(inventoryItemIds, async () => {
|
||||||
input.map((item) => {
|
return await inventoryService.adjustInventory(
|
||||||
return {
|
input.map((item) => {
|
||||||
inventoryItemId: item.inventory_item_id,
|
return {
|
||||||
locationId: item.location_id,
|
inventoryItemId: item.inventory_item_id,
|
||||||
adjustment: item.adjustment,
|
locationId: item.location_id,
|
||||||
}
|
adjustment: item.adjustment,
|
||||||
})
|
}
|
||||||
)
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
return new StepResponse(
|
return new StepResponse(
|
||||||
adjustedLevels,
|
adjustedLevels,
|
||||||
@@ -55,11 +57,15 @@ export const adjustInventoryLevelsStep = createStep(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
async (adjustedLevels, { container }) => {
|
async (adjustedLevels, { container }) => {
|
||||||
if (!adjustedLevels) {
|
if (!adjustedLevels?.length) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const inventoryService = container.resolve(Modules.INVENTORY)
|
const inventoryService = container.resolve(Modules.INVENTORY)
|
||||||
|
const locking = container.resolve(Modules.LOCKING)
|
||||||
|
const inventoryItemIds = adjustedLevels.map(
|
||||||
|
(item) => item.inventory_item_id
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo
|
* @todo
|
||||||
@@ -67,14 +73,16 @@ export const adjustInventoryLevelsStep = createStep(
|
|||||||
* "inventoryItemId" and "locationId" as snake case, whereas
|
* "inventoryItemId" and "locationId" as snake case, whereas
|
||||||
* the expected object needed these properties as camelCase
|
* the expected object needed these properties as camelCase
|
||||||
*/
|
*/
|
||||||
await inventoryService.adjustInventory(
|
await locking.execute(inventoryItemIds, async () => {
|
||||||
adjustedLevels.map((level) => {
|
await inventoryService.adjustInventory(
|
||||||
return {
|
adjustedLevels.map((level) => {
|
||||||
inventoryItemId: level.inventory_item_id,
|
return {
|
||||||
locationId: level.location_id,
|
inventoryItemId: level.inventory_item_id,
|
||||||
adjustment: level.adjustment,
|
locationId: level.location_id,
|
||||||
}
|
adjustment: level.adjustment,
|
||||||
})
|
}
|
||||||
)
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -20,10 +20,10 @@ export const updateOrderClaimsStep = createStep(
|
|||||||
const { selects, relations } = getSelectsAndRelationsFromObjectArray(data, {
|
const { selects, relations } = getSelectsAndRelationsFromObjectArray(data, {
|
||||||
objectFields: ["metadata"],
|
objectFields: ["metadata"],
|
||||||
})
|
})
|
||||||
const dataBeforeUpdate = await service.listOrderClaims(
|
const dataBeforeUpdate = (await service.listOrderClaims(
|
||||||
{ id: data.map((d) => d.id) },
|
{ id: data.map((d) => d.id) },
|
||||||
{ relations, select: selects }
|
{ relations, select: selects }
|
||||||
)
|
)) as UpdateOrderClaimDTO[]
|
||||||
|
|
||||||
const updated = await service.updateOrderClaims(
|
const updated = await service.updateOrderClaims(
|
||||||
data.map((dt) => {
|
data.map((dt) => {
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ export const updateOrderExchangesStep = createStep(
|
|||||||
const { selects, relations } = getSelectsAndRelationsFromObjectArray(data, {
|
const { selects, relations } = getSelectsAndRelationsFromObjectArray(data, {
|
||||||
objectFields: ["metadata"],
|
objectFields: ["metadata"],
|
||||||
})
|
})
|
||||||
const dataBeforeUpdate = await service.listOrderExchanges(
|
const dataBeforeUpdate = (await service.listOrderExchanges(
|
||||||
{ id: data.map((d) => d.id) },
|
{ id: data.map((d) => d.id) },
|
||||||
{ relations, select: selects }
|
{ relations, select: selects }
|
||||||
)
|
)) as UpdateOrderExchangeDTO[]
|
||||||
|
|
||||||
const updated = await service.updateOrderExchanges(
|
const updated = await service.updateOrderExchanges(
|
||||||
data.map((dt) => {
|
data.map((dt) => {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export * from "./exchange/create-exchange-items-from-actions"
|
|||||||
export * from "./exchange/delete-exchanges"
|
export * from "./exchange/delete-exchanges"
|
||||||
export * from "./preview-order-change"
|
export * from "./preview-order-change"
|
||||||
export * from "./register-fulfillment"
|
export * from "./register-fulfillment"
|
||||||
|
export * from "./register-order-changes"
|
||||||
export * from "./register-shipment"
|
export * from "./register-shipment"
|
||||||
export * from "./return/cancel-return"
|
export * from "./return/cancel-return"
|
||||||
export * from "./return/create-complete-return"
|
export * from "./return/create-complete-return"
|
||||||
@@ -32,7 +33,5 @@ export * from "./return/update-returns"
|
|||||||
export * from "./set-tax-lines-for-items"
|
export * from "./set-tax-lines-for-items"
|
||||||
export * from "./update-order-change-actions"
|
export * from "./update-order-change-actions"
|
||||||
export * from "./update-order-changes"
|
export * from "./update-order-changes"
|
||||||
export * from "./update-order-exchanges"
|
|
||||||
export * from "./update-shipping-methods"
|
|
||||||
export * from "./update-orders"
|
export * from "./update-orders"
|
||||||
export * from "./register-order-changes"
|
export * from "./update-shipping-methods"
|
||||||
@@ -13,7 +13,7 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
|||||||
*/
|
*/
|
||||||
export type UpdateOrderChangesStepInput = UpdateOrderChangeDTO[]
|
export type UpdateOrderChangesStepInput = UpdateOrderChangeDTO[]
|
||||||
|
|
||||||
export const updateOrderChangesStepId = "update-order-shopping-methods"
|
export const updateOrderChangesStepId = "update-order-changes"
|
||||||
/**
|
/**
|
||||||
* This step updates order change.
|
* This step updates order change.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
import {
|
|
||||||
IOrderModuleService,
|
|
||||||
UpdateOrderExchangeDTO,
|
|
||||||
} from "@medusajs/framework/types"
|
|
||||||
import {
|
|
||||||
Modules,
|
|
||||||
getSelectsAndRelationsFromObjectArray,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The order exchanges to update.
|
|
||||||
*/
|
|
||||||
export type UpdateOrderExchangesStepInput = UpdateOrderExchangeDTO[]
|
|
||||||
|
|
||||||
export const updateOrderExchangesStepId = "update-order-exchange"
|
|
||||||
/**
|
|
||||||
* This step update order changes.
|
|
||||||
*/
|
|
||||||
export const updateOrderExchangesStep = createStep(
|
|
||||||
updateOrderExchangesStepId,
|
|
||||||
async (data: UpdateOrderExchangesStepInput, { container }) => {
|
|
||||||
const service = container.resolve<IOrderModuleService>(Modules.ORDER)
|
|
||||||
|
|
||||||
const { selects, relations } = getSelectsAndRelationsFromObjectArray(data, {
|
|
||||||
objectFields: ["metadata"],
|
|
||||||
})
|
|
||||||
const dataBeforeUpdate = await service.listOrderExchanges(
|
|
||||||
{ id: data.map((d) => d.id) },
|
|
||||||
{ relations, select: selects }
|
|
||||||
)
|
|
||||||
|
|
||||||
const updated = await service.updateOrderExchanges(
|
|
||||||
data.map((dt) => {
|
|
||||||
const { id, ...rest } = dt
|
|
||||||
return {
|
|
||||||
selector: { id },
|
|
||||||
data: rest,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
return new StepResponse(updated, dataBeforeUpdate)
|
|
||||||
},
|
|
||||||
async (dataBeforeUpdate, { container }) => {
|
|
||||||
if (!dataBeforeUpdate?.length) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const service = container.resolve<IOrderModuleService>(Modules.ORDER)
|
|
||||||
|
|
||||||
await service.updateOrderExchanges(
|
|
||||||
dataBeforeUpdate.map((dt) => {
|
|
||||||
const { id, ...rest } = dt
|
|
||||||
return {
|
|
||||||
selector: { id },
|
|
||||||
data: rest,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@@ -143,13 +143,15 @@ function prepareInventoryUpdate({
|
|||||||
}[] = []
|
}[] = []
|
||||||
for (const item of fulfillment.items) {
|
for (const item of fulfillment.items) {
|
||||||
// if this is `null` this means that item is from variant that has `manage_inventory` false
|
// if this is `null` this means that item is from variant that has `manage_inventory` false
|
||||||
if (item.inventory_item_id) {
|
if (!item.inventory_item_id) {
|
||||||
inventoryAdjustment.push({
|
continue
|
||||||
inventory_item_id: item.inventory_item_id as string,
|
|
||||||
location_id: fulfillment.location_id,
|
|
||||||
adjustment: item.quantity,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inventoryAdjustment.push({
|
||||||
|
inventory_item_id: item.inventory_item_id as string,
|
||||||
|
location_id: fulfillment.location_id,
|
||||||
|
adjustment: item.quantity,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -223,16 +223,10 @@ export const orderClaimRequestItemReturnWorkflow = createWorkflow(
|
|||||||
when({ orderClaim }, ({ orderClaim }) => {
|
when({ orderClaim }, ({ orderClaim }) => {
|
||||||
return !orderClaim.return_id
|
return !orderClaim.return_id
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const createdReturnId = transform(
|
|
||||||
{ createdReturn },
|
|
||||||
({ createdReturn }) => {
|
|
||||||
return createdReturn?.[0]!.id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
updateOrderClaimsStep([
|
updateOrderClaimsStep([
|
||||||
{
|
{
|
||||||
id: orderClaim.id,
|
id: orderClaim.id,
|
||||||
return_id: createdReturnId,
|
return: createdReturn?.[0]!.id,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -327,6 +327,8 @@ export const confirmClaimRequestWorkflow = createWorkflow(
|
|||||||
fields: [
|
fields: [
|
||||||
"id",
|
"id",
|
||||||
"status",
|
"status",
|
||||||
|
"claim_id",
|
||||||
|
"return_id",
|
||||||
"actions.id",
|
"actions.id",
|
||||||
"actions.claim_id",
|
"actions.claim_id",
|
||||||
"actions.return_id",
|
"actions.return_id",
|
||||||
|
|||||||
+1
-7
@@ -225,16 +225,10 @@ export const orderExchangeRequestItemReturnWorkflow = createWorkflow(
|
|||||||
when({ orderExchange }, ({ orderExchange }) => {
|
when({ orderExchange }, ({ orderExchange }) => {
|
||||||
return !orderExchange.return_id
|
return !orderExchange.return_id
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const createdReturnId = transform(
|
|
||||||
{ createdReturn },
|
|
||||||
({ createdReturn }) => {
|
|
||||||
return createdReturn?.[0]!.id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
updateOrderExchangesStep([
|
updateOrderExchangesStep([
|
||||||
{
|
{
|
||||||
id: orderExchange.id,
|
id: orderExchange.id,
|
||||||
return_id: createdReturnId,
|
return: createdReturn?.[0]!.id,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -186,7 +186,17 @@ export const removeItemReturnActionWorkflow = createWorkflow(
|
|||||||
|
|
||||||
const updatedOrderChange: OrderChangeDTO = useRemoteQueryStep({
|
const updatedOrderChange: OrderChangeDTO = useRemoteQueryStep({
|
||||||
entry_point: "order_change",
|
entry_point: "order_change",
|
||||||
fields: ["actions.action", "actions.return_id", "actions.id"],
|
fields: [
|
||||||
|
"actions.id",
|
||||||
|
"actions.action",
|
||||||
|
"actions.order_id",
|
||||||
|
"actions.return_id",
|
||||||
|
"actions.claim_id",
|
||||||
|
"actions.exchange_id",
|
||||||
|
"actions.reference",
|
||||||
|
"actions.reference_id",
|
||||||
|
"actions.order_change_id",
|
||||||
|
],
|
||||||
variables: {
|
variables: {
|
||||||
filters: {
|
filters: {
|
||||||
order_id: orderReturn.order_id,
|
order_id: orderReturn.order_id,
|
||||||
|
|||||||
@@ -55,10 +55,10 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/cli": "^2.3.1",
|
"@medusajs/cli": "^2.3.1",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
@@ -97,11 +97,11 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/cli": "^2.0.0",
|
"@medusajs/cli": "^2.0.0",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"ioredis": "^5.4.1",
|
"ioredis": "^5.4.1",
|
||||||
"pg": "^8.13.0",
|
"pg": "^8.13.0",
|
||||||
|
|||||||
@@ -11,17 +11,15 @@
|
|||||||
* small, we should be okay with managing this wrapper.
|
* small, we should be okay with managing this wrapper.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { isAbsolute, join } from "path"
|
|
||||||
import { ConfigurationLoader } from "@mikro-orm/core"
|
|
||||||
import { CLIConfigurator, CLIHelper } from "@mikro-orm/cli"
|
import { CLIConfigurator, CLIHelper } from "@mikro-orm/cli"
|
||||||
|
import { ConfigurationLoader } from "@mikro-orm/core"
|
||||||
|
import { isAbsolute, join } from "path"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monkey patching the TSNode registration of Mikro ORM to not use
|
* Monkey patching the TSNode registration of Mikro ORM to not use
|
||||||
* hardcoded module system with TypeScript.
|
* hardcoded module system with TypeScript.
|
||||||
*/
|
*/
|
||||||
ConfigurationLoader.registerTsNode = async function (
|
ConfigurationLoader.registerTsNode = function (configPath = "tsconfig.json") {
|
||||||
configPath = "tsconfig.json"
|
|
||||||
) {
|
|
||||||
const tsConfigPath = isAbsolute(configPath)
|
const tsConfigPath = isAbsolute(configPath)
|
||||||
? configPath
|
? configPath
|
||||||
: join(process.cwd(), configPath)
|
: join(process.cwd(), configPath)
|
||||||
|
|||||||
@@ -31,10 +31,10 @@
|
|||||||
"watch": "tsc --build --watch"
|
"watch": "tsc --build --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
@@ -50,10 +50,10 @@
|
|||||||
"@medusajs/utils": "^2.3.1"
|
"@medusajs/utils": "^2.3.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.0",
|
||||||
"pg": "^8.13.0"
|
"pg": "^8.13.0"
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
@@ -43,10 +43,10 @@
|
|||||||
"@medusajs/utils": "^2.3.1"
|
"@medusajs/utils": "^2.3.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.0",
|
||||||
"pg": "^8.13.0"
|
"pg": "^8.13.0"
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ export type DMLSchema = Record<
|
|||||||
PropertyType<any> | RelationshipType<any>
|
PropertyType<any> | RelationshipType<any>
|
||||||
>
|
>
|
||||||
|
|
||||||
export type IDmlEntityConfig = string | { name?: string; tableName: string }
|
export type IDmlEntityConfig =
|
||||||
|
| string
|
||||||
|
| {
|
||||||
|
name?: string
|
||||||
|
tableName: string
|
||||||
|
}
|
||||||
|
|
||||||
export type InferDmlEntityNameFromConfig<TConfig extends IDmlEntityConfig> =
|
export type InferDmlEntityNameFromConfig<TConfig extends IDmlEntityConfig> =
|
||||||
TConfig extends string
|
TConfig extends string
|
||||||
|
|||||||
@@ -2727,6 +2727,21 @@ export interface FilterableOrderChangeProps
|
|||||||
*/
|
*/
|
||||||
order_id?: string | string[] | OperatorMap<string>
|
order_id?: string | string[] | OperatorMap<string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the changes by their associated return's ID.
|
||||||
|
*/
|
||||||
|
return_id?: string | string[] | OperatorMap<string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the changes by their associated claim's ID.
|
||||||
|
*/
|
||||||
|
claim_id?: string | string[] | OperatorMap<string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the changes by their associated exchange's ID.
|
||||||
|
*/
|
||||||
|
exchange_id?: string | string[] | OperatorMap<string>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the order changes by their status.
|
* Filter the order changes by their status.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1738,7 +1738,7 @@ export interface UpdateOrderClaimDTO {
|
|||||||
* The associated return's ID, if the
|
* The associated return's ID, if the
|
||||||
* claim's {@link type} is `replace`.
|
* claim's {@link type} is `replace`.
|
||||||
*/
|
*/
|
||||||
return_id?: string
|
return?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the claim.
|
* The type of the claim.
|
||||||
@@ -1778,7 +1778,7 @@ export interface UpdateOrderExchangeDTO {
|
|||||||
/**
|
/**
|
||||||
* The associated return's ID.
|
* The associated return's ID.
|
||||||
*/
|
*/
|
||||||
return_id?: string
|
return?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether backorders are allowed on the exchange's items.
|
* Whether backorders are allowed on the exchange's items.
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
@@ -59,10 +59,10 @@
|
|||||||
"ulid": "^2.3.0"
|
"ulid": "^2.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.0",
|
||||||
"pg": "^8.13.0"
|
"pg": "^8.13.0"
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class ProductOptionValue {
|
|||||||
fieldName: "option_id",
|
fieldName: "option_id",
|
||||||
mapToPk: true,
|
mapToPk: true,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
onDelete: "cascade",
|
deleteRule: "cascade",
|
||||||
})
|
})
|
||||||
option_id: string | null
|
option_id: string | null
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ class ProductVariant {
|
|||||||
@ManyToOne(() => Product, {
|
@ManyToOne(() => Product, {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
onDelete: "cascade",
|
deleteRule: "cascade",
|
||||||
fieldName: "product_id",
|
fieldName: "product_id",
|
||||||
mapToPk: true,
|
mapToPk: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Entity, MikroORM, OnInit, Property } from "@mikro-orm/core"
|
import { Entity, MikroORM, OnInit, Property } from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
import { BaseEntity } from "../base-entity"
|
import { BaseEntity } from "../base-entity"
|
||||||
|
|
||||||
describe("BaseEntity", () => {
|
describe("BaseEntity", () => {
|
||||||
@@ -10,11 +11,15 @@ describe("BaseEntity", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const orm = await MikroORM.init({
|
const orm = await MikroORM.init(
|
||||||
entities: [Entity1],
|
defineConfig({
|
||||||
dbName: "test",
|
entities: [Entity1],
|
||||||
type: "postgresql",
|
dbName: "test",
|
||||||
})
|
user: "postgres",
|
||||||
|
password: "",
|
||||||
|
connect: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const manager = orm.em.fork()
|
const manager = orm.em.fork()
|
||||||
const entity1 = manager.create(Entity1, {})
|
const entity1 = manager.create(Entity1, {})
|
||||||
@@ -28,11 +33,15 @@ describe("BaseEntity", () => {
|
|||||||
@Entity()
|
@Entity()
|
||||||
class Entity1 extends BaseEntity {}
|
class Entity1 extends BaseEntity {}
|
||||||
|
|
||||||
const orm = await MikroORM.init({
|
const orm = await MikroORM.init(
|
||||||
entities: [Entity1],
|
defineConfig({
|
||||||
dbName: "test",
|
entities: [Entity1],
|
||||||
type: "postgresql",
|
dbName: "test",
|
||||||
})
|
user: "postgres",
|
||||||
|
password: "",
|
||||||
|
connect: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const manager = orm.em.fork()
|
const manager = orm.em.fork()
|
||||||
const entity1 = manager.create(Entity1, {})
|
const entity1 = manager.create(Entity1, {})
|
||||||
@@ -52,11 +61,15 @@ describe("BaseEntity", () => {
|
|||||||
@Entity()
|
@Entity()
|
||||||
class ProductOptionValue extends BaseEntity {}
|
class ProductOptionValue extends BaseEntity {}
|
||||||
|
|
||||||
const orm = await MikroORM.init({
|
const orm = await MikroORM.init(
|
||||||
entities: [ProductModel, ProductCategoryEntity, ProductOptionValue],
|
defineConfig({
|
||||||
dbName: "test",
|
entities: [ProductModel, ProductCategoryEntity, ProductOptionValue],
|
||||||
type: "postgresql",
|
dbName: "test",
|
||||||
})
|
user: "postgres",
|
||||||
|
password: "",
|
||||||
|
connect: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const manager = orm.em.fork()
|
const manager = orm.em.fork()
|
||||||
|
|
||||||
@@ -105,11 +118,15 @@ describe("BaseEntity", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const orm = await MikroORM.init({
|
const orm = await MikroORM.init(
|
||||||
entities: [ProductModel, ProductCategoryEntity, ProductOptionValue],
|
defineConfig({
|
||||||
dbName: "test",
|
entities: [ProductModel, ProductCategoryEntity, ProductOptionValue],
|
||||||
type: "postgresql",
|
dbName: "test",
|
||||||
})
|
user: "postgres",
|
||||||
|
password: "",
|
||||||
|
connect: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const manager = orm.em.fork()
|
const manager = orm.em.fork()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BigNumberRawValue } from "@medusajs/types"
|
import { BigNumberRawValue } from "@medusajs/types"
|
||||||
import { Entity, MikroORM, PrimaryKey } from "@mikro-orm/core"
|
import { Entity, MikroORM, PrimaryKey } from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
import { BigNumber } from "../../../totals/big-number"
|
import { BigNumber } from "../../../totals/big-number"
|
||||||
import { MikroOrmBigNumberProperty } from "../big-number-field"
|
import { MikroOrmBigNumberProperty } from "../big-number-field"
|
||||||
|
|
||||||
@@ -23,11 +24,15 @@ describe("@MikroOrmBigNumberProperty", () => {
|
|||||||
let orm!: MikroORM
|
let orm!: MikroORM
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [TestAmount],
|
defineConfig({
|
||||||
dbName: "test",
|
entities: [TestAmount],
|
||||||
type: "postgresql",
|
dbName: "test",
|
||||||
})
|
user: "postgres",
|
||||||
|
password: "",
|
||||||
|
connect: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@@ -51,9 +56,7 @@ describe("@MikroOrmBigNumberProperty", () => {
|
|||||||
try {
|
try {
|
||||||
;(testAmount as any).amount = null
|
;(testAmount as any).amount = null
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toEqual(
|
expect(e.message).toEqual("Cannot set value null for amount.")
|
||||||
"Invalid BigNumber value: null. Should be one of: string, number, BigNumber (bignumber.js), BigNumberRawValue"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testAmount.nullable_amount = null
|
testAmount.nullable_amount = null
|
||||||
|
|||||||
+14
-9
@@ -1,4 +1,5 @@
|
|||||||
import { MikroORM } from "@mikro-orm/core"
|
import { MikroORM } from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
import { SearchableEntity1, SearchableEntity2 } from "../__fixtures__/utils"
|
import { SearchableEntity1, SearchableEntity2 } from "../__fixtures__/utils"
|
||||||
import { mikroOrmFreeTextSearchFilterOptionsFactory } from "../mikro-orm-free-text-search-filter"
|
import { mikroOrmFreeTextSearchFilterOptionsFactory } from "../mikro-orm-free-text-search-filter"
|
||||||
|
|
||||||
@@ -6,21 +7,23 @@ describe("mikroOrmFreeTextSearchFilterOptionsFactory", () => {
|
|||||||
let orm
|
let orm
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [SearchableEntity1, SearchableEntity2],
|
defineConfig({
|
||||||
dbName: "test",
|
entities: [SearchableEntity1, SearchableEntity2],
|
||||||
type: "postgresql",
|
user: "postgres",
|
||||||
})
|
password: "",
|
||||||
|
dbName: "test",
|
||||||
|
connect: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should return a filter function that filters entities based on the free text search value", async () => {
|
it("should return a filter function that filters entities based on the free text search value", async () => {
|
||||||
const entityManager = orm.em.fork()
|
const entityManager = orm.em.fork()
|
||||||
const freeTextSearchValue = "search"
|
const freeTextSearchValue = "search"
|
||||||
|
|
||||||
const models = [SearchableEntity1, SearchableEntity2]
|
|
||||||
|
|
||||||
let filterConstraints = mikroOrmFreeTextSearchFilterOptionsFactory(
|
let filterConstraints = mikroOrmFreeTextSearchFilterOptionsFactory(
|
||||||
models
|
SearchableEntity1.name
|
||||||
).cond(
|
).cond(
|
||||||
{
|
{
|
||||||
value: freeTextSearchValue,
|
value: freeTextSearchValue,
|
||||||
@@ -51,7 +54,9 @@ describe("mikroOrmFreeTextSearchFilterOptionsFactory", () => {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
filterConstraints = mikroOrmFreeTextSearchFilterOptionsFactory(models).cond(
|
filterConstraints = mikroOrmFreeTextSearchFilterOptionsFactory(
|
||||||
|
SearchableEntity2.name
|
||||||
|
).cond(
|
||||||
{
|
{
|
||||||
value: freeTextSearchValue,
|
value: freeTextSearchValue,
|
||||||
fromEntity: SearchableEntity2.name,
|
fromEntity: SearchableEntity2.name,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { MikroORM } from "@mikro-orm/core"
|
import { MikroORM } from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
import {
|
import {
|
||||||
Entity1WithUnDecoratedProp,
|
Entity1WithUnDecoratedProp,
|
||||||
Entity2WithUnDecoratedProp,
|
Entity2WithUnDecoratedProp,
|
||||||
@@ -11,18 +12,22 @@ import { mikroOrmSerializer } from "../mikro-orm-serializer"
|
|||||||
|
|
||||||
describe("mikroOrmSerializer", () => {
|
describe("mikroOrmSerializer", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await MikroORM.init({
|
await MikroORM.init(
|
||||||
entities: [
|
defineConfig({
|
||||||
Entity1WithUnDecoratedProp,
|
entities: [
|
||||||
Entity2WithUnDecoratedProp,
|
Entity1WithUnDecoratedProp,
|
||||||
Product,
|
Entity2WithUnDecoratedProp,
|
||||||
ProductOption,
|
Product,
|
||||||
ProductOptionValue,
|
ProductOption,
|
||||||
ProductVariant,
|
ProductOptionValue,
|
||||||
],
|
ProductVariant,
|
||||||
dbName: "test",
|
],
|
||||||
type: "postgresql",
|
user: "postgres",
|
||||||
})
|
password: "",
|
||||||
|
dbName: "test",
|
||||||
|
connect: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should serialize an entity", async () => {
|
it("should serialize an entity", async () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CustomTsMigrationGenerator } from "../mikro-orm-create-connection"
|
import { CustomTsMigrationGenerator } from "../mikro-orm-create-connection"
|
||||||
|
|
||||||
function unwrapSql(sql: string) {
|
function unwrapSql(sql: string) {
|
||||||
return sql.match(/this.addSql\('(.*?)'\)/)?.[1]
|
return sql.toString().match(/this.addSql\(`(.*?)`\)/)?.[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("CustomTsMigrationGenerator", () => {
|
describe("CustomTsMigrationGenerator", () => {
|
||||||
|
|||||||
@@ -26,20 +26,24 @@ export function MikroOrmBigNumberProperty(
|
|||||||
set(value: BigNumberInput) {
|
set(value: BigNumberInput) {
|
||||||
if (options?.nullable && !isPresent(value)) {
|
if (options?.nullable && !isPresent(value)) {
|
||||||
this.__helper.__data[columnName] = null
|
this.__helper.__data[columnName] = null
|
||||||
this.__helper.__data[rawColumnName]
|
this.__helper.__data[rawColumnName] = null
|
||||||
this[rawColumnName] = null
|
this[rawColumnName] = null
|
||||||
} else {
|
} else {
|
||||||
let bigNumber: BigNumber
|
let bigNumber: BigNumber
|
||||||
|
|
||||||
if (value instanceof BigNumber) {
|
try {
|
||||||
bigNumber = value
|
if (value instanceof BigNumber) {
|
||||||
} else if (this[rawColumnName]) {
|
bigNumber = value
|
||||||
const precision = this[rawColumnName].precision
|
} else if (this[rawColumnName]) {
|
||||||
bigNumber = new BigNumber(value, {
|
const precision = this[rawColumnName].precision
|
||||||
precision,
|
bigNumber = new BigNumber(value, {
|
||||||
})
|
precision,
|
||||||
} else {
|
})
|
||||||
bigNumber = new BigNumber(value)
|
} else {
|
||||||
|
bigNumber = new BigNumber(value)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(`Cannot set value ${value} for ${columnName}.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const raw = bigNumber.raw!
|
const raw = bigNumber.raw!
|
||||||
@@ -80,6 +84,7 @@ export function MikroOrmBigNumberProperty(
|
|||||||
type: "any",
|
type: "any",
|
||||||
columnType: "numeric",
|
columnType: "numeric",
|
||||||
trackChanges: false,
|
trackChanges: false,
|
||||||
|
runtimeType: "any",
|
||||||
...options,
|
...options,
|
||||||
})(target, columnName)
|
})(target, columnName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
||||||
const DB_USERNAME = process.env.DB_USERNAME ?? ""
|
const DB_USERNAME = process.env.DB_USERNAME ?? "postgres"
|
||||||
const DB_PASSWORD = process.env.DB_PASSWORD
|
const DB_PASSWORD = process.env.DB_PASSWORD
|
||||||
|
|
||||||
export const pgGodCredentials = {
|
export const pgGodCredentials = {
|
||||||
|
|||||||
+11
-9
@@ -1,3 +1,4 @@
|
|||||||
|
import { BigNumberRawValue } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Collection,
|
Collection,
|
||||||
@@ -13,11 +14,11 @@ import {
|
|||||||
Unique,
|
Unique,
|
||||||
wrap,
|
wrap,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { mikroOrmBaseRepositoryFactory } from "../../mikro-orm-repository"
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
|
import BigNumber from "bignumber.js"
|
||||||
import { dropDatabase } from "pg-god"
|
import { dropDatabase } from "pg-god"
|
||||||
import { MikroOrmBigNumberProperty } from "../../big-number-field"
|
import { MikroOrmBigNumberProperty } from "../../big-number-field"
|
||||||
import BigNumber from "bignumber.js"
|
import { mikroOrmBaseRepositoryFactory } from "../../mikro-orm-repository"
|
||||||
import { BigNumberRawValue } from "@medusajs/types"
|
|
||||||
import { getDatabaseURL, pgGodCredentials } from "../__fixtures__/database"
|
import { getDatabaseURL, pgGodCredentials } from "../__fixtures__/database"
|
||||||
|
|
||||||
const dbName = "mikroorm-integration-1"
|
const dbName = "mikroorm-integration-1"
|
||||||
@@ -78,7 +79,7 @@ class Entity2 {
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
mapToPk: true,
|
mapToPk: true,
|
||||||
fieldName: "entity1_id",
|
fieldName: "entity1_id",
|
||||||
onDelete: "set null",
|
deleteRule: "set null",
|
||||||
})
|
})
|
||||||
entity1_id: string
|
entity1_id: string
|
||||||
|
|
||||||
@@ -143,11 +144,12 @@ describe("mikroOrmRepository", () => {
|
|||||||
pgGodCredentials
|
pgGodCredentials
|
||||||
)
|
)
|
||||||
|
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [Entity1, Entity2],
|
defineConfig({
|
||||||
clientUrl: getDatabaseURL(dbName),
|
entities: [Entity1, Entity2],
|
||||||
type: "postgresql",
|
clientUrl: getDatabaseURL(dbName),
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const generator = orm.getSchemaGenerator()
|
const generator = orm.getSchemaGenerator()
|
||||||
await generator.ensureDatabase()
|
await generator.ensureDatabase()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { mikroOrmUpdateDeletedAtRecursively } from "../../utils"
|
|
||||||
import { MikroORM } from "@mikro-orm/core"
|
import { MikroORM } from "@mikro-orm/core"
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
import { defineConfig, SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
|
import { dropDatabase } from "pg-god"
|
||||||
|
import { mikroOrmUpdateDeletedAtRecursively } from "../../utils"
|
||||||
|
import { getDatabaseURL, pgGodCredentials } from "../__fixtures__/database"
|
||||||
import {
|
import {
|
||||||
DeepRecursiveEntity1,
|
DeepRecursiveEntity1,
|
||||||
DeepRecursiveEntity2,
|
DeepRecursiveEntity2,
|
||||||
@@ -12,8 +14,6 @@ import {
|
|||||||
RecursiveEntity1,
|
RecursiveEntity1,
|
||||||
RecursiveEntity2,
|
RecursiveEntity2,
|
||||||
} from "../__fixtures__/utils"
|
} from "../__fixtures__/utils"
|
||||||
import { dropDatabase } from "pg-god"
|
|
||||||
import { getDatabaseURL, pgGodCredentials } from "../__fixtures__/database"
|
|
||||||
|
|
||||||
const dbName = "mikroorm-utils-integration-1"
|
const dbName = "mikroorm-utils-integration-1"
|
||||||
|
|
||||||
@@ -38,21 +38,22 @@ describe("mikroOrmUpdateDeletedAtRecursively", () => {
|
|||||||
pgGodCredentials
|
pgGodCredentials
|
||||||
)
|
)
|
||||||
|
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [
|
defineConfig({
|
||||||
Entity1,
|
entities: [
|
||||||
Entity2,
|
Entity1,
|
||||||
RecursiveEntity1,
|
Entity2,
|
||||||
RecursiveEntity2,
|
RecursiveEntity1,
|
||||||
DeepRecursiveEntity1,
|
RecursiveEntity2,
|
||||||
DeepRecursiveEntity2,
|
DeepRecursiveEntity1,
|
||||||
DeepRecursiveEntity3,
|
DeepRecursiveEntity2,
|
||||||
DeepRecursiveEntity4,
|
DeepRecursiveEntity3,
|
||||||
InternalCircularDependencyEntity1,
|
DeepRecursiveEntity4,
|
||||||
],
|
InternalCircularDependencyEntity1,
|
||||||
clientUrl: getDatabaseURL(dbName),
|
],
|
||||||
type: "postgresql",
|
clientUrl: getDatabaseURL(dbName),
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const generator = orm.getSchemaGenerator()
|
const generator = orm.getSchemaGenerator()
|
||||||
await generator.ensureDatabase()
|
await generator.ensureDatabase()
|
||||||
|
|||||||
@@ -45,34 +45,38 @@ export async function mikroOrmCreateConnection(
|
|||||||
schema = database.connection.context?.client?.config?.searchPath
|
schema = database.connection.context?.client?.config?.searchPath
|
||||||
}
|
}
|
||||||
|
|
||||||
const { MikroORM } = await import("@mikro-orm/postgresql")
|
const { MikroORM, defineConfig } = await import("@mikro-orm/postgresql")
|
||||||
return await MikroORM.init({
|
return await MikroORM.init(
|
||||||
discovery: { disableDynamicFileAccess: true, warnWhenNoEntities: false },
|
defineConfig({
|
||||||
entities,
|
discovery: { disableDynamicFileAccess: true, warnWhenNoEntities: false },
|
||||||
debug: database.debug ?? process.env.NODE_ENV?.startsWith("dev") ?? false,
|
entities,
|
||||||
baseDir: process.cwd(),
|
debug: database.debug ?? process.env.NODE_ENV?.startsWith("dev") ?? false,
|
||||||
clientUrl,
|
baseDir: process.cwd(),
|
||||||
schema,
|
clientUrl,
|
||||||
driverOptions,
|
schema,
|
||||||
tsNode: process.env.APP_ENV === "development",
|
driverOptions,
|
||||||
type: "postgresql",
|
tsNode: process.env.APP_ENV === "development",
|
||||||
filters: database.filters ?? {},
|
filters: database.filters ?? {},
|
||||||
migrations: {
|
assign: {
|
||||||
disableForeignKeys: false,
|
convertCustomTypes: true,
|
||||||
path: pathToMigrations,
|
},
|
||||||
generator: CustomTsMigrationGenerator,
|
migrations: {
|
||||||
silent: !(
|
disableForeignKeys: false,
|
||||||
database.debug ??
|
path: pathToMigrations,
|
||||||
process.env.NODE_ENV?.startsWith("dev") ??
|
generator: CustomTsMigrationGenerator,
|
||||||
false
|
silent: !(
|
||||||
),
|
database.debug ??
|
||||||
},
|
process.env.NODE_ENV?.startsWith("dev") ??
|
||||||
schemaGenerator: {
|
false
|
||||||
disableForeignKeys: false,
|
),
|
||||||
},
|
},
|
||||||
pool: {
|
schemaGenerator: {
|
||||||
min: 2,
|
disableForeignKeys: false,
|
||||||
...database.pool,
|
},
|
||||||
},
|
pool: {
|
||||||
})
|
min: 2,
|
||||||
|
...database.pool,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@@ -4,23 +4,20 @@ import type {
|
|||||||
FindOneOptions,
|
FindOneOptions,
|
||||||
FindOptions,
|
FindOptions,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { EntityMetadata, EntitySchema, ReferenceType } from "@mikro-orm/core"
|
import { EntityMetadata, ReferenceKind } from "@mikro-orm/core"
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
|
|
||||||
export const FreeTextSearchFilterKey = "freeTextSearch"
|
export const FreeTextSearchFilterKeyPrefix = "freeTextSearch_"
|
||||||
|
|
||||||
interface FilterArgument {
|
interface FilterArgument {
|
||||||
value: string
|
value: string
|
||||||
fromEntity: string
|
fromEntity: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEntityProperties(entity: EntityClass<any> | EntitySchema): {
|
function getEntityProperties(metadata: EntityMetadata<any>): {
|
||||||
[key: string]: EntityProperty<any>
|
[key: string]: EntityProperty<any>
|
||||||
} {
|
} {
|
||||||
return (
|
return metadata.properties
|
||||||
(entity as EntityClass<any>)?.prototype.__meta?.properties ??
|
|
||||||
(entity as EntitySchema).meta?.properties
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function retrieveRelationsConstraints(
|
function retrieveRelationsConstraints(
|
||||||
@@ -31,7 +28,7 @@ function retrieveRelationsConstraints(
|
|||||||
type: string
|
type: string
|
||||||
name: string
|
name: string
|
||||||
},
|
},
|
||||||
models: (EntityClass<any> | EntitySchema)[],
|
metadata: EntityMetadata<any>,
|
||||||
searchValue: string,
|
searchValue: string,
|
||||||
visited: Set<string> = new Set(),
|
visited: Set<string> = new Set(),
|
||||||
shouldStop: boolean = false
|
shouldStop: boolean = false
|
||||||
@@ -46,13 +43,12 @@ function retrieveRelationsConstraints(
|
|||||||
|
|
||||||
const relationFreeTextSearchWhere: any = []
|
const relationFreeTextSearchWhere: any = []
|
||||||
|
|
||||||
const relationClass = models.find((m) => m.name === relation.type)!
|
const relationProperties = getEntityProperties(metadata)
|
||||||
const relationProperties = getEntityProperties(relationClass)
|
|
||||||
|
|
||||||
for (const propertyConfiguration of Object.values(relationProperties)) {
|
for (const propertyConfiguration of Object.values(relationProperties)) {
|
||||||
if (
|
if (
|
||||||
!(propertyConfiguration as any).searchable ||
|
!(propertyConfiguration as any).searchable ||
|
||||||
propertyConfiguration.reference !== ReferenceType.SCALAR
|
propertyConfiguration.kind !== ReferenceKind.SCALAR
|
||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -69,9 +65,7 @@ function retrieveRelationsConstraints(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const innerRelations: EntityProperty[] =
|
const innerRelations: EntityProperty[] = metadata.relations
|
||||||
(relationClass as EntityClass<any>)?.prototype.__meta?.relations ??
|
|
||||||
(relationClass as EntitySchema).meta?.relations
|
|
||||||
|
|
||||||
for (const innerRelation of innerRelations) {
|
for (const innerRelation of innerRelations) {
|
||||||
const branchVisited = new Set(Array.from(visited))
|
const branchVisited = new Set(Array.from(visited))
|
||||||
@@ -108,7 +102,7 @@ function retrieveRelationsConstraints(
|
|||||||
mapToPk: innerRelation.mapToPk,
|
mapToPk: innerRelation.mapToPk,
|
||||||
type: innerRelation.type,
|
type: innerRelation.type,
|
||||||
},
|
},
|
||||||
models,
|
innerRelation.targetMeta!,
|
||||||
searchValue,
|
searchValue,
|
||||||
branchVisited,
|
branchVisited,
|
||||||
isSelfCircularDependency
|
isSelfCircularDependency
|
||||||
@@ -128,10 +122,9 @@ function retrieveRelationsConstraints(
|
|||||||
return relationFreeTextSearchWhere
|
return relationFreeTextSearchWhere
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mikroOrmFreeTextSearchFilterOptionsFactory = (
|
export const mikroOrmFreeTextSearchFilterOptionsFactory = (model: string) => {
|
||||||
models: (EntityClass<any> | EntitySchema)[]
|
|
||||||
) => {
|
|
||||||
return {
|
return {
|
||||||
|
name: FreeTextSearchFilterKeyPrefix + model,
|
||||||
cond: (
|
cond: (
|
||||||
freeTextSearchArgs: FilterArgument,
|
freeTextSearchArgs: FilterArgument,
|
||||||
operation: string,
|
operation: string,
|
||||||
@@ -144,7 +137,7 @@ export const mikroOrmFreeTextSearchFilterOptionsFactory = (
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { value, fromEntity } = freeTextSearchArgs
|
const { value } = freeTextSearchArgs
|
||||||
|
|
||||||
if (options?.visited?.size) {
|
if (options?.visited?.size) {
|
||||||
/**
|
/**
|
||||||
@@ -158,17 +151,17 @@ export const mikroOrmFreeTextSearchFilterOptionsFactory = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const entityMetadata = manager.getDriver().getMetadata().get(fromEntity)
|
const entityMetadata = manager.getDriver().getMetadata().get(model)
|
||||||
|
|
||||||
const freeTextSearchWhere = retrieveRelationsConstraints(
|
const freeTextSearchWhere = retrieveRelationsConstraints(
|
||||||
{
|
{
|
||||||
targetMeta: entityMetadata,
|
targetMeta: entityMetadata,
|
||||||
mapToPk: false,
|
mapToPk: false,
|
||||||
searchable: true,
|
searchable: true,
|
||||||
type: fromEntity,
|
type: model,
|
||||||
name: entityMetadata.name!,
|
name: entityMetadata.name!,
|
||||||
},
|
},
|
||||||
models,
|
entityMetadata,
|
||||||
value
|
value
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -180,8 +173,5 @@ export const mikroOrmFreeTextSearchFilterOptionsFactory = (
|
|||||||
$or: freeTextSearchWhere,
|
$or: freeTextSearchWhere,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
default: true,
|
|
||||||
args: false,
|
|
||||||
entity: models.map((m) => m.name) as string[],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
LoadStrategy,
|
LoadStrategy,
|
||||||
FilterQuery as MikroFilterQuery,
|
FilterQuery as MikroFilterQuery,
|
||||||
FindOptions as MikroOptions,
|
FindOptions as MikroOptions,
|
||||||
ReferenceType,
|
ReferenceKind,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
import {
|
import {
|
||||||
@@ -245,24 +245,6 @@ export class MikroOrmBaseRepository<const T extends object = object>
|
|||||||
|
|
||||||
return [entities, softDeletedEntitiesMap]
|
return [entities, softDeletedEntitiesMap]
|
||||||
}
|
}
|
||||||
|
|
||||||
applyFreeTextSearchFilters<T>(
|
|
||||||
findOptions: DAL.FindOptions<T & { q?: string }>,
|
|
||||||
retrieveConstraintsToApply: (q: string) => any[]
|
|
||||||
): void {
|
|
||||||
if (!("q" in findOptions.where) || !findOptions.where.q) {
|
|
||||||
delete findOptions.where.q
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const q = findOptions.where.q as string
|
|
||||||
delete findOptions.where.q
|
|
||||||
|
|
||||||
findOptions.where = {
|
|
||||||
$and: [findOptions.where, { $or: retrieveConstraintsToApply(q) }],
|
|
||||||
} as unknown as DAL.FindOptions<T & { q?: string }>["where"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MikroOrmBaseTreeRepository<
|
export class MikroOrmBaseTreeRepository<
|
||||||
@@ -391,7 +373,7 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
const relation = relations.find((relation) => relation.name === key)
|
const relation = relations.find((relation) => relation.name === key)
|
||||||
const shouldInit =
|
const shouldInit =
|
||||||
relation &&
|
relation &&
|
||||||
relation.reference === ReferenceType.MANY_TO_MANY &&
|
relation.kind === ReferenceKind.MANY_TO_MANY &&
|
||||||
Array.isArray(update[key]) &&
|
Array.isArray(update[key]) &&
|
||||||
!update[key].length
|
!update[key].length
|
||||||
|
|
||||||
@@ -434,7 +416,9 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
await this.initManyToManyToDetachAllItemsIfNeeded(data, context)
|
await this.initManyToManyToDetachAllItemsIfNeeded(data, context)
|
||||||
|
|
||||||
data.map((_, index) => {
|
data.map((_, index) => {
|
||||||
manager.assign(data[index].entity, data[index].update)
|
manager.assign(data[index].entity, data[index].update, {
|
||||||
|
mergeObjectProperties: true,
|
||||||
|
})
|
||||||
manager.persist(data[index].entity)
|
manager.persist(data[index].entity)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -578,7 +562,7 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
const existingEntity = existingEntitiesMap.get(key)
|
const existingEntity = existingEntitiesMap.get(key)
|
||||||
if (existingEntity) {
|
if (existingEntity) {
|
||||||
const updatedType = manager.assign(existingEntity, data_)
|
const updatedType = manager.assign(existingEntity, data_)
|
||||||
updatedEntities.push(updatedType)
|
updatedEntities.push(updatedType as any)
|
||||||
} else {
|
} else {
|
||||||
const newEntity = manager.create(this.entity, data_)
|
const newEntity = manager.create(this.entity, data_)
|
||||||
createdEntities.push(newEntity as InferRepositoryReturnType<T>)
|
createdEntities.push(newEntity as InferRepositoryReturnType<T>)
|
||||||
@@ -698,8 +682,8 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
// TODO: Handle ONE_TO_ONE
|
// TODO: Handle ONE_TO_ONE
|
||||||
// One to one and Many to one are handled outside of the assignment as they need to happen before the main entity is created
|
// One to one and Many to one are handled outside of the assignment as they need to happen before the main entity is created
|
||||||
if (
|
if (
|
||||||
relation.reference === ReferenceType.ONE_TO_ONE ||
|
relation.kind === ReferenceKind.ONE_TO_ONE ||
|
||||||
relation.reference === ReferenceType.MANY_TO_ONE
|
relation.kind === ReferenceKind.MANY_TO_ONE
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -765,7 +749,7 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
return this.getEntityWithId(manager, relation.type, normalizedItem)
|
return this.getEntityWithId(manager, relation.type, normalizedItem)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (relation.reference === ReferenceType.MANY_TO_MANY) {
|
if (relation.kind === ReferenceKind.MANY_TO_MANY) {
|
||||||
const currentPivotColumn = relation.inverseJoinColumns[0]
|
const currentPivotColumn = relation.inverseJoinColumns[0]
|
||||||
const parentPivotColumn = relation.joinColumns[0]
|
const parentPivotColumn = relation.joinColumns[0]
|
||||||
|
|
||||||
@@ -805,7 +789,7 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
return { entities: normalizedData, performedActions }
|
return { entities: normalizedData, performedActions }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relation.reference === ReferenceType.ONE_TO_MANY) {
|
if (relation.kind === ReferenceKind.ONE_TO_MANY) {
|
||||||
const joinColumns =
|
const joinColumns =
|
||||||
relation.targetMeta?.properties[relation.mappedBy]?.joinColumns
|
relation.targetMeta?.properties[relation.mappedBy]?.joinColumns
|
||||||
|
|
||||||
@@ -815,7 +799,7 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
joinColumnsConstraints[joinColumn] = data[referencedColumnName]
|
joinColumnsConstraints[joinColumn] = data[referencedColumnName]
|
||||||
})
|
})
|
||||||
|
|
||||||
const toDeleteEntities = await manager.find<any>(
|
const toDeleteEntities = await manager.find<any, any, "id">(
|
||||||
relation.type,
|
relation.type,
|
||||||
{
|
{
|
||||||
...joinColumnsConstraints,
|
...joinColumnsConstraints,
|
||||||
@@ -869,7 +853,7 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If it is a many-to-one we ensure the ID is set for when we want to set/unset an association
|
// If it is a many-to-one we ensure the ID is set for when we want to set/unset an association
|
||||||
if (relation.reference === ReferenceType.MANY_TO_ONE) {
|
if (relation.kind === ReferenceKind.MANY_TO_ONE) {
|
||||||
if (originalData === null) {
|
if (originalData === null) {
|
||||||
entryCopy[relation.joinColumns[0]] = null
|
entryCopy[relation.joinColumns[0]] = null
|
||||||
return null
|
return null
|
||||||
@@ -927,7 +911,7 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
|||||||
.filter(
|
.filter(
|
||||||
([_, propDef]: any) =>
|
([_, propDef]: any) =>
|
||||||
propDef.persist === false &&
|
propDef.persist === false &&
|
||||||
propDef.reference === ReferenceType.MANY_TO_ONE
|
propDef.kind === ReferenceKind.MANY_TO_ONE
|
||||||
)
|
)
|
||||||
.forEach(([key]) => {
|
.forEach(([key]) => {
|
||||||
delete resp[key]
|
delete resp[key]
|
||||||
|
|||||||
@@ -7,36 +7,45 @@ import {
|
|||||||
Loaded,
|
Loaded,
|
||||||
Platform,
|
Platform,
|
||||||
Reference,
|
Reference,
|
||||||
ReferenceType,
|
ReferenceKind,
|
||||||
SerializationContext,
|
SerializationContext,
|
||||||
SerializeOptions,
|
SerializeOptions,
|
||||||
Utils,
|
Utils,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
|
|
||||||
|
type CustomSerializeOptions<T, P = any> = SerializeOptions<T, P & string> & {
|
||||||
|
preventCircularRef?: boolean
|
||||||
|
populate?: [keyof T][] | boolean
|
||||||
|
}
|
||||||
|
|
||||||
function isVisible<T extends object>(
|
function isVisible<T extends object>(
|
||||||
meta: EntityMetadata<T>,
|
meta: EntityMetadata<T>,
|
||||||
propName: string,
|
propName: string,
|
||||||
options: SerializeOptions<T, any> & { preventCircularRef?: boolean } = {}
|
options: CustomSerializeOptions<T> = {}
|
||||||
): boolean {
|
): boolean {
|
||||||
if (options.populate === true) {
|
if (options.populate === true) {
|
||||||
return options.populate
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Array.isArray(options.populate) &&
|
Array.isArray(options.populate) &&
|
||||||
options.populate?.find(
|
options.exclude?.find((item) => item === propName)
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
Array.isArray(options.populate) &&
|
||||||
|
(options.populate?.find(
|
||||||
(item) => item === propName || item.startsWith(propName + ".")
|
(item) => item === propName || item.startsWith(propName + ".")
|
||||||
)
|
) ||
|
||||||
|
options.populate.includes("*"))
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.exclude?.find((item) => item === propName)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const prop = meta.properties[propName]
|
const prop = meta.properties[propName]
|
||||||
const visible = prop && !prop.hidden
|
const visible = (prop && !prop.hidden) || prop === undefined // allow unknown properties
|
||||||
const prefixed = prop && !prop.primary && propName.startsWith("_") // ignore prefixed properties, if it's not a PK
|
const prefixed = prop && !prop.primary && propName.startsWith("_") // ignore prefixed properties, if it's not a PK
|
||||||
|
|
||||||
return visible && !prefixed
|
return visible && !prefixed
|
||||||
@@ -45,13 +54,14 @@ function isVisible<T extends object>(
|
|||||||
function isPopulated<T extends object>(
|
function isPopulated<T extends object>(
|
||||||
entity: T,
|
entity: T,
|
||||||
propName: string,
|
propName: string,
|
||||||
options: SerializeOptions<T, any>
|
options: CustomSerializeOptions<T>
|
||||||
): boolean {
|
): boolean {
|
||||||
if (
|
if (
|
||||||
typeof options.populate !== "boolean" &&
|
Array.isArray(options.populate) &&
|
||||||
options.populate?.find(
|
(options.populate?.find(
|
||||||
(item) => item === propName || item.startsWith(propName + ".")
|
(item) => item === propName || item.startsWith(propName + ".")
|
||||||
)
|
) ||
|
||||||
|
options.populate.includes("*"))
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -78,9 +88,7 @@ function filterEntityPropToSerialize({
|
|||||||
}: {
|
}: {
|
||||||
propName: string
|
propName: string
|
||||||
meta: EntityMetadata
|
meta: EntityMetadata
|
||||||
options: SerializeOptions<object, any> & {
|
options: CustomSerializeOptions<any>
|
||||||
preventCircularRef?: boolean
|
|
||||||
}
|
|
||||||
parents?: string[]
|
parents?: string[]
|
||||||
}): boolean {
|
}): boolean {
|
||||||
parents ??= []
|
parents ??= []
|
||||||
@@ -92,7 +100,7 @@ function filterEntityPropToSerialize({
|
|||||||
prop &&
|
prop &&
|
||||||
options.preventCircularRef &&
|
options.preventCircularRef &&
|
||||||
isVisibleRes &&
|
isVisibleRes &&
|
||||||
prop.reference !== ReferenceType.SCALAR
|
prop.kind !== ReferenceKind.SCALAR
|
||||||
) {
|
) {
|
||||||
// mapToPk would represent a foreign key and we want to keep them
|
// mapToPk would represent a foreign key and we want to keep them
|
||||||
if (!!prop.mapToPk) {
|
if (!!prop.mapToPk) {
|
||||||
@@ -108,7 +116,7 @@ function filterEntityPropToSerialize({
|
|||||||
export class EntitySerializer {
|
export class EntitySerializer {
|
||||||
static serialize<T extends object, P extends string = never>(
|
static serialize<T extends object, P extends string = never>(
|
||||||
entity: T,
|
entity: T,
|
||||||
options: SerializeOptions<T, P> & { preventCircularRef?: boolean } = {},
|
options: CustomSerializeOptions<T, P> = {},
|
||||||
parents: string[] = []
|
parents: string[] = []
|
||||||
): EntityDTO<Loaded<T, P>> {
|
): EntityDTO<Loaded<T, P>> {
|
||||||
const parents_ = Array.from(new Set(parents))
|
const parents_ = Array.from(new Set(parents))
|
||||||
@@ -118,12 +126,11 @@ export class EntitySerializer {
|
|||||||
let contextCreated = false
|
let contextCreated = false
|
||||||
|
|
||||||
if (!wrapped.__serializationContext.root) {
|
if (!wrapped.__serializationContext.root) {
|
||||||
const root = new SerializationContext<T>()
|
const root = new SerializationContext<T>({} as any)
|
||||||
SerializationContext.propagate(
|
SerializationContext.propagate(
|
||||||
root,
|
root,
|
||||||
entity,
|
entity,
|
||||||
(meta, prop) =>
|
(meta, prop) => meta.properties[prop]?.kind !== ReferenceKind.SCALAR
|
||||||
meta.properties[prop]?.reference !== ReferenceType.SCALAR
|
|
||||||
)
|
)
|
||||||
contextCreated = true
|
contextCreated = true
|
||||||
}
|
}
|
||||||
@@ -238,25 +245,25 @@ export class EntitySerializer {
|
|||||||
|
|
||||||
private static propertyName<T>(
|
private static propertyName<T>(
|
||||||
meta: EntityMetadata<T>,
|
meta: EntityMetadata<T>,
|
||||||
prop: keyof T & string,
|
prop: string,
|
||||||
platform?: Platform
|
platform?: Platform
|
||||||
): string {
|
): string {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (meta.properties[prop]?.serializedName) {
|
if (meta.properties[prop]?.serializedName) {
|
||||||
return meta.properties[prop].serializedName as keyof T & string
|
return meta.properties[prop].serializedName as string
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta.properties[prop]?.primary && platform) {
|
if (meta.properties[prop]?.primary && platform) {
|
||||||
return platform.getSerializedPrimaryKeyField(prop) as keyof T & string
|
return platform.getSerializedPrimaryKeyField(prop) as string
|
||||||
}
|
}
|
||||||
|
|
||||||
return prop
|
return prop
|
||||||
}
|
}
|
||||||
|
|
||||||
private static processProperty<T extends object>(
|
private static processProperty<T extends object>(
|
||||||
prop: keyof T & string,
|
prop: string,
|
||||||
entity: T,
|
entity: T,
|
||||||
options: SerializeOptions<T, any>,
|
options: CustomSerializeOptions<T>,
|
||||||
parents: string[] = []
|
parents: string[] = []
|
||||||
): T[keyof T] | undefined {
|
): T[keyof T] | undefined {
|
||||||
const parents_ = [...parents, entity.constructor.name]
|
const parents_ = [...parents, entity.constructor.name]
|
||||||
@@ -284,12 +291,17 @@ export class EntitySerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isCollection(entity[prop])) {
|
if (Utils.isCollection(entity[prop])) {
|
||||||
return this.processCollection(prop, entity, options, parents_)
|
return this.processCollection(
|
||||||
|
prop as keyof T & string,
|
||||||
|
entity,
|
||||||
|
options,
|
||||||
|
parents_
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isEntity(entity[prop], true)) {
|
if (Utils.isEntity(entity[prop], true)) {
|
||||||
return this.processEntity(
|
return this.processEntity(
|
||||||
prop,
|
prop as keyof T & string,
|
||||||
entity,
|
entity,
|
||||||
wrapped.__platform,
|
wrapped.__platform,
|
||||||
options,
|
options,
|
||||||
@@ -298,7 +310,7 @@ export class EntitySerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (property?.reference === ReferenceType.EMBEDDED) {
|
if (property?.reference === ReferenceKind.EMBEDDED) {
|
||||||
if (Array.isArray(entity[prop])) {
|
if (Array.isArray(entity[prop])) {
|
||||||
return (entity[prop] as object[]).map((item) =>
|
return (entity[prop] as object[]).map((item) =>
|
||||||
helper(item).toJSON()
|
helper(item).toJSON()
|
||||||
@@ -322,9 +334,9 @@ export class EntitySerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static extractChildOptions<T extends object, U extends object>(
|
private static extractChildOptions<T extends object, U extends object>(
|
||||||
options: SerializeOptions<T, any>,
|
options: CustomSerializeOptions<T>,
|
||||||
prop: keyof T & string
|
prop: keyof T & string
|
||||||
): SerializeOptions<U, any> {
|
): CustomSerializeOptions<U> {
|
||||||
const extractChildElements = (items: string[]) => {
|
const extractChildElements = (items: string[]) => {
|
||||||
return items
|
return items
|
||||||
.filter((field) => field.startsWith(`${prop}.`))
|
.filter((field) => field.startsWith(`${prop}.`))
|
||||||
@@ -333,20 +345,22 @@ export class EntitySerializer {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...options,
|
...options,
|
||||||
populate: Array.isArray(options.populate)
|
populate:
|
||||||
? extractChildElements(options.populate)
|
Array.isArray(options.populate) && !options.populate.includes("*")
|
||||||
: options.populate,
|
? extractChildElements(options.populate as unknown as string[])
|
||||||
exclude: Array.isArray(options.exclude)
|
: options.populate,
|
||||||
? extractChildElements(options.exclude)
|
exclude:
|
||||||
: options.exclude,
|
Array.isArray(options.exclude) && !options.exclude.includes("*")
|
||||||
} as SerializeOptions<U, any>
|
? extractChildElements(options.exclude)
|
||||||
|
: options.exclude,
|
||||||
|
} as CustomSerializeOptions<U>
|
||||||
}
|
}
|
||||||
|
|
||||||
private static processEntity<T extends object>(
|
private static processEntity<T extends object>(
|
||||||
prop: keyof T & string,
|
prop: keyof T & string,
|
||||||
entity: T,
|
entity: T,
|
||||||
platform: Platform,
|
platform: Platform,
|
||||||
options: SerializeOptions<T, any>,
|
options: CustomSerializeOptions<T>,
|
||||||
parents: string[] = []
|
parents: string[] = []
|
||||||
): T[keyof T] | undefined {
|
): T[keyof T] | undefined {
|
||||||
const parents_ = [...parents, entity.constructor.name]
|
const parents_ = [...parents, entity.constructor.name]
|
||||||
@@ -373,7 +387,7 @@ export class EntitySerializer {
|
|||||||
private static processCollection<T extends object>(
|
private static processCollection<T extends object>(
|
||||||
prop: keyof T & string,
|
prop: keyof T & string,
|
||||||
entity: T,
|
entity: T,
|
||||||
options: SerializeOptions<T, any>,
|
options: CustomSerializeOptions<T>,
|
||||||
parents: string[] = []
|
parents: string[] = []
|
||||||
): T[keyof T] | undefined {
|
): T[keyof T] | undefined {
|
||||||
const parents_ = [...parents, entity.constructor.name]
|
const parents_ = [...parents, entity.constructor.name]
|
||||||
@@ -401,6 +415,7 @@ export const mikroOrmSerializer = <TOutput extends object>(
|
|||||||
data: any,
|
data: any,
|
||||||
options?: Parameters<typeof EntitySerializer.serialize>[1] & {
|
options?: Parameters<typeof EntitySerializer.serialize>[1] & {
|
||||||
preventCircularRef?: boolean
|
preventCircularRef?: boolean
|
||||||
|
populate?: string[] | boolean
|
||||||
}
|
}
|
||||||
): Promise<TOutput> => {
|
): Promise<TOutput> => {
|
||||||
return new Promise<TOutput>((resolve) => {
|
return new Promise<TOutput>((resolve) => {
|
||||||
@@ -422,10 +437,11 @@ export const mikroOrmSerializer = <TOutput extends object>(
|
|||||||
let result: any = forSerialization.map((entity) =>
|
let result: any = forSerialization.map((entity) =>
|
||||||
EntitySerializer.serialize(entity, {
|
EntitySerializer.serialize(entity, {
|
||||||
forceObject: true,
|
forceObject: true,
|
||||||
populate: true,
|
populate: ["*"],
|
||||||
|
|
||||||
preventCircularRef: true,
|
preventCircularRef: true,
|
||||||
...options,
|
...options,
|
||||||
} as SerializeOptions<any, any>)
|
} as CustomSerializeOptions<any>)
|
||||||
) as TOutput[]
|
) as TOutput[]
|
||||||
|
|
||||||
if (notForSerialization.length) {
|
if (notForSerialization.length) {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -6,6 +6,7 @@ import {
|
|||||||
import { DmlEntity, DMLEntitySchemaBuilder } from "./entity"
|
import { DmlEntity, DMLEntitySchemaBuilder } from "./entity"
|
||||||
import { createBigNumberProperties } from "./helpers/entity-builder/create-big-number-properties"
|
import { createBigNumberProperties } from "./helpers/entity-builder/create-big-number-properties"
|
||||||
import { createDefaultProperties } from "./helpers/entity-builder/create-default-properties"
|
import { createDefaultProperties } from "./helpers/entity-builder/create-default-properties"
|
||||||
|
import { FloatProperty } from "./properties"
|
||||||
import { ArrayProperty } from "./properties/array"
|
import { ArrayProperty } from "./properties/array"
|
||||||
import { AutoIncrementProperty } from "./properties/autoincrement"
|
import { AutoIncrementProperty } from "./properties/autoincrement"
|
||||||
import { BigNumberProperty } from "./properties/big-number"
|
import { BigNumberProperty } from "./properties/big-number"
|
||||||
@@ -21,7 +22,6 @@ import { HasMany } from "./relations/has-many"
|
|||||||
import { HasOne } from "./relations/has-one"
|
import { HasOne } from "./relations/has-one"
|
||||||
import { HasOneWithForeignKey } from "./relations/has-one-fk"
|
import { HasOneWithForeignKey } from "./relations/has-one-fk"
|
||||||
import { ManyToMany } from "./relations/many-to-many"
|
import { ManyToMany } from "./relations/many-to-many"
|
||||||
import { FloatProperty } from "./properties"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The implicit properties added by EntityBuilder in every schema
|
* The implicit properties added by EntityBuilder in every schema
|
||||||
@@ -128,7 +128,7 @@ export class EntityBuilder {
|
|||||||
): DmlEntity<DMLEntitySchemaBuilder<Schema>, TConfig> {
|
): DmlEntity<DMLEntitySchemaBuilder<Schema>, TConfig> {
|
||||||
this.#disallowImplicitProperties(schema)
|
this.#disallowImplicitProperties(schema)
|
||||||
|
|
||||||
return new DmlEntity<Schema, TConfig>(nameOrConfig, {
|
return new DmlEntity(nameOrConfig, {
|
||||||
...schema,
|
...schema,
|
||||||
...createBigNumberProperties(schema),
|
...createBigNumberProperties(schema),
|
||||||
...createDefaultProperties(),
|
...createDefaultProperties(),
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
import {
|
import {
|
||||||
IDmlEntity,
|
|
||||||
DMLSchema,
|
|
||||||
EntityIndex,
|
|
||||||
CheckConstraint,
|
CheckConstraint,
|
||||||
|
DMLSchema,
|
||||||
EntityCascades,
|
EntityCascades,
|
||||||
QueryCondition,
|
EntityIndex,
|
||||||
IDmlEntityConfig,
|
|
||||||
ExtractEntityRelations,
|
ExtractEntityRelations,
|
||||||
|
IDmlEntity,
|
||||||
|
IDmlEntityConfig,
|
||||||
InferDmlEntityNameFromConfig,
|
InferDmlEntityNameFromConfig,
|
||||||
|
QueryCondition,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { isObject, isString, toCamelCase, upperCaseFirst } from "../common"
|
import { isObject, isString, toCamelCase, upperCaseFirst } from "../common"
|
||||||
import { transformIndexWhere } from "./helpers/entity-builder/build-indexes"
|
import { transformIndexWhere } from "./helpers/entity-builder/build-indexes"
|
||||||
|
import { DMLSchemaWithBigNumber } from "./helpers/entity-builder/create-big-number-properties"
|
||||||
|
import { DMLSchemaDefaults } from "./helpers/entity-builder/create-default-properties"
|
||||||
import { BelongsTo } from "./relations/belongs-to"
|
import { BelongsTo } from "./relations/belongs-to"
|
||||||
import {
|
|
||||||
DMLSchemaDefaults,
|
|
||||||
DMLSchemaWithBigNumber,
|
|
||||||
} from "./helpers/entity-builder"
|
|
||||||
|
|
||||||
const IsDmlEntity = Symbol.for("isDmlEntity")
|
const IsDmlEntity = Symbol.for("isDmlEntity")
|
||||||
|
|
||||||
@@ -68,7 +66,7 @@ function extractNameAndTableName<const Config extends IDmlEntityConfig>(
|
|||||||
* name, its schema and relationships.
|
* name, its schema and relationships.
|
||||||
*/
|
*/
|
||||||
export class DmlEntity<
|
export class DmlEntity<
|
||||||
Schema extends DMLSchema,
|
const Schema extends DMLSchema,
|
||||||
const TConfig extends IDmlEntityConfig
|
const TConfig extends IDmlEntityConfig
|
||||||
> implements IDmlEntity<Schema, TConfig>
|
> implements IDmlEntity<Schema, TConfig>
|
||||||
{
|
{
|
||||||
@@ -79,6 +77,7 @@ export class DmlEntity<
|
|||||||
|
|
||||||
readonly #tableName: string
|
readonly #tableName: string
|
||||||
#cascades: EntityCascades<string[], string[]> = {}
|
#cascades: EntityCascades<string[], string[]> = {}
|
||||||
|
|
||||||
#indexes: EntityIndex<Schema>[] = []
|
#indexes: EntityIndex<Schema>[] = []
|
||||||
#checks: CheckConstraint<Schema>[] = []
|
#checks: CheckConstraint<Schema>[] = []
|
||||||
|
|
||||||
@@ -251,8 +250,6 @@ export class DmlEntity<
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
checks(checks: CheckConstraint<Schema>[]) {
|
checks(checks: CheckConstraint<Schema>[]) {
|
||||||
this.#checks = checks
|
this.#checks = checks
|
||||||
return this
|
return this
|
||||||
|
|||||||
@@ -8,15 +8,18 @@ import type {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { Entity, Filter } from "@mikro-orm/core"
|
import { Entity, Filter } from "@mikro-orm/core"
|
||||||
|
|
||||||
|
import {
|
||||||
|
mikroOrmFreeTextSearchFilterOptionsFactory,
|
||||||
|
mikroOrmSoftDeletableFilterOptions,
|
||||||
|
} from "../../dal"
|
||||||
import { DmlEntity } from "../entity"
|
import { DmlEntity } from "../entity"
|
||||||
import { IdProperty } from "../properties/id"
|
|
||||||
import { DuplicateIdPropertyError } from "../errors"
|
import { DuplicateIdPropertyError } from "../errors"
|
||||||
import { applyChecks } from "./mikro-orm/apply-checks"
|
import { IdProperty } from "../properties/id"
|
||||||
import { mikroOrmSoftDeletableFilterOptions } from "../../dal"
|
|
||||||
import { defineProperty } from "./entity-builder/define-property"
|
|
||||||
import { applySearchable } from "./entity-builder/apply-searchable"
|
import { applySearchable } from "./entity-builder/apply-searchable"
|
||||||
import { parseEntityName } from "./entity-builder/parse-entity-name"
|
import { defineProperty } from "./entity-builder/define-property"
|
||||||
import { defineRelationship } from "./entity-builder/define-relationship"
|
import { defineRelationship } from "./entity-builder/define-relationship"
|
||||||
|
import { parseEntityName } from "./entity-builder/parse-entity-name"
|
||||||
|
import { applyChecks } from "./mikro-orm/apply-checks"
|
||||||
import { applyEntityIndexes, applyIndexes } from "./mikro-orm/apply-indexes"
|
import { applyEntityIndexes, applyIndexes } from "./mikro-orm/apply-indexes"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,8 +51,16 @@ function createMikrORMEntity() {
|
|||||||
function createEntity<T extends DmlEntity<any, any>>(entity: T): Infer<T> {
|
function createEntity<T extends DmlEntity<any, any>>(entity: T): Infer<T> {
|
||||||
class MikroORMEntity {}
|
class MikroORMEntity {}
|
||||||
|
|
||||||
const { schema, cascades, indexes: entityIndexes, checks } = entity.parse()
|
const {
|
||||||
|
schema,
|
||||||
|
cascades,
|
||||||
|
indexes: entityIndexes = [],
|
||||||
|
//params,
|
||||||
|
checks,
|
||||||
|
} = entity.parse()
|
||||||
|
|
||||||
const { modelName, tableName } = parseEntityName(entity)
|
const { modelName, tableName } = parseEntityName(entity)
|
||||||
|
|
||||||
if (ENTITIES[modelName]) {
|
if (ENTITIES[modelName]) {
|
||||||
return ENTITIES[modelName] as Infer<T>
|
return ENTITIES[modelName] as Infer<T>
|
||||||
}
|
}
|
||||||
@@ -102,6 +113,9 @@ function createMikrORMEntity() {
|
|||||||
/**
|
/**
|
||||||
* Converting class to a MikroORM entity
|
* Converting class to a MikroORM entity
|
||||||
*/
|
*/
|
||||||
|
Filter(mikroOrmFreeTextSearchFilterOptionsFactory(modelName))(
|
||||||
|
MikroORMEntity
|
||||||
|
)
|
||||||
const RegisteredEntity = Entity({ tableName })(
|
const RegisteredEntity = Entity({ tableName })(
|
||||||
Filter(mikroOrmSoftDeletableFilterOptions)(MikroORMEntity)
|
Filter(mikroOrmSoftDeletableFilterOptions)(MikroORMEntity)
|
||||||
) as Infer<T>
|
) as Infer<T>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
Utils,
|
Utils,
|
||||||
t as mikroOrmType,
|
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { generateEntityId, isDefined } from "../../../common"
|
import { generateEntityId, isDefined } from "../../../common"
|
||||||
import { MikroOrmBigNumberProperty } from "../../../dal"
|
import { MikroOrmBigNumberProperty } from "../../../dal"
|
||||||
@@ -122,7 +121,8 @@ export function defineProperty(
|
|||||||
) {
|
) {
|
||||||
const field = property.parse(propertyName)
|
const field = property.parse(propertyName)
|
||||||
/**
|
/**
|
||||||
* Here we initialize nullable properties with a null value
|
* Here we initialize all properties with their default values on before create
|
||||||
|
* which means when persist is called but not necessarely flush
|
||||||
*/
|
*/
|
||||||
if (isDefined(field.defaultValue) || field.nullable) {
|
if (isDefined(field.defaultValue) || field.nullable) {
|
||||||
const defaultValueSetterHookName = `${field.fieldName}_setDefaultValueOnBeforeCreate`
|
const defaultValueSetterHookName = `${field.fieldName}_setDefaultValueOnBeforeCreate`
|
||||||
@@ -274,11 +274,12 @@ export function defineProperty(
|
|||||||
: Property
|
: Property
|
||||||
|
|
||||||
Prop({
|
Prop({
|
||||||
columnType: "serial",
|
autoincrement: true,
|
||||||
type: mikroOrmType.integer,
|
type: "number",
|
||||||
nullable: true,
|
runtimeType: "number",
|
||||||
|
nullable: field.nullable,
|
||||||
fieldName: field.fieldName,
|
fieldName: field.fieldName,
|
||||||
serializer: Number,
|
serializer: (value) => (value == null ? value : Number(value)),
|
||||||
})(MikroORMEntity.prototype, field.fieldName)
|
})(MikroORMEntity.prototype, field.fieldName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -290,13 +291,14 @@ export function defineProperty(
|
|||||||
Property({
|
Property({
|
||||||
columnType: "real",
|
columnType: "real",
|
||||||
type: "number",
|
type: "number",
|
||||||
|
runtimeType: "number",
|
||||||
nullable: field.nullable,
|
nullable: field.nullable,
|
||||||
fieldName: field.fieldName,
|
fieldName: field.fieldName,
|
||||||
/**
|
/**
|
||||||
* Applying number serializer to convert value back to a
|
* Applying number serializer to convert value back to a
|
||||||
* JavaScript number
|
* JavaScript number
|
||||||
*/
|
*/
|
||||||
serializer: Number,
|
serializer: (value) => (value == null ? value : Number(value)),
|
||||||
/**
|
/**
|
||||||
* MikroORM does not ignore undefined values for default when generating
|
* MikroORM does not ignore undefined values for default when generating
|
||||||
* the database schema SQL. Conditionally add it here to prevent undefined
|
* the database schema SQL. Conditionally add it here to prevent undefined
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export function defineHasOneRelationship(
|
|||||||
entity: relatedModelName,
|
entity: relatedModelName,
|
||||||
...(relationship.nullable ? { nullable: relationship.nullable } : {}),
|
...(relationship.nullable ? { nullable: relationship.nullable } : {}),
|
||||||
...(mappedBy ? { mappedBy } : {}),
|
...(mappedBy ? { mappedBy } : {}),
|
||||||
onDelete: shouldRemoveRelated ? "cascade" : undefined,
|
deleteRule: shouldRemoveRelated ? "cascade" : undefined,
|
||||||
} as OneToOneOptions<any, any>
|
} as OneToOneOptions<any, any>
|
||||||
|
|
||||||
if (shouldRemoveRelated && !isOthersideBelongsTo) {
|
if (shouldRemoveRelated && !isOthersideBelongsTo) {
|
||||||
@@ -322,7 +322,7 @@ export function defineBelongsToRelationship(
|
|||||||
/**
|
/**
|
||||||
* In DML the relationships are cascaded from parent to child. A belongsTo
|
* In DML the relationships are cascaded from parent to child. A belongsTo
|
||||||
* relationship is always a child, therefore we look at the parent and
|
* relationship is always a child, therefore we look at the parent and
|
||||||
* define a onDelete: cascade when we are included in the delete
|
* define a deleteRule: cascade when we are included in the delete
|
||||||
* list of parent cascade.
|
* list of parent cascade.
|
||||||
*/
|
*/
|
||||||
const shouldCascade = !!relationCascades.delete?.includes(mappedBy)
|
const shouldCascade = !!relationCascades.delete?.includes(mappedBy)
|
||||||
@@ -435,27 +435,33 @@ export function defineBelongsToRelationship(
|
|||||||
|
|
||||||
if (DmlManyToMany.isManyToMany(otherSideRelation)) {
|
if (DmlManyToMany.isManyToMany(otherSideRelation)) {
|
||||||
Property({
|
Property({
|
||||||
type: relatedModelName,
|
type: "string",
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
fieldName: foreignKeyName,
|
fieldName: foreignKeyName,
|
||||||
nullable: relationship.nullable,
|
nullable: relationship.nullable,
|
||||||
})(MikroORMEntity.prototype, foreignKeyName)
|
})(MikroORMEntity.prototype, foreignKeyName)
|
||||||
|
|
||||||
ManyToOne({
|
const conf = {
|
||||||
entity: relatedModelName,
|
entity: relatedModelName,
|
||||||
nullable: relationship.nullable,
|
nullable: relationship.nullable,
|
||||||
persist: false,
|
persist: false,
|
||||||
onDelete: shouldCascade || detachCascade ? "cascade" : undefined,
|
}
|
||||||
})(MikroORMEntity.prototype, relationship.name)
|
if (shouldCascade || detachCascade) {
|
||||||
|
conf["deleteRule"] = "cascade"
|
||||||
|
}
|
||||||
|
ManyToOne(conf)(MikroORMEntity.prototype, relationship.name)
|
||||||
} else {
|
} else {
|
||||||
ManyToOne({
|
const conf = {
|
||||||
entity: relatedModelName,
|
entity: relatedModelName,
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
mapToPk: true,
|
mapToPk: true,
|
||||||
fieldName: foreignKeyName,
|
fieldName: foreignKeyName,
|
||||||
nullable: relationship.nullable,
|
nullable: relationship.nullable,
|
||||||
onDelete: shouldCascade ? "cascade" : undefined,
|
}
|
||||||
})(MikroORMEntity.prototype, foreignKeyName)
|
if (shouldCascade) {
|
||||||
|
conf["deleteRule"] = "cascade"
|
||||||
|
}
|
||||||
|
ManyToOne(conf)(MikroORMEntity.prototype, foreignKeyName)
|
||||||
|
|
||||||
ManyToOne({
|
ManyToOne({
|
||||||
entity: relatedModelName,
|
entity: relatedModelName,
|
||||||
@@ -486,7 +492,6 @@ export function defineBelongsToRelationship(
|
|||||||
const foreignKeyName =
|
const foreignKeyName =
|
||||||
relationship.options.foreignKeyName ??
|
relationship.options.foreignKeyName ??
|
||||||
camelToSnakeCase(`${relationship.name}Id`)
|
camelToSnakeCase(`${relationship.name}Id`)
|
||||||
|
|
||||||
Property({
|
Property({
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
type: "string",
|
type: "string",
|
||||||
@@ -504,10 +509,10 @@ export function defineBelongsToRelationship(
|
|||||||
fieldName: foreignKeyName,
|
fieldName: foreignKeyName,
|
||||||
owner: true,
|
owner: true,
|
||||||
// orphanRemoval: true,
|
// orphanRemoval: true,
|
||||||
onDelete: shouldCascade ? "cascade" : undefined,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldCascade) {
|
if (shouldCascade) {
|
||||||
|
oneToOneOptions.deleteRule = "cascade"
|
||||||
oneToOneOptions.cascade = [Cascade.PERSIST, "soft-remove"] as any
|
oneToOneOptions.cascade = [Cascade.PERSIST, "soft-remove"] as any
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,8 +746,15 @@ export function defineManyToManyRelationship(
|
|||||||
: {}),
|
: {}),
|
||||||
...(pivotEntityName ? { pivotEntity: pivotEntityName } : {}),
|
...(pivotEntityName ? { pivotEntity: pivotEntityName } : {}),
|
||||||
...({ [mappedByProp]: mappedByPropValue } as any),
|
...({ [mappedByProp]: mappedByPropValue } as any),
|
||||||
[joinColumnProp]: joinColumn ?? joinColumns,
|
} as any
|
||||||
[inverseJoinColumnProp]: inverseJoinColumn ?? inverseJoinColumns,
|
|
||||||
|
if (joinColumn || joinColumns) {
|
||||||
|
manytoManyOptions[joinColumnProp] = joinColumn ?? joinColumns
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inverseJoinColumn || inverseJoinColumns) {
|
||||||
|
manytoManyOptions[inverseJoinColumnProp] =
|
||||||
|
inverseJoinColumn ?? inverseJoinColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
ManyToMany(manytoManyOptions)(MikroORMEntity.prototype, relationship.name)
|
ManyToMany(manytoManyOptions)(MikroORMEntity.prototype, relationship.name)
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ export * from "./helpers/entity-builder/index"
|
|||||||
export * from "./helpers/create-mikro-orm-entity"
|
export * from "./helpers/create-mikro-orm-entity"
|
||||||
export * from "./relations/index"
|
export * from "./relations/index"
|
||||||
export * from "./properties/index"
|
export * from "./properties/index"
|
||||||
|
|
||||||
|
export * from "./helpers/entity-builder/index"
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
import { EntityConstructor } from "@medusajs/types"
|
||||||
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
|
import { join } from "path"
|
||||||
|
import { createDatabase, dropDatabase } from "pg-god"
|
||||||
|
import { FileSystem } from "../../../common"
|
||||||
|
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
||||||
import { model } from "../../entity-builder"
|
import { model } from "../../entity-builder"
|
||||||
import {
|
import {
|
||||||
mikroORMEntityBuilder,
|
mikroORMEntityBuilder,
|
||||||
toMikroOrmEntities,
|
toMikroOrmEntities,
|
||||||
} from "../../helpers/create-mikro-orm-entity"
|
} from "../../helpers/create-mikro-orm-entity"
|
||||||
import { createDatabase, dropDatabase } from "pg-god"
|
|
||||||
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
|
||||||
import { EntityConstructor } from "@medusajs/types"
|
|
||||||
import { pgGodCredentials } from "../utils"
|
import { pgGodCredentials } from "../utils"
|
||||||
import { FileSystem } from "../../../common"
|
|
||||||
import { join } from "path"
|
|
||||||
|
|
||||||
export const fileSystem = new FileSystem(
|
export const fileSystem = new FileSystem(
|
||||||
join(__dirname, "../../integration-tests-migrations-enum")
|
join(__dirname, "../../integration-tests-migrations-enum")
|
||||||
@@ -40,19 +41,20 @@ describe("EntityBuilder", () => {
|
|||||||
|
|
||||||
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
||||||
|
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [User],
|
defineConfig({
|
||||||
tsNode: true,
|
entities: [User],
|
||||||
dbName,
|
tsNode: true,
|
||||||
password: pgGodCredentials.password,
|
dbName,
|
||||||
host: pgGodCredentials.host,
|
password: pgGodCredentials.password,
|
||||||
user: pgGodCredentials.user,
|
host: pgGodCredentials.host,
|
||||||
type: "postgresql",
|
user: pgGodCredentials.user,
|
||||||
migrations: {
|
migrations: {
|
||||||
generator: CustomTsMigrationGenerator,
|
generator: CustomTsMigrationGenerator,
|
||||||
path: fileSystem.basePath,
|
path: fileSystem.basePath,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const migrator = orm.getMigrator()
|
const migrator = orm.getMigrator()
|
||||||
await migrator.createMigration()
|
await migrator.createMigration()
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
|
import { EntityConstructor } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
CheckConstraintViolationException,
|
CheckConstraintViolationException,
|
||||||
MetadataStorage,
|
MetadataStorage,
|
||||||
MikroORM,
|
MikroORM,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
|
import { join } from "path"
|
||||||
|
import { createDatabase, dropDatabase } from "pg-god"
|
||||||
|
import { FileSystem } from "../../../common"
|
||||||
|
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
||||||
import { model } from "../../entity-builder"
|
import { model } from "../../entity-builder"
|
||||||
import {
|
import {
|
||||||
mikroORMEntityBuilder,
|
mikroORMEntityBuilder,
|
||||||
toMikroOrmEntities,
|
toMikroOrmEntities,
|
||||||
} from "../../helpers/create-mikro-orm-entity"
|
} from "../../helpers/create-mikro-orm-entity"
|
||||||
import { createDatabase, dropDatabase } from "pg-god"
|
|
||||||
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
|
||||||
import { EntityConstructor } from "@medusajs/types"
|
|
||||||
import { pgGodCredentials } from "../utils"
|
import { pgGodCredentials } from "../utils"
|
||||||
import { FileSystem } from "../../../common"
|
|
||||||
import { join } from "path"
|
|
||||||
|
|
||||||
export const fileSystem = new FileSystem(
|
export const fileSystem = new FileSystem(
|
||||||
join(__dirname, "../../integration-tests-migrations-enum")
|
join(__dirname, "../../integration-tests-migrations-enum")
|
||||||
@@ -43,19 +44,20 @@ describe("EntityBuilder | enum", () => {
|
|||||||
|
|
||||||
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
||||||
|
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [User],
|
defineConfig({
|
||||||
tsNode: true,
|
entities: [User],
|
||||||
dbName,
|
tsNode: true,
|
||||||
password: pgGodCredentials.password,
|
dbName,
|
||||||
host: pgGodCredentials.host,
|
password: pgGodCredentials.password,
|
||||||
user: pgGodCredentials.user,
|
host: pgGodCredentials.host,
|
||||||
type: "postgresql",
|
user: pgGodCredentials.user,
|
||||||
migrations: {
|
migrations: {
|
||||||
generator: CustomTsMigrationGenerator,
|
generator: CustomTsMigrationGenerator,
|
||||||
path: fileSystem.basePath,
|
path: fileSystem.basePath,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const migrator = orm.getMigrator()
|
const migrator = orm.getMigrator()
|
||||||
await migrator.createMigration()
|
await migrator.createMigration()
|
||||||
|
|||||||
+20
-18
@@ -1,15 +1,16 @@
|
|||||||
|
import { EntityConstructor } from "@medusajs/types"
|
||||||
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
|
import { join } from "path"
|
||||||
|
import { createDatabase, dropDatabase } from "pg-god"
|
||||||
|
import { FileSystem } from "../../../common"
|
||||||
|
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
||||||
import { model } from "../../entity-builder"
|
import { model } from "../../entity-builder"
|
||||||
import {
|
import {
|
||||||
mikroORMEntityBuilder,
|
mikroORMEntityBuilder,
|
||||||
toMikroOrmEntities,
|
toMikroOrmEntities,
|
||||||
} from "../../helpers/create-mikro-orm-entity"
|
} from "../../helpers/create-mikro-orm-entity"
|
||||||
import { createDatabase, dropDatabase } from "pg-god"
|
|
||||||
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
|
||||||
import { EntityConstructor } from "@medusajs/types"
|
|
||||||
import { pgGodCredentials } from "../utils"
|
import { pgGodCredentials } from "../utils"
|
||||||
import { FileSystem } from "../../../common"
|
|
||||||
import { join } from "path"
|
|
||||||
|
|
||||||
export const fileSystem = new FileSystem(
|
export const fileSystem = new FileSystem(
|
||||||
join(__dirname, "../../integration-tests-migrations-has-one-belongs-to")
|
join(__dirname, "../../integration-tests-migrations-has-one-belongs-to")
|
||||||
@@ -45,19 +46,20 @@ describe("hasOne - belongTo", () => {
|
|||||||
|
|
||||||
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
||||||
|
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [Team, User],
|
defineConfig({
|
||||||
tsNode: true,
|
entities: [Team, User],
|
||||||
dbName,
|
tsNode: true,
|
||||||
password: pgGodCredentials.password,
|
dbName,
|
||||||
host: pgGodCredentials.host,
|
password: pgGodCredentials.password,
|
||||||
user: pgGodCredentials.user,
|
host: pgGodCredentials.host,
|
||||||
type: "postgresql",
|
user: pgGodCredentials.user,
|
||||||
migrations: {
|
migrations: {
|
||||||
generator: CustomTsMigrationGenerator,
|
generator: CustomTsMigrationGenerator,
|
||||||
path: fileSystem.basePath,
|
path: fileSystem.basePath,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const migrator = orm.getMigrator()
|
const migrator = orm.getMigrator()
|
||||||
await migrator.createMigration()
|
await migrator.createMigration()
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import { join } from "path"
|
import { EntityConstructor } from "@medusajs/types"
|
||||||
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
|
import { join } from "path"
|
||||||
|
import { createDatabase, dropDatabase } from "pg-god"
|
||||||
|
import { FileSystem } from "../../../common"
|
||||||
|
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
||||||
import { model } from "../../entity-builder"
|
import { model } from "../../entity-builder"
|
||||||
import {
|
import {
|
||||||
mikroORMEntityBuilder,
|
mikroORMEntityBuilder,
|
||||||
toMikroOrmEntities,
|
toMikroOrmEntities,
|
||||||
} from "../../helpers/create-mikro-orm-entity"
|
} from "../../helpers/create-mikro-orm-entity"
|
||||||
import { createDatabase, dropDatabase } from "pg-god"
|
|
||||||
import { CustomTsMigrationGenerator, mikroOrmSerializer } from "../../../dal"
|
|
||||||
import { EntityConstructor } from "@medusajs/types"
|
|
||||||
import { pgGodCredentials } from "../utils"
|
import { pgGodCredentials } from "../utils"
|
||||||
import { FileSystem } from "../../../common"
|
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -62,19 +63,20 @@ describe("manyToMany - manyToMany", () => {
|
|||||||
|
|
||||||
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
||||||
|
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [Team, User, Squad],
|
defineConfig({
|
||||||
tsNode: true,
|
entities: [Team, User, Squad],
|
||||||
dbName,
|
tsNode: true,
|
||||||
password: pgGodCredentials.password,
|
dbName,
|
||||||
host: pgGodCredentials.host,
|
password: pgGodCredentials.password,
|
||||||
user: pgGodCredentials.user,
|
host: pgGodCredentials.host,
|
||||||
type: "postgresql",
|
user: pgGodCredentials.user,
|
||||||
migrations: {
|
migrations: {
|
||||||
generator: CustomTsMigrationGenerator,
|
generator: CustomTsMigrationGenerator,
|
||||||
path: fileSystem.basePath,
|
path: fileSystem.basePath,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const migrator = orm.getMigrator()
|
const migrator = orm.getMigrator()
|
||||||
await migrator.createMigration()
|
await migrator.createMigration()
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
|
import { EntityConstructor } from "@medusajs/types"
|
||||||
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
import { MetadataStorage, MikroORM } from "@mikro-orm/core"
|
||||||
import { model } from "../../entity-builder"
|
import { defineConfig, SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
import {
|
import { join } from "path"
|
||||||
mikroORMEntityBuilder,
|
|
||||||
toMikroOrmEntities,
|
|
||||||
} from "../../helpers/create-mikro-orm-entity"
|
|
||||||
import { createDatabase, dropDatabase } from "pg-god"
|
import { createDatabase, dropDatabase } from "pg-god"
|
||||||
|
import { FileSystem } from "../../../common"
|
||||||
import {
|
import {
|
||||||
CustomTsMigrationGenerator,
|
CustomTsMigrationGenerator,
|
||||||
mikroOrmSerializer,
|
mikroOrmSerializer,
|
||||||
mikroOrmUpdateDeletedAtRecursively,
|
mikroOrmUpdateDeletedAtRecursively,
|
||||||
SoftDeletableFilterKey,
|
SoftDeletableFilterKey,
|
||||||
} from "../../../dal"
|
} from "../../../dal"
|
||||||
import { EntityConstructor } from "@medusajs/types"
|
import { model } from "../../entity-builder"
|
||||||
|
import {
|
||||||
|
mikroORMEntityBuilder,
|
||||||
|
toMikroOrmEntities,
|
||||||
|
} from "../../helpers/create-mikro-orm-entity"
|
||||||
import { pgGodCredentials } from "../utils"
|
import { pgGodCredentials } from "../utils"
|
||||||
import { FileSystem } from "../../../common"
|
|
||||||
import { join } from "path"
|
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
|
||||||
|
|
||||||
export const fileSystem = new FileSystem(
|
export const fileSystem = new FileSystem(
|
||||||
join(__dirname, "../../integration-tests-migrations-many-to-one")
|
join(__dirname, "../../integration-tests-migrations-many-to-one")
|
||||||
@@ -55,19 +55,20 @@ describe("manyToOne - belongTo", () => {
|
|||||||
|
|
||||||
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
await createDatabase({ databaseName: dbName }, pgGodCredentials)
|
||||||
|
|
||||||
orm = await MikroORM.init({
|
orm = await MikroORM.init(
|
||||||
entities: [Team, User],
|
defineConfig({
|
||||||
tsNode: true,
|
entities: [Team, User],
|
||||||
dbName,
|
tsNode: true,
|
||||||
password: pgGodCredentials.password,
|
dbName,
|
||||||
host: pgGodCredentials.host,
|
password: pgGodCredentials.password,
|
||||||
user: pgGodCredentials.user,
|
host: pgGodCredentials.host,
|
||||||
type: "postgresql",
|
user: pgGodCredentials.user,
|
||||||
migrations: {
|
migrations: {
|
||||||
generator: CustomTsMigrationGenerator,
|
generator: CustomTsMigrationGenerator,
|
||||||
path: fileSystem.basePath,
|
path: fileSystem.basePath,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const migrator = orm.getMigrator()
|
const migrator = orm.getMigrator()
|
||||||
await migrator.createMigration()
|
await migrator.createMigration()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
||||||
const DB_USERNAME = process.env.DB_USERNAME ?? ""
|
const DB_USERNAME = process.env.DB_USERNAME ?? "postgres"
|
||||||
const DB_PASSWORD = process.env.DB_PASSWORD ?? ""
|
const DB_PASSWORD = process.env.DB_PASSWORD ?? ""
|
||||||
|
|
||||||
export const pgGodCredentials = {
|
export const pgGodCredentials = {
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import { PrimaryKeyModifier } from "./primary-key"
|
|||||||
export class NumberProperty extends BaseProperty<number> {
|
export class NumberProperty extends BaseProperty<number> {
|
||||||
protected dataType: {
|
protected dataType: {
|
||||||
name: "number"
|
name: "number"
|
||||||
options: {}
|
options: {
|
||||||
|
primaryKey?: boolean
|
||||||
|
searchable?: boolean
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,6 +33,27 @@ export class NumberProperty extends BaseProperty<number> {
|
|||||||
return new PrimaryKeyModifier<number, NumberProperty>(this)
|
return new PrimaryKeyModifier<number, NumberProperty>(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method indicates that a number property is searchable.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* import { model } from "@medusajs/framework/utils"
|
||||||
|
*
|
||||||
|
* const MyCustom = model.define("my_custom", {
|
||||||
|
* name: model.number().searchable(),
|
||||||
|
* // ...
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* export default MyCustom
|
||||||
|
*
|
||||||
|
* @customNamespace Property Configuration Methods
|
||||||
|
*/
|
||||||
|
searchable() {
|
||||||
|
this.dataType.options.searchable = true
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
constructor(options?: { primaryKey?: boolean }) {
|
constructor(options?: { primaryKey?: boolean }) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
MigrationResult,
|
MigrationResult,
|
||||||
UmzugMigration,
|
UmzugMigration,
|
||||||
} from "@mikro-orm/migrations"
|
} from "@mikro-orm/migrations"
|
||||||
import { PostgreSqlDriver } from "@mikro-orm/postgresql"
|
import { defineConfig, PostgreSqlDriver } from "@mikro-orm/postgresql"
|
||||||
import { EventEmitter } from "events"
|
import { EventEmitter } from "events"
|
||||||
import { access, mkdir, writeFile } from "fs/promises"
|
import { access, mkdir, writeFile } from "fs/promises"
|
||||||
import { dirname } from "path"
|
import { dirname } from "path"
|
||||||
@@ -42,13 +42,15 @@ export class Migrations extends EventEmitter<MigrationsEvents> {
|
|||||||
return this.#configOrConnection as MikroORM<PostgreSqlDriver>
|
return this.#configOrConnection as MikroORM<PostgreSqlDriver>
|
||||||
}
|
}
|
||||||
|
|
||||||
return await MikroORM.init({
|
return await MikroORM.init(
|
||||||
...this.#configOrConnection,
|
defineConfig({
|
||||||
migrations: {
|
...(this.#configOrConnection as any),
|
||||||
...this.#configOrConnection.migrations,
|
migrations: {
|
||||||
silent: true,
|
...this.#configOrConnection.migrations,
|
||||||
},
|
silent: true,
|
||||||
})
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+7
-7
@@ -1,13 +1,13 @@
|
|||||||
import { join } from "path"
|
|
||||||
import { MikroORM } from "@mikro-orm/postgresql"
|
|
||||||
import { MetadataStorage } from "@mikro-orm/core"
|
import { MetadataStorage } from "@mikro-orm/core"
|
||||||
import { createDatabase, dropDatabase } from "pg-god"
|
|
||||||
import { TSMigrationGenerator } from "@mikro-orm/migrations"
|
import { TSMigrationGenerator } from "@mikro-orm/migrations"
|
||||||
|
import { MikroORM } from "@mikro-orm/postgresql"
|
||||||
|
import { join } from "path"
|
||||||
|
import { createDatabase, dropDatabase } from "pg-god"
|
||||||
|
|
||||||
import { model } from "../../../dml"
|
|
||||||
import { FileSystem } from "../../../common"
|
import { FileSystem } from "../../../common"
|
||||||
import { Migrations, MigrationsEvents } from "../../index"
|
import { model } from "../../../dml"
|
||||||
import { defineMikroOrmCliConfig } from "../../../modules-sdk"
|
import { defineMikroOrmCliConfig } from "../../../modules-sdk"
|
||||||
|
import { Migrations, MigrationsEvents } from "../../index"
|
||||||
|
|
||||||
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
||||||
const DB_USERNAME = process.env.DB_USERNAME ?? ""
|
const DB_USERNAME = process.env.DB_USERNAME ?? ""
|
||||||
@@ -22,8 +22,8 @@ const migrationFileNameGenerator = (_: string, name?: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pgGodCredentials = {
|
const pgGodCredentials = {
|
||||||
user: DB_USERNAME,
|
user: DB_USERNAME ?? "postgres",
|
||||||
password: DB_PASSWORD,
|
password: DB_PASSWORD ?? "",
|
||||||
host: DB_HOST,
|
host: DB_HOST,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@ const moduleName = "myTestServiceRun"
|
|||||||
const fs = new FileSystem(join(__dirname, "./migrations-run"))
|
const fs = new FileSystem(join(__dirname, "./migrations-run"))
|
||||||
|
|
||||||
const pgGodCredentials = {
|
const pgGodCredentials = {
|
||||||
user: DB_USERNAME,
|
user: DB_USERNAME ?? "postgres",
|
||||||
password: DB_PASSWORD,
|
password: DB_PASSWORD ?? "",
|
||||||
host: DB_HOST,
|
host: DB_HOST,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ describe("defineMikroOrmCliConfig", () => {
|
|||||||
|
|
||||||
expect(config).toEqual({
|
expect(config).toEqual({
|
||||||
entities: [{}],
|
entities: [{}],
|
||||||
type: "postgresql",
|
driver: expect.any(Function),
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
user: "postgres",
|
user: "postgres",
|
||||||
password: "",
|
password: "",
|
||||||
@@ -37,7 +37,7 @@ describe("defineMikroOrmCliConfig", () => {
|
|||||||
|
|
||||||
expect(config).toEqual({
|
expect(config).toEqual({
|
||||||
entities: [{}],
|
entities: [{}],
|
||||||
type: "postgresql",
|
driver: expect.any(Function),
|
||||||
dbName: "medusa-my-test",
|
dbName: "medusa-my-test",
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
user: "postgres",
|
user: "postgres",
|
||||||
|
|||||||
@@ -2,11 +2,7 @@ import { Logger, MedusaContainer, ModulesSdkTypes } from "@medusajs/types"
|
|||||||
import { PostgreSqlDriver, SqlEntityManager } from "@mikro-orm/postgresql"
|
import { PostgreSqlDriver, SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import { ContainerRegistrationKeys, MedusaError } from "../../common"
|
import { ContainerRegistrationKeys, MedusaError } from "../../common"
|
||||||
import {
|
import { mikroOrmCreateConnection } from "../../dal"
|
||||||
FreeTextSearchFilterKey,
|
|
||||||
mikroOrmCreateConnection,
|
|
||||||
mikroOrmFreeTextSearchFilterOptionsFactory,
|
|
||||||
} from "../../dal"
|
|
||||||
import { isSharedConnectionSymbol } from "../create-pg-connection"
|
import { isSharedConnectionSymbol } from "../create-pg-connection"
|
||||||
import { loadDatabaseConfig } from "../load-module-database-config"
|
import { loadDatabaseConfig } from "../load-module-database-config"
|
||||||
|
|
||||||
@@ -39,9 +35,6 @@ export async function mikroOrmConnectionLoader({
|
|||||||
logger?: Logger
|
logger?: Logger
|
||||||
pathToMigrations: string
|
pathToMigrations: string
|
||||||
}) {
|
}) {
|
||||||
const freeTextSearchGlobalFilter =
|
|
||||||
mikroOrmFreeTextSearchFilterOptionsFactory(entities)
|
|
||||||
|
|
||||||
let manager = (
|
let manager = (
|
||||||
options as ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions
|
options as ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions
|
||||||
)?.manager
|
)?.manager
|
||||||
@@ -68,9 +61,6 @@ export async function mikroOrmConnectionLoader({
|
|||||||
return await loadShared({
|
return await loadShared({
|
||||||
database: {
|
database: {
|
||||||
...dbConfig,
|
...dbConfig,
|
||||||
filters: {
|
|
||||||
[FreeTextSearchFilterKey as string]: freeTextSearchGlobalFilter,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
container,
|
container,
|
||||||
entities,
|
entities,
|
||||||
@@ -98,9 +88,6 @@ export async function mikroOrmConnectionLoader({
|
|||||||
manager ??= await loadDefault({
|
manager ??= await loadDefault({
|
||||||
database: {
|
database: {
|
||||||
...dbConfig,
|
...dbConfig,
|
||||||
filters: {
|
|
||||||
[FreeTextSearchFilterKey as string]: freeTextSearchGlobalFilter,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
entities,
|
entities,
|
||||||
pathToMigrations,
|
pathToMigrations,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import {
|
|||||||
BaseFilterable,
|
BaseFilterable,
|
||||||
Context,
|
Context,
|
||||||
FilterQuery,
|
FilterQuery,
|
||||||
FilterQuery as InternalFilterQuery,
|
|
||||||
FindConfig,
|
FindConfig,
|
||||||
InferEntityType,
|
InferEntityType,
|
||||||
|
FilterQuery as InternalFilterQuery,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
PerformedActions,
|
PerformedActions,
|
||||||
UpsertWithReplaceConfig,
|
UpsertWithReplaceConfig,
|
||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
lowerCaseFirst,
|
lowerCaseFirst,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
} from "../common"
|
} from "../common"
|
||||||
import { FreeTextSearchFilterKey } from "../dal"
|
import { FreeTextSearchFilterKeyPrefix } from "../dal"
|
||||||
import { DmlEntity, toMikroORMEntity } from "../dml"
|
import { DmlEntity, toMikroORMEntity } from "../dml"
|
||||||
import { buildQuery } from "./build-query"
|
import { buildQuery } from "./build-query"
|
||||||
import {
|
import {
|
||||||
@@ -67,7 +67,7 @@ export function MedusaInternalService<
|
|||||||
): void {
|
): void {
|
||||||
if (isDefined(filters?.q)) {
|
if (isDefined(filters?.q)) {
|
||||||
config.filters ??= {}
|
config.filters ??= {}
|
||||||
config.filters[FreeTextSearchFilterKey] = {
|
config.filters[FreeTextSearchFilterKeyPrefix + model.name] = {
|
||||||
value: filters.q,
|
value: filters.q,
|
||||||
fromEntity: model.name,
|
fromEntity: model.name,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
EntitySchema,
|
EntitySchema,
|
||||||
MikroORMOptions,
|
MikroORMOptions,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
|
import { defineConfig } from "@mikro-orm/postgresql"
|
||||||
import { kebabCase } from "../common"
|
import { kebabCase } from "../common"
|
||||||
import { CustomTsMigrationGenerator } from "../dal"
|
import { CustomTsMigrationGenerator } from "../dal"
|
||||||
import { DmlEntity, toMikroOrmEntities } from "../dml"
|
import { DmlEntity, toMikroOrmEntities } from "../dml"
|
||||||
@@ -21,7 +22,6 @@ type Options = Partial<Omit<MikroORMOptions, "entities" | "entitiesTs">> & {
|
|||||||
|
|
||||||
type ReturnedOptions = Partial<MikroORMOptions> & {
|
type ReturnedOptions = Partial<MikroORMOptions> & {
|
||||||
entities: MikroORMOptions["entities"]
|
entities: MikroORMOptions["entities"]
|
||||||
type: MikroORMOptions["type"]
|
|
||||||
migrations: MikroORMOptions["migrations"]
|
migrations: MikroORMOptions["migrations"]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ export function defineMikroOrmCliConfig(
|
|||||||
|
|
||||||
const dmlEntities = options.entities.filter(DmlEntity.isDmlEntity)
|
const dmlEntities = options.entities.filter(DmlEntity.isDmlEntity)
|
||||||
const nonDmlEntities = options.entities.filter(
|
const nonDmlEntities = options.entities.filter(
|
||||||
(entity) => !DmlEntity.isDmlEntity(entity)
|
(entity) => entity && !DmlEntity.isDmlEntity(entity)
|
||||||
)
|
)
|
||||||
|
|
||||||
const entities = nonDmlEntities.concat(
|
const entities = nonDmlEntities.concat(
|
||||||
@@ -53,17 +53,16 @@ export function defineMikroOrmCliConfig(
|
|||||||
const normalizedModuleName = kebabCase(moduleName.replace("Service", ""))
|
const normalizedModuleName = kebabCase(moduleName.replace("Service", ""))
|
||||||
const databaseName = `medusa-${normalizedModuleName}`
|
const databaseName = `medusa-${normalizedModuleName}`
|
||||||
|
|
||||||
return {
|
return defineConfig({
|
||||||
type: "postgresql",
|
|
||||||
dbName: databaseName,
|
dbName: databaseName,
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
user: "postgres",
|
user: "postgres",
|
||||||
password: "",
|
password: "",
|
||||||
...options,
|
...(options as any),
|
||||||
entities,
|
entities,
|
||||||
migrations: {
|
migrations: {
|
||||||
generator: CustomTsMigrationGenerator,
|
generator: CustomTsMigrationGenerator,
|
||||||
...options.migrations,
|
...options.migrations,
|
||||||
},
|
},
|
||||||
}
|
}) as ReturnedOptions
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,10 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
@@ -47,10 +47,10 @@
|
|||||||
"ulid": "^2.3.0"
|
"ulid": "^2.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.0",
|
||||||
"pg": "^8.13.0"
|
"pg": "^8.13.0"
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
"vitest": "^0.32.2"
|
"vitest": "^0.32.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/icons": "^2.2.0",
|
"@medusajs/icons": "^2.3.0",
|
||||||
"@radix-ui/react-accordion": "1.2.0",
|
"@radix-ui/react-accordion": "1.2.0",
|
||||||
"@radix-ui/react-alert-dialog": "1.1.1",
|
"@radix-ui/react-alert-dialog": "1.1.1",
|
||||||
"@radix-ui/react-avatar": "1.1.0",
|
"@radix-ui/react-avatar": "1.1.0",
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"pg": "^8.13.0",
|
"pg": "^8.13.0",
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@medusajs/medusa": "^2.0.0",
|
"@medusajs/medusa": "^2.0.0",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { MikroORM, Options, SqlEntityManager } from "@mikro-orm/postgresql"
|
import {
|
||||||
|
defineConfig,
|
||||||
|
MikroORM,
|
||||||
|
Options,
|
||||||
|
SqlEntityManager,
|
||||||
|
} from "@mikro-orm/postgresql"
|
||||||
import { createDatabase, dropDatabase } from "pg-god"
|
import { createDatabase, dropDatabase } from "pg-god"
|
||||||
|
|
||||||
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
||||||
@@ -13,8 +18,8 @@ const pgGodCredentials = {
|
|||||||
|
|
||||||
export function getDatabaseURL(dbName?: string): string {
|
export function getDatabaseURL(dbName?: string): string {
|
||||||
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
const DB_HOST = process.env.DB_HOST ?? "localhost"
|
||||||
const DB_USERNAME = process.env.DB_USERNAME ?? ""
|
const DB_USERNAME = process.env.DB_USERNAME ?? "postgres"
|
||||||
const DB_PASSWORD = process.env.DB_PASSWORD
|
const DB_PASSWORD = process.env.DB_PASSWORD ?? ""
|
||||||
const DB_NAME = dbName ?? process.env.DB_TEMP_NAME
|
const DB_NAME = dbName ?? process.env.DB_TEMP_NAME
|
||||||
|
|
||||||
return `postgres://${DB_USERNAME}${
|
return `postgres://${DB_USERNAME}${
|
||||||
@@ -35,8 +40,7 @@ export function getMikroOrmConfig({
|
|||||||
}): Options {
|
}): Options {
|
||||||
const DB_URL = clientUrl ?? getDatabaseURL()
|
const DB_URL = clientUrl ?? getDatabaseURL()
|
||||||
|
|
||||||
return {
|
return defineConfig({
|
||||||
type: "postgresql",
|
|
||||||
clientUrl: DB_URL,
|
clientUrl: DB_URL,
|
||||||
entities: Object.values(mikroOrmEntities),
|
entities: Object.values(mikroOrmEntities),
|
||||||
schema: schema ?? process.env.MEDUSA_DB_SCHEMA,
|
schema: schema ?? process.env.MEDUSA_DB_SCHEMA,
|
||||||
@@ -48,7 +52,7 @@ export function getMikroOrmConfig({
|
|||||||
pathTs: pathToMigrations,
|
pathTs: pathToMigrations,
|
||||||
silent: true,
|
silent: true,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TestDatabase {
|
export interface TestDatabase {
|
||||||
|
|||||||
@@ -128,10 +128,10 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1",
|
"awilix": "^8.0.1",
|
||||||
"yalc": "1.0.0-pre.53"
|
"yalc": "1.0.0-pre.53"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,18 +2,18 @@ import {
|
|||||||
removeItemReturnActionWorkflow,
|
removeItemReturnActionWorkflow,
|
||||||
updateRequestItemReturnWorkflow,
|
updateRequestItemReturnWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import {
|
|
||||||
ContainerRegistrationKeys,
|
|
||||||
remoteQueryObjectFromString,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
refetchEntity,
|
refetchEntity,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
import {
|
||||||
|
ContainerRegistrationKeys,
|
||||||
|
remoteQueryObjectFromString,
|
||||||
|
} from "@medusajs/framework/utils"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
||||||
import { AdminPostReturnsRequestItemsActionReqSchemaType } from "../../../../../returns/validators"
|
import { AdminPostReturnsRequestItemsActionReqSchemaType } from "../../../../../returns/validators"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminPostReturnsRequestItemsActionReqSchemaType>,
|
req: AuthenticatedMedusaRequest<AdminPostReturnsRequestItemsActionReqSchemaType>,
|
||||||
@@ -29,7 +29,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
@@ -67,7 +67,10 @@ export const DELETE = async (
|
|||||||
) => {
|
) => {
|
||||||
const { id, action_id } = req.params
|
const { id, action_id } = req.params
|
||||||
|
|
||||||
const claim = await refetchEntity("order_claim", id, req.scope, ["return_id"])
|
const claim = await refetchEntity("order_claim", id, req.scope, [
|
||||||
|
"id",
|
||||||
|
"return_id",
|
||||||
|
])
|
||||||
|
|
||||||
const { result: orderPreview } = await removeItemReturnActionWorkflow(
|
const { result: orderPreview } = await removeItemReturnActionWorkflow(
|
||||||
req.scope
|
req.scope
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
||||||
import { AdminPostReturnsRequestItemsReqSchemaType } from "../../../../returns/validators"
|
import { AdminPostReturnsRequestItemsReqSchemaType } from "../../../../returns/validators"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminPostReturnsRequestItemsReqSchemaType>,
|
req: AuthenticatedMedusaRequest<AdminPostReturnsRequestItemsReqSchemaType>,
|
||||||
@@ -26,7 +26,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
@@ -41,10 +41,11 @@ export const POST = async (
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const returnId = result.order_change.return_id
|
||||||
const queryObject = remoteQueryObjectFromString({
|
const queryObject = remoteQueryObjectFromString({
|
||||||
entryPoint: "return",
|
entryPoint: "return",
|
||||||
variables: {
|
variables: {
|
||||||
id: claim.return_id,
|
id: returnId,
|
||||||
},
|
},
|
||||||
fields: defaultAdminDetailsReturnFields,
|
fields: defaultAdminDetailsReturnFields,
|
||||||
})
|
})
|
||||||
|
|||||||
+6
-6
@@ -2,17 +2,17 @@ import {
|
|||||||
removeClaimShippingMethodWorkflow,
|
removeClaimShippingMethodWorkflow,
|
||||||
updateReturnShippingMethodWorkflow,
|
updateReturnShippingMethodWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import {
|
|
||||||
ContainerRegistrationKeys,
|
|
||||||
remoteQueryObjectFromString,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
import {
|
||||||
|
ContainerRegistrationKeys,
|
||||||
|
remoteQueryObjectFromString,
|
||||||
|
} from "@medusajs/framework/utils"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
||||||
import { AdminPostClaimsShippingActionReqSchemaType } from "../../../../validators"
|
import { AdminPostClaimsShippingActionReqSchemaType } from "../../../../validators"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingActionReqSchemaType>,
|
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingActionReqSchemaType>,
|
||||||
@@ -28,7 +28,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
||||||
import { AdminPostReturnsShippingReqSchemaType } from "../../../../returns/validators"
|
import { AdminPostReturnsShippingReqSchemaType } from "../../../../returns/validators"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminPostReturnsShippingReqSchemaType>,
|
req: AuthenticatedMedusaRequest<AdminPostReturnsShippingReqSchemaType>,
|
||||||
@@ -26,7 +26,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
@@ -41,10 +41,11 @@ export const POST = async (
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const returnId = result.order_change.return_id
|
||||||
const queryObject = remoteQueryObjectFromString({
|
const queryObject = remoteQueryObjectFromString({
|
||||||
entryPoint: "return",
|
entryPoint: "return",
|
||||||
variables: {
|
variables: {
|
||||||
id: claim.return_id,
|
id: returnId,
|
||||||
},
|
},
|
||||||
fields: defaultAdminDetailsReturnFields,
|
fields: defaultAdminDetailsReturnFields,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ import {
|
|||||||
removeItemReturnActionWorkflow,
|
removeItemReturnActionWorkflow,
|
||||||
updateRequestItemReturnWorkflow,
|
updateRequestItemReturnWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
|
||||||
import {
|
|
||||||
ContainerRegistrationKeys,
|
|
||||||
remoteQueryObjectFromString,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
refetchEntity,
|
refetchEntity,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
import {
|
||||||
|
ContainerRegistrationKeys,
|
||||||
|
remoteQueryObjectFromString,
|
||||||
|
} from "@medusajs/framework/utils"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
||||||
import { AdminPostExchangesRequestItemsReturnActionReqSchemaType } from "../../../../validators"
|
import { AdminPostExchangesRequestItemsReturnActionReqSchemaType } from "../../../../validators"
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
||||||
import { AdminPostExchangesReturnRequestItemsReqSchemaType } from "../../../validators"
|
import { AdminPostExchangesReturnRequestItemsReqSchemaType } from "../../../validators"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminPostExchangesReturnRequestItemsReqSchemaType>,
|
req: AuthenticatedMedusaRequest<AdminPostExchangesReturnRequestItemsReqSchemaType>,
|
||||||
@@ -26,7 +26,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
@@ -43,10 +43,11 @@ export const POST = async (
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const returnId = result.order_change.return_id
|
||||||
const queryObject = remoteQueryObjectFromString({
|
const queryObject = remoteQueryObjectFromString({
|
||||||
entryPoint: "return",
|
entryPoint: "return",
|
||||||
variables: {
|
variables: {
|
||||||
id: exchange.return_id,
|
id: returnId,
|
||||||
},
|
},
|
||||||
fields: defaultAdminDetailsReturnFields,
|
fields: defaultAdminDetailsReturnFields,
|
||||||
})
|
})
|
||||||
|
|||||||
+7
-7
@@ -2,17 +2,17 @@ import {
|
|||||||
removeReturnShippingMethodWorkflow,
|
removeReturnShippingMethodWorkflow,
|
||||||
updateReturnShippingMethodWorkflow,
|
updateReturnShippingMethodWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import {
|
|
||||||
ContainerRegistrationKeys,
|
|
||||||
remoteQueryObjectFromString,
|
|
||||||
} from "@medusajs/framework/utils"
|
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { AdminOrderPreview, HttpTypes } from "@medusajs/framework/types"
|
||||||
|
import {
|
||||||
|
ContainerRegistrationKeys,
|
||||||
|
remoteQueryObjectFromString,
|
||||||
|
} from "@medusajs/framework/utils"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
||||||
import { AdminPostExchangesShippingActionReqSchemaType } from "../../../../validators"
|
import { AdminPostExchangesShippingActionReqSchemaType } from "../../../../validators"
|
||||||
import { AdminOrderPreview, HttpTypes } from "@medusajs/framework/types"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingActionReqSchemaType>,
|
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingActionReqSchemaType>,
|
||||||
@@ -28,7 +28,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
@@ -76,7 +76,7 @@ export const DELETE = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
||||||
import { AdminPostReturnsShippingReqSchemaType } from "../../../../returns/validators"
|
import { AdminPostReturnsShippingReqSchemaType } from "../../../../returns/validators"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminPostReturnsShippingReqSchemaType>,
|
req: AuthenticatedMedusaRequest<AdminPostReturnsShippingReqSchemaType>,
|
||||||
@@ -26,7 +26,7 @@ export const POST = async (
|
|||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
fields: ["return_id"],
|
fields: ["id", "return_id"],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
throwIfKeyNotFound: true,
|
throwIfKeyNotFound: true,
|
||||||
@@ -41,10 +41,11 @@ export const POST = async (
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const returnId = result.order_change.return_id
|
||||||
const queryObject = remoteQueryObjectFromString({
|
const queryObject = remoteQueryObjectFromString({
|
||||||
entryPoint: "return",
|
entryPoint: "return",
|
||||||
variables: {
|
variables: {
|
||||||
id: exchange.return_id,
|
id: returnId,
|
||||||
},
|
},
|
||||||
fields: defaultAdminDetailsReturnFields,
|
fields: defaultAdminDetailsReturnFields,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -30,15 +30,15 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
||||||
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
"migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
||||||
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -48,9 +48,9 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,18 +30,18 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --runInBand --bail --passWithNoTests --forceExit -- src",
|
"test": "jest --runInBand --bail --passWithNoTests --forceExit -- src",
|
||||||
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
"migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
||||||
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -51,9 +51,9 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,18 +30,18 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --runInBand --bail --passWithNoTests --forceExit -- src",
|
"test": "jest --runInBand --bail --passWithNoTests --forceExit -- src",
|
||||||
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
"migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
||||||
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -51,9 +51,9 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,18 +30,18 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
||||||
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
"migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
||||||
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -51,9 +51,9 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,19 +30,19 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --runInBand --bail --passWithNoTests --forceExit -- src",
|
"test": "jest --runInBand --bail --passWithNoTests --forceExit -- src",
|
||||||
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
"migration:generate": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:generate",
|
"migration:generate": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:generate",
|
||||||
"migration:initial": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
"migration:initial": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
||||||
"migration:create": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -52,9 +52,9 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,18 +30,18 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --passWithNoTests --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
"test": "jest --passWithNoTests --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
||||||
"test:integration": "jest --passWithNoTests --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
"test:integration": "jest --passWithNoTests --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
"migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
||||||
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
|
|||||||
+4
-4
@@ -137,7 +137,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
|||||||
{
|
{
|
||||||
attribute: "test-attribute",
|
attribute: "test-attribute",
|
||||||
operator: "in",
|
operator: "in",
|
||||||
value: ["test"],
|
value: ["true"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@@ -161,7 +161,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
|||||||
{
|
{
|
||||||
attribute: "test-attribute",
|
attribute: "test-attribute",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
value: "test",
|
value: "true",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
attribute: "test-attribute2.options",
|
attribute: "test-attribute2.options",
|
||||||
@@ -174,7 +174,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
|||||||
|
|
||||||
let listedOptions = await service.listShippingOptionsForContext({
|
let listedOptions = await service.listShippingOptionsForContext({
|
||||||
context: {
|
context: {
|
||||||
"test-attribute": "test",
|
"test-attribute": "true",
|
||||||
"test-attribute2": {
|
"test-attribute2": {
|
||||||
options: "test2",
|
options: "test2",
|
||||||
},
|
},
|
||||||
@@ -774,7 +774,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
|||||||
rules: expect.arrayContaining([
|
rules: expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: existingRule.id,
|
id: existingRule.id,
|
||||||
value: '"false"',
|
value: "false",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
|
|||||||
@@ -30,18 +30,18 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --runInBand --bail --forceExit --passWithNoTests -- src",
|
"test": "jest --runInBand --bail --forceExit --passWithNoTests -- src",
|
||||||
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.spec.ts",
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.spec.ts",
|
||||||
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration",
|
"migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration",
|
||||||
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -51,9 +51,9 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,6 +154,7 @@
|
|||||||
"keyName": "IDX_fulfillment_address_deleted_at",
|
"keyName": "IDX_fulfillment_address_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_address_deleted_at\" ON \"fulfillment_address\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_address_deleted_at\" ON \"fulfillment_address\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -164,12 +165,14 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {}
|
"foreignKeys": {},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -232,6 +235,7 @@
|
|||||||
"keyName": "IDX_fulfillment_provider_deleted_at",
|
"keyName": "IDX_fulfillment_provider_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_provider_deleted_at\" ON \"fulfillment_provider\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_provider_deleted_at\" ON \"fulfillment_provider\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -242,12 +246,14 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {}
|
"foreignKeys": {},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -327,6 +333,7 @@
|
|||||||
"keyName": "IDX_fulfillment_set_deleted_at",
|
"keyName": "IDX_fulfillment_set_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_set_deleted_at\" ON \"fulfillment_set\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_set_deleted_at\" ON \"fulfillment_set\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -335,6 +342,7 @@
|
|||||||
"keyName": "IDX_fulfillment_set_name_unique",
|
"keyName": "IDX_fulfillment_set_name_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_fulfillment_set_name_unique\" ON \"fulfillment_set\" (name) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_fulfillment_set_name_unique\" ON \"fulfillment_set\" (name) WHERE deleted_at IS NULL"
|
||||||
@@ -345,12 +353,14 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {}
|
"foreignKeys": {},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -430,6 +440,7 @@
|
|||||||
"keyName": "IDX_service_zone_fulfillment_set_id",
|
"keyName": "IDX_service_zone_fulfillment_set_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_service_zone_fulfillment_set_id\" ON \"service_zone\" (fulfillment_set_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_service_zone_fulfillment_set_id\" ON \"service_zone\" (fulfillment_set_id) WHERE deleted_at IS NULL"
|
||||||
@@ -438,6 +449,7 @@
|
|||||||
"keyName": "IDX_service_zone_deleted_at",
|
"keyName": "IDX_service_zone_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_service_zone_deleted_at\" ON \"service_zone\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_service_zone_deleted_at\" ON \"service_zone\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -446,6 +458,7 @@
|
|||||||
"keyName": "IDX_service_zone_name_unique",
|
"keyName": "IDX_service_zone_name_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_service_zone_name_unique\" ON \"service_zone\" (name) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_service_zone_name_unique\" ON \"service_zone\" (name) WHERE deleted_at IS NULL"
|
||||||
@@ -456,6 +469,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
@@ -475,7 +489,8 @@
|
|||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -598,6 +613,7 @@
|
|||||||
"keyName": "IDX_geo_zone_service_zone_id",
|
"keyName": "IDX_geo_zone_service_zone_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_service_zone_id\" ON \"geo_zone\" (service_zone_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_service_zone_id\" ON \"geo_zone\" (service_zone_id) WHERE deleted_at IS NULL"
|
||||||
@@ -606,6 +622,7 @@
|
|||||||
"keyName": "IDX_geo_zone_deleted_at",
|
"keyName": "IDX_geo_zone_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_deleted_at\" ON \"geo_zone\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_deleted_at\" ON \"geo_zone\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -614,6 +631,7 @@
|
|||||||
"keyName": "IDX_geo_zone_country_code",
|
"keyName": "IDX_geo_zone_country_code",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_country_code\" ON \"geo_zone\" (country_code) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_country_code\" ON \"geo_zone\" (country_code) WHERE deleted_at IS NULL"
|
||||||
@@ -622,6 +640,7 @@
|
|||||||
"keyName": "IDX_geo_zone_province_code",
|
"keyName": "IDX_geo_zone_province_code",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_province_code\" ON \"geo_zone\" (province_code) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_province_code\" ON \"geo_zone\" (province_code) WHERE deleted_at IS NULL"
|
||||||
@@ -630,6 +649,7 @@
|
|||||||
"keyName": "IDX_geo_zone_city",
|
"keyName": "IDX_geo_zone_city",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_city\" ON \"geo_zone\" (city) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_city\" ON \"geo_zone\" (city) WHERE deleted_at IS NULL"
|
||||||
@@ -640,6 +660,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
@@ -659,7 +680,8 @@
|
|||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -739,6 +761,7 @@
|
|||||||
"keyName": "IDX_shipping_option_type_deleted_at",
|
"keyName": "IDX_shipping_option_type_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_type_deleted_at\" ON \"shipping_option_type\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_type_deleted_at\" ON \"shipping_option_type\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -749,12 +772,14 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {}
|
"foreignKeys": {},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -834,6 +859,7 @@
|
|||||||
"keyName": "IDX_shipping_profile_deleted_at",
|
"keyName": "IDX_shipping_profile_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_profile_deleted_at\" ON \"shipping_profile\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_profile_deleted_at\" ON \"shipping_profile\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -842,6 +868,7 @@
|
|||||||
"keyName": "IDX_shipping_profile_name_unique",
|
"keyName": "IDX_shipping_profile_name_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_shipping_profile_name_unique\" ON \"shipping_profile\" (name) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_shipping_profile_name_unique\" ON \"shipping_profile\" (name) WHERE deleted_at IS NULL"
|
||||||
@@ -852,12 +879,14 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {}
|
"foreignKeys": {},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -983,10 +1012,21 @@
|
|||||||
"name": "shipping_option",
|
"name": "shipping_option",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"columnNames": [
|
||||||
|
"shipping_option_type_id"
|
||||||
|
],
|
||||||
|
"composite": false,
|
||||||
|
"keyName": "shipping_option_shipping_option_type_id_unique",
|
||||||
|
"constraint": true,
|
||||||
|
"primary": false,
|
||||||
|
"unique": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_shipping_option_service_zone_id",
|
"keyName": "IDX_shipping_option_service_zone_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_service_zone_id\" ON \"shipping_option\" (service_zone_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_service_zone_id\" ON \"shipping_option\" (service_zone_id) WHERE deleted_at IS NULL"
|
||||||
@@ -995,14 +1035,25 @@
|
|||||||
"keyName": "IDX_shipping_option_shipping_profile_id",
|
"keyName": "IDX_shipping_option_shipping_profile_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_shipping_profile_id\" ON \"shipping_option\" (shipping_profile_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_shipping_profile_id\" ON \"shipping_option\" (shipping_profile_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_shipping_option_provider_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_provider_id\" ON \"shipping_option\" (provider_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_shipping_option_deleted_at",
|
"keyName": "IDX_shipping_option_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_deleted_at\" ON \"shipping_option\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_deleted_at\" ON \"shipping_option\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -1013,6 +1064,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
@@ -1044,8 +1096,34 @@
|
|||||||
"referencedTableName": "public.shipping_profile",
|
"referencedTableName": "public.shipping_profile",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
|
},
|
||||||
|
"shipping_option_provider_id_foreign": {
|
||||||
|
"constraintName": "shipping_option_provider_id_foreign",
|
||||||
|
"columnNames": [
|
||||||
|
"provider_id"
|
||||||
|
],
|
||||||
|
"localTableName": "public.shipping_option",
|
||||||
|
"referencedColumnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"referencedTableName": "public.fulfillment_provider",
|
||||||
|
"deleteRule": "set null",
|
||||||
|
"updateRule": "cascade"
|
||||||
|
},
|
||||||
|
"shipping_option_shipping_option_type_id_foreign": {
|
||||||
|
"constraintName": "shipping_option_shipping_option_type_id_foreign",
|
||||||
|
"columnNames": [
|
||||||
|
"shipping_option_type_id"
|
||||||
|
],
|
||||||
|
"localTableName": "public.shipping_option",
|
||||||
|
"referencedColumnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"referencedTableName": "public.shipping_option_type",
|
||||||
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -1144,6 +1222,7 @@
|
|||||||
"keyName": "IDX_shipping_option_rule_shipping_option_id",
|
"keyName": "IDX_shipping_option_rule_shipping_option_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_rule_shipping_option_id\" ON \"shipping_option_rule\" (shipping_option_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_rule_shipping_option_id\" ON \"shipping_option_rule\" (shipping_option_id) WHERE deleted_at IS NULL"
|
||||||
@@ -1152,6 +1231,7 @@
|
|||||||
"keyName": "IDX_shipping_option_rule_deleted_at",
|
"keyName": "IDX_shipping_option_rule_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_rule_deleted_at\" ON \"shipping_option_rule\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_rule_deleted_at\" ON \"shipping_option_rule\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -1162,6 +1242,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
@@ -1181,7 +1262,8 @@
|
|||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -1352,10 +1434,31 @@
|
|||||||
"name": "fulfillment",
|
"name": "fulfillment",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"columnNames": [
|
||||||
|
"provider_id"
|
||||||
|
],
|
||||||
|
"composite": false,
|
||||||
|
"keyName": "fulfillment_provider_id_unique",
|
||||||
|
"constraint": true,
|
||||||
|
"primary": false,
|
||||||
|
"unique": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columnNames": [
|
||||||
|
"delivery_address_id"
|
||||||
|
],
|
||||||
|
"composite": false,
|
||||||
|
"keyName": "fulfillment_delivery_address_id_unique",
|
||||||
|
"constraint": true,
|
||||||
|
"primary": false,
|
||||||
|
"unique": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_fulfillment_shipping_option_id",
|
"keyName": "IDX_fulfillment_shipping_option_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_shipping_option_id\" ON \"fulfillment\" (shipping_option_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_shipping_option_id\" ON \"fulfillment\" (shipping_option_id) WHERE deleted_at IS NULL"
|
||||||
@@ -1364,6 +1467,7 @@
|
|||||||
"keyName": "IDX_fulfillment_deleted_at",
|
"keyName": "IDX_fulfillment_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_deleted_at\" ON \"fulfillment\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_deleted_at\" ON \"fulfillment\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -1372,6 +1476,7 @@
|
|||||||
"keyName": "IDX_fulfillment_location_id",
|
"keyName": "IDX_fulfillment_location_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_location_id\" ON \"fulfillment\" (location_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_location_id\" ON \"fulfillment\" (location_id) WHERE deleted_at IS NULL"
|
||||||
@@ -1382,12 +1487,26 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
|
"fulfillment_provider_id_foreign": {
|
||||||
|
"constraintName": "fulfillment_provider_id_foreign",
|
||||||
|
"columnNames": [
|
||||||
|
"provider_id"
|
||||||
|
],
|
||||||
|
"localTableName": "public.fulfillment",
|
||||||
|
"referencedColumnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"referencedTableName": "public.fulfillment_provider",
|
||||||
|
"deleteRule": "set null",
|
||||||
|
"updateRule": "cascade"
|
||||||
|
},
|
||||||
"fulfillment_shipping_option_id_foreign": {
|
"fulfillment_shipping_option_id_foreign": {
|
||||||
"constraintName": "fulfillment_shipping_option_id_foreign",
|
"constraintName": "fulfillment_shipping_option_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
@@ -1400,8 +1519,22 @@
|
|||||||
"referencedTableName": "public.shipping_option",
|
"referencedTableName": "public.shipping_option",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
|
},
|
||||||
|
"fulfillment_delivery_address_id_foreign": {
|
||||||
|
"constraintName": "fulfillment_delivery_address_id_foreign",
|
||||||
|
"columnNames": [
|
||||||
|
"delivery_address_id"
|
||||||
|
],
|
||||||
|
"localTableName": "public.fulfillment",
|
||||||
|
"referencedColumnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"referencedTableName": "public.fulfillment_address",
|
||||||
|
"deleteRule": "set null",
|
||||||
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -1490,6 +1623,7 @@
|
|||||||
"keyName": "IDX_fulfillment_label_fulfillment_id",
|
"keyName": "IDX_fulfillment_label_fulfillment_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_label_fulfillment_id\" ON \"fulfillment_label\" (fulfillment_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_label_fulfillment_id\" ON \"fulfillment_label\" (fulfillment_id) WHERE deleted_at IS NULL"
|
||||||
@@ -1498,6 +1632,7 @@
|
|||||||
"keyName": "IDX_fulfillment_label_deleted_at",
|
"keyName": "IDX_fulfillment_label_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_label_deleted_at\" ON \"fulfillment_label\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_label_deleted_at\" ON \"fulfillment_label\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -1508,6 +1643,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
@@ -1527,7 +1663,8 @@
|
|||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -1652,6 +1789,7 @@
|
|||||||
"keyName": "IDX_fulfillment_item_fulfillment_id",
|
"keyName": "IDX_fulfillment_item_fulfillment_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_fulfillment_id\" ON \"fulfillment_item\" (fulfillment_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_fulfillment_id\" ON \"fulfillment_item\" (fulfillment_id) WHERE deleted_at IS NULL"
|
||||||
@@ -1660,6 +1798,7 @@
|
|||||||
"keyName": "IDX_fulfillment_item_deleted_at",
|
"keyName": "IDX_fulfillment_item_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_deleted_at\" ON \"fulfillment_item\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_deleted_at\" ON \"fulfillment_item\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -1668,6 +1807,7 @@
|
|||||||
"keyName": "IDX_fulfillment_item_inventory_item_id",
|
"keyName": "IDX_fulfillment_item_inventory_item_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_inventory_item_id\" ON \"fulfillment_item\" (inventory_item_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_inventory_item_id\" ON \"fulfillment_item\" (inventory_item_id) WHERE deleted_at IS NULL"
|
||||||
@@ -1676,6 +1816,7 @@
|
|||||||
"keyName": "IDX_fulfillment_item_line_item_id",
|
"keyName": "IDX_fulfillment_item_line_item_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_line_item_id\" ON \"fulfillment_item\" (line_item_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_item_line_item_id\" ON \"fulfillment_item\" (line_item_id) WHERE deleted_at IS NULL"
|
||||||
@@ -1686,6 +1827,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
@@ -1705,7 +1847,9 @@
|
|||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"nativeEnums": {}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20250113122235 extends Migration {
|
||||||
|
override async up(): Promise<void> {
|
||||||
|
this.addSql(`
|
||||||
|
UPDATE shipping_option_rule
|
||||||
|
SET value = 'true'::jsonb
|
||||||
|
WHERE value = '"true"'::jsonb;
|
||||||
|
`)
|
||||||
|
this.addSql(`
|
||||||
|
UPDATE shipping_option_rule
|
||||||
|
SET value = 'false'::jsonb
|
||||||
|
WHERE value = '"false"'::jsonb;
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
override async down(): Promise<void> {
|
||||||
|
this.addSql(`
|
||||||
|
UPDATE shipping_option_rule
|
||||||
|
SET value = '"true"'::jsonb
|
||||||
|
WHERE value = 'true'::jsonb;
|
||||||
|
`)
|
||||||
|
this.addSql(`
|
||||||
|
UPDATE shipping_option_rule
|
||||||
|
SET value = '"false"'::jsonb
|
||||||
|
WHERE value = 'false'::jsonb;
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -146,12 +146,12 @@ export function validateRule(rule: Record<string, unknown>): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeRulesValue<T extends Partial<Rule>>(rules: T[]): void {
|
export function normalizeRulesValue<T extends Partial<Rule>>(rules: T[]): void {
|
||||||
rules.forEach((rule) => {
|
rules.forEach((rule: any) => {
|
||||||
/**
|
/**
|
||||||
* If a string is provided, then we don't want jsonb to convert to the primitive value based on the RFC
|
* If a boolean is provided, then we convert to string
|
||||||
*/
|
*/
|
||||||
if (rule.value === "true" || rule.value === "false") {
|
if (rule.value === true || rule.value === false) {
|
||||||
rule.value = rule.value === "true" ? '"true"' : '"false"'
|
rule.value = rule.value === true ? "true" : "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
return rule
|
return rule
|
||||||
|
|||||||
@@ -722,57 +722,11 @@ describe("IndexModuleService", function () {
|
|||||||
it("should consume all deleted events and delete the index entries", async () => {
|
it("should consume all deleted events and delete the index entries", async () => {
|
||||||
const indexEntries = await manager.find(toMikroORMEntity(IndexData), {})
|
const indexEntries = await manager.find(toMikroORMEntity(IndexData), {})
|
||||||
const indexRelationEntries = await manager.find(
|
const indexRelationEntries = await manager.find(
|
||||||
toMikroORMEntity(IndexRelation),
|
toMikroORMEntity(IndexRelation)
|
||||||
{},
|
|
||||||
{
|
|
||||||
populate: ["parent", "child"],
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(indexEntries).toHaveLength(3)
|
expect(indexEntries).toHaveLength(3)
|
||||||
expect(indexRelationEntries).toHaveLength(2)
|
expect(indexRelationEntries).toHaveLength(2)
|
||||||
|
|
||||||
const linkIndexEntry = indexEntries.find((entry) => {
|
|
||||||
return (
|
|
||||||
entry.name === "LinkProductVariantPriceSet" && entry.id === linkId
|
|
||||||
)
|
|
||||||
})!
|
|
||||||
|
|
||||||
const priceSetIndexEntry = indexEntries.find((entry) => {
|
|
||||||
return entry.name === "PriceSet" && entry.id === priceSetId
|
|
||||||
})!
|
|
||||||
|
|
||||||
const priceIndexEntry = indexEntries.find((entry) => {
|
|
||||||
return entry.name === "Price" && entry.id === priceId
|
|
||||||
})!
|
|
||||||
|
|
||||||
const linkPriceSetIndexRelationEntry = indexRelationEntries.find(
|
|
||||||
(entry) => {
|
|
||||||
return (
|
|
||||||
entry.parent_id === linkId &&
|
|
||||||
entry.parent_name === "LinkProductVariantPriceSet" &&
|
|
||||||
entry.child_id === priceSetId &&
|
|
||||||
entry.child_name === "PriceSet"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)!
|
|
||||||
|
|
||||||
expect(linkPriceSetIndexRelationEntry.parent).toEqual(linkIndexEntry)
|
|
||||||
expect(linkPriceSetIndexRelationEntry.child).toEqual(priceSetIndexEntry)
|
|
||||||
|
|
||||||
const priceSetPriceIndexRelationEntry = indexRelationEntries.find(
|
|
||||||
(entry) => {
|
|
||||||
return (
|
|
||||||
entry.parent_id === priceSetId &&
|
|
||||||
entry.parent_name === "PriceSet" &&
|
|
||||||
entry.child_id === priceId &&
|
|
||||||
entry.child_name === "Price"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)!
|
|
||||||
|
|
||||||
expect(priceSetPriceIndexRelationEntry.parent).toEqual(priceSetIndexEntry)
|
|
||||||
expect(priceSetPriceIndexRelationEntry.child).toEqual(priceIndexEntry)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -30,19 +30,19 @@
|
|||||||
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
||||||
"test": "jest --passWithNoTests ./src",
|
"test": "jest --passWithNoTests ./src",
|
||||||
"test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
"test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
"migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
|
||||||
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
"migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
|
||||||
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
"migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
|
||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/framework": "^2.3.1",
|
"@medusajs/framework": "^2.3.1",
|
||||||
"@medusajs/test-utils": "^2.3.1",
|
"@medusajs/test-utils": "^2.3.1",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"@swc/core": "^1.7.28",
|
"@swc/core": "^1.7.28",
|
||||||
"@swc/jest": "^0.2.36",
|
"@swc/jest": "^0.2.36",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
@@ -52,10 +52,10 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/framework": "^2.0.0",
|
"@medusajs/framework": "^2.0.0",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "6.4.3",
|
||||||
"@mikro-orm/knex": "5.9.7",
|
"@mikro-orm/knex": "6.4.3",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "6.4.3",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "6.4.3",
|
||||||
"awilix": "^8.0.1"
|
"awilix": "^8.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loaded 100 of 178 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user