diff --git a/.changeset/fair-ants-heal.md b/.changeset/fair-ants-heal.md new file mode 100644 index 0000000000000..2219b8b8f218c --- /dev/null +++ b/.changeset/fair-ants-heal.md @@ -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 diff --git a/integration-tests/http/__tests__/cart/store/cart.spec.ts b/integration-tests/http/__tests__/cart/store/cart.spec.ts index 003f322c2054e..9ea0690af79b9 100644 --- a/integration-tests/http/__tests__/cart/store/cart.spec.ts +++ b/integration-tests/http/__tests__/cart/store/cart.spec.ts @@ -388,7 +388,7 @@ medusaIntegrationTestRunner({ rules: [ { attribute: "enabled_in_store", - value: '"true"', + value: "true", operator: "eq", }, { @@ -1779,7 +1779,7 @@ medusaIntegrationTestRunner({ rules: [ { attribute: "enabled_in_store", - value: '"true"', + value: "true", operator: "eq", }, { @@ -2150,7 +2150,7 @@ medusaIntegrationTestRunner({ rules: [ { attribute: "enabled_in_store", - value: '"true"', + value: "true", operator: "eq", }, { diff --git a/integration-tests/http/__tests__/customer-group/admin/customer-group.spec.ts b/integration-tests/http/__tests__/customer-group/admin/customer-group.spec.ts index 9764af10891b0..0616a9be1196c 100644 --- a/integration-tests/http/__tests__/customer-group/admin/customer-group.spec.ts +++ b/integration-tests/http/__tests__/customer-group/admin/customer-group.spec.ts @@ -69,7 +69,6 @@ medusaIntegrationTestRunner({ await api .post("/admin/customer-groups", payload, adminHeaders) .catch((err) => { - console.log(err) // BREAKING: Duplicate error is now 400 expect(err.response.status).toEqual(400) expect(err.response.data.type).toEqual("invalid_data") diff --git a/integration-tests/http/__tests__/exchanges/exchanges.spec.ts b/integration-tests/http/__tests__/exchanges/exchanges.spec.ts index 0dd8cd4b07183..50ab7f65d9892 100644 --- a/integration-tests/http/__tests__/exchanges/exchanges.spec.ts +++ b/integration-tests/http/__tests__/exchanges/exchanges.spec.ts @@ -1,16 +1,16 @@ +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { ContainerRegistrationKeys, Modules, RuleOperator, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { adminHeaders, createAdminUser, } from "../../../helpers/create-admin-user" import { setupTaxStructure } from "../../../modules/__tests__/fixtures/tax" -jest.setTimeout(30000) +jest.setTimeout(300000) medusaIntegrationTestRunner({ testSuite: ({ dbConnection, getContainer, api }) => { diff --git a/integration-tests/http/__tests__/order/admin/rma-flows.spec.ts b/integration-tests/http/__tests__/order/admin/rma-flows.spec.ts index c3b42a3d8a6fe..58354afa7beba 100644 --- a/integration-tests/http/__tests__/order/admin/rma-flows.spec.ts +++ b/integration-tests/http/__tests__/order/admin/rma-flows.spec.ts @@ -1,5 +1,5 @@ -import { ClaimType, Modules, RuleOperator } from "@medusajs/utils" import { medusaIntegrationTestRunner } from "@medusajs/test-utils" +import { ClaimType, Modules, RuleOperator } from "@medusajs/utils" import { adminHeaders, createAdminUser, @@ -7,7 +7,7 @@ import { import { setupTaxStructure } from "../../../../modules/__tests__/fixtures" import { createOrderSeeder } from "../../fixtures/order" -jest.setTimeout(30000) +jest.setTimeout(300000) medusaIntegrationTestRunner({ testSuite: ({ dbConnection, getContainer, api }) => { @@ -268,6 +268,7 @@ medusaIntegrationTestRunner({ { items: [ { + title: "new ITEM", variant_id: order.items[0].variant_id, quantity: 1, }, @@ -480,6 +481,7 @@ medusaIntegrationTestRunner({ { items: [ { + title: "Test item 2", variant_id: order.items[0].variant_id, quantity: 1, }, @@ -551,7 +553,7 @@ medusaIntegrationTestRunner({ }) ) - inboundItem = orderResult.items[0] + inboundItem = orderResult.items[1] await api.post( `/admin/claims/${claimWithInboundAndOutbound.id}/inbound/items`, diff --git a/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts b/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts index 3274f93a05584..1c4c3e0fafbef 100644 --- a/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts +++ b/integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts @@ -968,6 +968,7 @@ medusaIntegrationTestRunner({ sales_channel_id: expect.stringContaining("sc_"), currency_code: "usd", region_id: expect.stringContaining("reg_"), + shipping_address: null, item_total: 0, total: 0, email: null, diff --git a/integration-tests/modules/__tests__/link-modules/index.ts b/integration-tests/modules/__tests__/link-modules/index.ts index cf5e8183c0a3c..4eb5d71b0c422 100644 --- a/integration-tests/modules/__tests__/link-modules/index.ts +++ b/integration-tests/modules/__tests__/link-modules/index.ts @@ -1,7 +1,7 @@ import { getMigrationPlanner, initialize } from "@medusajs/link-modules" import { MedusaModule } from "@medusajs/modules-sdk" -import { ModuleJoinerConfig } from "@medusajs/types" import { medusaIntegrationTestRunner } from "@medusajs/test-utils" +import { ModuleJoinerConfig } from "@medusajs/types" jest.setTimeout(5000000) @@ -74,6 +74,7 @@ medusaIntegrationTestRunner({ const planner = getMigrationPlanner(dbConfig, linkDefinition) await planner.executePlan(await planner.createPlan()) + links = await initialize(dbConfig, linkDefinition) }) diff --git a/integration-tests/modules/__tests__/order/draft-order.spec.ts b/integration-tests/modules/__tests__/order/draft-order.spec.ts index e11bf06c43ed3..78d35f1985757 100644 --- a/integration-tests/modules/__tests__/order/draft-order.spec.ts +++ b/integration-tests/modules/__tests__/order/draft-order.spec.ts @@ -236,7 +236,7 @@ medusaIntegrationTestRunner({ summary: expect.objectContaining({ // TODO: add summary fields }), - items: [ + items: expect.arrayContaining([ expect.objectContaining({ title: "Test variant", subtitle: "Test product", @@ -335,7 +335,7 @@ medusaIntegrationTestRunner({ value: "1", }), }), - ], + ]), shipping_address: expect.objectContaining({ last_name: "Test", address_1: "Test", diff --git a/integration-tests/modules/__tests__/order/order.spec.ts b/integration-tests/modules/__tests__/order/order.spec.ts index cbe798789f093..7d923b7f9842d 100644 --- a/integration-tests/modules/__tests__/order/order.spec.ts +++ b/integration-tests/modules/__tests__/order/order.spec.ts @@ -362,6 +362,7 @@ medusaIntegrationTestRunner({ metadata: null, created_at: expect.any(String), updated_at: expect.any(String), + deleted_at: null, }, billing_address: { id: expect.any(String), @@ -379,6 +380,7 @@ medusaIntegrationTestRunner({ metadata: null, created_at: expect.any(String), updated_at: expect.any(String), + deleted_at: null, }, shipping_methods: [ expect.objectContaining({ diff --git a/integration-tests/modules/__tests__/order/workflows/begin-order-claim.spec.ts b/integration-tests/modules/__tests__/order/workflows/begin-order-claim.spec.ts index c8334e3d90b2a..98e45ab9c561a 100644 --- a/integration-tests/modules/__tests__/order/workflows/begin-order-claim.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/begin-order-claim.spec.ts @@ -3,6 +3,7 @@ import { createShippingOptionsWorkflow, orderClaimRequestItemReturnWorkflow, } from "@medusajs/core-flows" +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { FulfillmentWorkflow, IOrderModuleService, @@ -19,7 +20,6 @@ import { RuleOperator, remoteQueryObjectFromString, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" jest.setTimeout(500000) @@ -186,7 +186,7 @@ async function prepareDataFixtures({ container }) { { attribute: "is_return", operator: RuleOperator.EQ, - value: '"true"', + value: "true", }, ], } diff --git a/integration-tests/modules/__tests__/order/workflows/begin-order-exchange.spec.ts b/integration-tests/modules/__tests__/order/workflows/begin-order-exchange.spec.ts index aa0caf90b27d0..9ae2091252bfd 100644 --- a/integration-tests/modules/__tests__/order/workflows/begin-order-exchange.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/begin-order-exchange.spec.ts @@ -4,6 +4,7 @@ import { orderExchangeAddNewItemWorkflow, orderExchangeRequestItemReturnWorkflow, } from "@medusajs/core-flows" +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { FulfillmentWorkflow, IRegionModuleService, @@ -21,7 +22,6 @@ import { RuleOperator, remoteQueryObjectFromString, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" jest.setTimeout(500000) @@ -234,7 +234,7 @@ async function prepareDataFixtures({ container }) { { attribute: "is_return", operator: RuleOperator.EQ, - value: '"true"', + value: "true", }, ], } diff --git a/integration-tests/modules/__tests__/order/workflows/begin-order-return.spec.ts b/integration-tests/modules/__tests__/order/workflows/begin-order-return.spec.ts index 43b5a4727b9a5..9e91d5b3df272 100644 --- a/integration-tests/modules/__tests__/order/workflows/begin-order-return.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/begin-order-return.spec.ts @@ -2,6 +2,7 @@ import { beginReturnOrderWorkflow, createShippingOptionsWorkflow, } from "@medusajs/core-flows" +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { FulfillmentWorkflow, IOrderModuleService, @@ -17,7 +18,6 @@ import { RuleOperator, remoteQueryObjectFromString, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" jest.setTimeout(500000) @@ -187,7 +187,7 @@ async function prepareDataFixtures({ container }) { { attribute: "is_return", operator: RuleOperator.EQ, - value: '"true"', + value: "true", }, ], } diff --git a/integration-tests/modules/__tests__/order/workflows/create-complete-return.spec.ts b/integration-tests/modules/__tests__/order/workflows/create-complete-return.spec.ts index 6d9a4a9fd1b7d..95da82bff210c 100644 --- a/integration-tests/modules/__tests__/order/workflows/create-complete-return.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/create-complete-return.spec.ts @@ -3,6 +3,7 @@ import { createShippingOptionsWorkflow, } from "@medusajs/core-flows" import { RemoteLink } from "@medusajs/modules-sdk" +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { FulfillmentSetDTO, FulfillmentWorkflow, @@ -21,7 +22,6 @@ import { RuleOperator, remoteQueryObjectFromString, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" jest.setTimeout(500000) @@ -190,7 +190,7 @@ async function prepareDataFixtures({ container }) { { attribute: "is_return", operator: RuleOperator.EQ, - value: '"true"', + value: "true", }, ], } diff --git a/integration-tests/modules/__tests__/order/workflows/create-fulfillment.spec.ts b/integration-tests/modules/__tests__/order/workflows/create-fulfillment.spec.ts index 0a94876ccfe13..d770eb3c4a4a5 100644 --- a/integration-tests/modules/__tests__/order/workflows/create-fulfillment.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/create-fulfillment.spec.ts @@ -3,6 +3,7 @@ import { createOrderFulfillmentWorkflow, createShippingOptionsWorkflow, } from "@medusajs/core-flows" +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { FulfillmentWorkflow, IOrderModuleService, @@ -20,7 +21,6 @@ import { Modules, remoteQueryObjectFromString, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" jest.setTimeout(500000) @@ -305,12 +305,15 @@ async function createOrderFixture({ container, product, location }) { const inventoryModule = container.resolve(Modules.INVENTORY) + const itemWithInventory = order.items!.find( + (o) => o.variant_sku === variantSkuWithInventory + )! const reservation = await inventoryModule.createReservationItems([ { - line_item_id: order.items![0].id, + line_item_id: itemWithInventory.id, inventory_item_id: inventoryItem.id, location_id: location.id, - quantity: order.items![0].quantity, + quantity: itemWithInventory.quantity, }, ]) @@ -440,7 +443,6 @@ medusaIntegrationTestRunner({ id: order.id, }, fields: [ - "*", "items.*", "shipping_methods.*", "total", @@ -458,14 +460,15 @@ medusaIntegrationTestRunner({ )! expect(orderFulfillAfterCancelled.fulfillments).toHaveLength(1) - expect(orderFulfillItemWithInventory.detail.fulfilled_quantity).toEqual( - 0 - ) + expect( + orderFulfillItemWithInventory.detail.fulfilled_quantity.valueOf() + ).toEqual(0) const stockAvailabilityAfterCancelled = await inventoryModule.retrieveStockedQuantity(inventoryItem.id, [ location.id, ]) + expect(stockAvailabilityAfterCancelled.valueOf()).toEqual(2) }) diff --git a/integration-tests/modules/__tests__/order/workflows/create-shipment.spec.ts b/integration-tests/modules/__tests__/order/workflows/create-shipment.spec.ts index 7ae6fab32f472..7e31f754f1c34 100644 --- a/integration-tests/modules/__tests__/order/workflows/create-shipment.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/create-shipment.spec.ts @@ -3,6 +3,7 @@ import { createOrderShipmentWorkflow, createShippingOptionsWorkflow, } from "@medusajs/core-flows" +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { FulfillmentWorkflow, IOrderModuleService, @@ -20,7 +21,6 @@ import { RuleOperator, remoteQueryObjectFromString, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" jest.setTimeout(500000) @@ -177,7 +177,7 @@ async function prepareDataFixtures({ container }) { { attribute: "is_return", operator: RuleOperator.EQ, - value: '"true"', + value: "true", }, ], } diff --git a/integration-tests/modules/__tests__/order/workflows/return/items.spec.ts b/integration-tests/modules/__tests__/order/workflows/return/items.spec.ts index fb2ee5a3aa2a8..6bc8c8de0a136 100644 --- a/integration-tests/modules/__tests__/order/workflows/return/items.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/return/items.spec.ts @@ -145,7 +145,9 @@ medusaIntegrationTestRunner({ 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 () => { diff --git a/integration-tests/modules/__tests__/shipping-options/workflows/batch-shipping-options-rules.ts b/integration-tests/modules/__tests__/shipping-options/workflows/batch-shipping-options-rules.ts index 6ae4109bbfc19..46e3e5c8845d2 100644 --- a/integration-tests/modules/__tests__/shipping-options/workflows/batch-shipping-options-rules.ts +++ b/integration-tests/modules/__tests__/shipping-options/workflows/batch-shipping-options-rules.ts @@ -2,6 +2,7 @@ import { batchShippingOptionRulesWorkflow, createShippingOptionsWorkflow, } from "@medusajs/core-flows" +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { BatchWorkflowInput, CreateShippingOptionRuleDTO, @@ -19,7 +20,6 @@ import { RuleOperator, remoteQueryObjectFromString, } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" jest.setTimeout(100000) @@ -249,7 +249,7 @@ medusaIntegrationTestRunner({ expect.objectContaining({ attribute: "new_attribute", operator: "eq", - value: 100, + value: "100", }) ) expect(updatedRule).toEqual( @@ -345,7 +345,7 @@ medusaIntegrationTestRunner({ expect.objectContaining({ attribute: "total", operator: "eq", - value: 100, + value: "100", }), ]) ) diff --git a/integration-tests/package.json b/integration-tests/package.json index c64935ddc4199..e6cedeb0579cf 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -21,10 +21,10 @@ "scrypt-kdf": "^2.0.1", "jsonwebtoken": "^9.0.2", "@medusajs/framework": "^1.0.1", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "ioredis": "^5.4.1", "pg": "^8.13.0", diff --git a/packages/cli/medusa-cli/package.json b/packages/cli/medusa-cli/package.json index 510ba265e5f9f..3f5a2c5689ad2 100644 --- a/packages/cli/medusa-cli/package.json +++ b/packages/cli/medusa-cli/package.json @@ -32,10 +32,10 @@ "author": "Sebastian Rindom", "license": "MIT", "devDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "@types/yargs": "^15.0.15", @@ -72,10 +72,10 @@ "yargs": "^15.3.1" }, "peerDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "pg": "^8.13.0" }, diff --git a/packages/core/core-flows/package.json b/packages/core/core-flows/package.json index 00b18adf3e424..38d97bb7223a9 100644 --- a/packages/core/core-flows/package.json +++ b/packages/core/core-flows/package.json @@ -27,10 +27,10 @@ "license": "MIT", "devDependencies": { "@medusajs/framework": "^2.3.1", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "awilix": "^8.0.1", diff --git a/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts b/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts index 1dafde24f50ca..b599d5d6e0a3e 100644 --- a/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts +++ b/packages/core/core-flows/src/inventory/steps/adjust-inventory-levels.ts @@ -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 { MathBN, Modules } from "@medusajs/framework/utils" @@ -29,20 +29,22 @@ export const adjustInventoryLevelsStep = createStep( input: AdjustInventoryLevelsStepInput, { container } ) => { - const inventoryService: IInventoryService = container.resolve( - Modules.INVENTORY - ) + const inventoryService = container.resolve(Modules.INVENTORY) + const locking = container.resolve(Modules.LOCKING) + const inventoryItemIds = input.map((item) => item.inventory_item_id) const adjustedLevels: InventoryTypes.InventoryLevelDTO[] = - await inventoryService.adjustInventory( - input.map((item) => { - return { - inventoryItemId: item.inventory_item_id, - locationId: item.location_id, - adjustment: item.adjustment, - } - }) - ) + await locking.execute(inventoryItemIds, async () => { + return await inventoryService.adjustInventory( + input.map((item) => { + return { + inventoryItemId: item.inventory_item_id, + locationId: item.location_id, + adjustment: item.adjustment, + } + }) + ) + }) return new StepResponse( adjustedLevels, @@ -55,11 +57,15 @@ export const adjustInventoryLevelsStep = createStep( ) }, async (adjustedLevels, { container }) => { - if (!adjustedLevels) { + if (!adjustedLevels?.length) { return } const inventoryService = container.resolve(Modules.INVENTORY) + const locking = container.resolve(Modules.LOCKING) + const inventoryItemIds = adjustedLevels.map( + (item) => item.inventory_item_id + ) /** * @todo @@ -67,14 +73,16 @@ export const adjustInventoryLevelsStep = createStep( * "inventoryItemId" and "locationId" as snake case, whereas * the expected object needed these properties as camelCase */ - await inventoryService.adjustInventory( - adjustedLevels.map((level) => { - return { - inventoryItemId: level.inventory_item_id, - locationId: level.location_id, - adjustment: level.adjustment, - } - }) - ) + await locking.execute(inventoryItemIds, async () => { + await inventoryService.adjustInventory( + adjustedLevels.map((level) => { + return { + inventoryItemId: level.inventory_item_id, + locationId: level.location_id, + adjustment: level.adjustment, + } + }) + ) + }) } ) diff --git a/packages/core/core-flows/src/order/steps/claim/update-order-claims.ts b/packages/core/core-flows/src/order/steps/claim/update-order-claims.ts index 7ff933d2687b5..7775c8e1e3dcc 100644 --- a/packages/core/core-flows/src/order/steps/claim/update-order-claims.ts +++ b/packages/core/core-flows/src/order/steps/claim/update-order-claims.ts @@ -20,10 +20,10 @@ export const updateOrderClaimsStep = createStep( const { selects, relations } = getSelectsAndRelationsFromObjectArray(data, { objectFields: ["metadata"], }) - const dataBeforeUpdate = await service.listOrderClaims( + const dataBeforeUpdate = (await service.listOrderClaims( { id: data.map((d) => d.id) }, { relations, select: selects } - ) + )) as UpdateOrderClaimDTO[] const updated = await service.updateOrderClaims( data.map((dt) => { diff --git a/packages/core/core-flows/src/order/steps/exchange/update-order-exchanges.ts b/packages/core/core-flows/src/order/steps/exchange/update-order-exchanges.ts index 61410ba8dc154..c357cf3e09487 100644 --- a/packages/core/core-flows/src/order/steps/exchange/update-order-exchanges.ts +++ b/packages/core/core-flows/src/order/steps/exchange/update-order-exchanges.ts @@ -26,10 +26,10 @@ export const updateOrderExchangesStep = createStep( const { selects, relations } = getSelectsAndRelationsFromObjectArray(data, { objectFields: ["metadata"], }) - const dataBeforeUpdate = await service.listOrderExchanges( + const dataBeforeUpdate = (await service.listOrderExchanges( { id: data.map((d) => d.id) }, { relations, select: selects } - ) + )) as UpdateOrderExchangeDTO[] const updated = await service.updateOrderExchanges( data.map((dt) => { diff --git a/packages/core/core-flows/src/order/steps/index.ts b/packages/core/core-flows/src/order/steps/index.ts index f7b049b02bae4..bb5a1206be3cd 100644 --- a/packages/core/core-flows/src/order/steps/index.ts +++ b/packages/core/core-flows/src/order/steps/index.ts @@ -22,6 +22,7 @@ export * from "./exchange/create-exchange-items-from-actions" export * from "./exchange/delete-exchanges" export * from "./preview-order-change" export * from "./register-fulfillment" +export * from "./register-order-changes" export * from "./register-shipment" export * from "./return/cancel-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 "./update-order-change-actions" export * from "./update-order-changes" -export * from "./update-order-exchanges" -export * from "./update-shipping-methods" export * from "./update-orders" -export * from "./register-order-changes" +export * from "./update-shipping-methods" diff --git a/packages/core/core-flows/src/order/steps/update-order-changes.ts b/packages/core/core-flows/src/order/steps/update-order-changes.ts index d49e9be819286..6cf1491464bd3 100644 --- a/packages/core/core-flows/src/order/steps/update-order-changes.ts +++ b/packages/core/core-flows/src/order/steps/update-order-changes.ts @@ -13,7 +13,7 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk" */ export type UpdateOrderChangesStepInput = UpdateOrderChangeDTO[] -export const updateOrderChangesStepId = "update-order-shopping-methods" +export const updateOrderChangesStepId = "update-order-changes" /** * This step updates order change. */ diff --git a/packages/core/core-flows/src/order/steps/update-order-exchanges.ts b/packages/core/core-flows/src/order/steps/update-order-exchanges.ts deleted file mode 100644 index 875717c5d522c..0000000000000 --- a/packages/core/core-flows/src/order/steps/update-order-exchanges.ts +++ /dev/null @@ -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(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(Modules.ORDER) - - await service.updateOrderExchanges( - dataBeforeUpdate.map((dt) => { - const { id, ...rest } = dt - return { - selector: { id }, - data: rest, - } - }) - ) - } -) diff --git a/packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts b/packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts index c4231489532e4..e9671a3fba2dd 100644 --- a/packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts +++ b/packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts @@ -143,13 +143,15 @@ function prepareInventoryUpdate({ }[] = [] for (const item of fulfillment.items) { // if this is `null` this means that item is from variant that has `manage_inventory` false - if (item.inventory_item_id) { - inventoryAdjustment.push({ - inventory_item_id: item.inventory_item_id as string, - location_id: fulfillment.location_id, - adjustment: item.quantity, - }) + if (!item.inventory_item_id) { + continue } + + inventoryAdjustment.push({ + inventory_item_id: item.inventory_item_id as string, + location_id: fulfillment.location_id, + adjustment: item.quantity, + }) } return { diff --git a/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts b/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts index d972c2f9d90fd..449e422983794 100644 --- a/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts +++ b/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts @@ -223,16 +223,10 @@ export const orderClaimRequestItemReturnWorkflow = createWorkflow( when({ orderClaim }, ({ orderClaim }) => { return !orderClaim.return_id }).then(() => { - const createdReturnId = transform( - { createdReturn }, - ({ createdReturn }) => { - return createdReturn?.[0]!.id - } - ) updateOrderClaimsStep([ { id: orderClaim.id, - return_id: createdReturnId, + return: createdReturn?.[0]!.id, }, ]) }) diff --git a/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts b/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts index b8137eba59f1a..a127e8492eb59 100644 --- a/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts +++ b/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts @@ -327,6 +327,8 @@ export const confirmClaimRequestWorkflow = createWorkflow( fields: [ "id", "status", + "claim_id", + "return_id", "actions.id", "actions.claim_id", "actions.return_id", diff --git a/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts b/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts index 25194885f62fc..edc02bfe6607b 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts @@ -225,16 +225,10 @@ export const orderExchangeRequestItemReturnWorkflow = createWorkflow( when({ orderExchange }, ({ orderExchange }) => { return !orderExchange.return_id }).then(() => { - const createdReturnId = transform( - { createdReturn }, - ({ createdReturn }) => { - return createdReturn?.[0]!.id - } - ) updateOrderExchangesStep([ { id: orderExchange.id, - return_id: createdReturnId, + return: createdReturn?.[0]!.id, }, ]) }) diff --git a/packages/core/core-flows/src/order/workflows/return/remove-item-return-action.ts b/packages/core/core-flows/src/order/workflows/return/remove-item-return-action.ts index 339b1c90632f9..1e051c4c66dc0 100644 --- a/packages/core/core-flows/src/order/workflows/return/remove-item-return-action.ts +++ b/packages/core/core-flows/src/order/workflows/return/remove-item-return-action.ts @@ -186,7 +186,17 @@ export const removeItemReturnActionWorkflow = createWorkflow( const updatedOrderChange: OrderChangeDTO = useRemoteQueryStep({ 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: { filters: { order_id: orderReturn.order_id, diff --git a/packages/core/framework/package.json b/packages/core/framework/package.json index b5600a3d9965c..18b45f5ce88bd 100644 --- a/packages/core/framework/package.json +++ b/packages/core/framework/package.json @@ -55,10 +55,10 @@ }, "devDependencies": { "@medusajs/cli": "^2.3.1", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "@types/cors": "^2.8.17", @@ -97,11 +97,11 @@ }, "peerDependencies": { "@medusajs/cli": "^2.0.0", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "ioredis": "^5.4.1", "pg": "^8.13.0", diff --git a/packages/core/framework/src/mikro-orm-cli/bin.ts b/packages/core/framework/src/mikro-orm-cli/bin.ts index f131f28d6547c..4ca967e9e4760 100644 --- a/packages/core/framework/src/mikro-orm-cli/bin.ts +++ b/packages/core/framework/src/mikro-orm-cli/bin.ts @@ -11,17 +11,15 @@ * 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 { ConfigurationLoader } from "@mikro-orm/core" +import { isAbsolute, join } from "path" /** * Monkey patching the TSNode registration of Mikro ORM to not use * hardcoded module system with TypeScript. */ -ConfigurationLoader.registerTsNode = async function ( - configPath = "tsconfig.json" -) { +ConfigurationLoader.registerTsNode = function (configPath = "tsconfig.json") { const tsConfigPath = isAbsolute(configPath) ? configPath : join(process.cwd(), configPath) diff --git a/packages/core/modules-sdk/package.json b/packages/core/modules-sdk/package.json index 9faa3ddb58d31..339d8368ca3f5 100644 --- a/packages/core/modules-sdk/package.json +++ b/packages/core/modules-sdk/package.json @@ -31,10 +31,10 @@ "watch": "tsc --build --watch" }, "devDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "awilix": "^8.0.1", @@ -50,10 +50,10 @@ "@medusajs/utils": "^2.3.1" }, "peerDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "express": "^4.21.0", "pg": "^8.13.0" diff --git a/packages/core/orchestration/package.json b/packages/core/orchestration/package.json index 413c7612f6d07..ecb6ca1e397a2 100644 --- a/packages/core/orchestration/package.json +++ b/packages/core/orchestration/package.json @@ -26,10 +26,10 @@ "author": "Medusa", "license": "MIT", "devDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "awilix": "^8.0.1", @@ -43,10 +43,10 @@ "@medusajs/utils": "^2.3.1" }, "peerDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "express": "^4.21.0", "pg": "^8.13.0" diff --git a/packages/core/types/src/dml/index.ts b/packages/core/types/src/dml/index.ts index 253c4d2df4dd4..3f25730a070ef 100644 --- a/packages/core/types/src/dml/index.ts +++ b/packages/core/types/src/dml/index.ts @@ -10,7 +10,12 @@ export type DMLSchema = Record< PropertyType | RelationshipType > -export type IDmlEntityConfig = string | { name?: string; tableName: string } +export type IDmlEntityConfig = + | string + | { + name?: string + tableName: string + } export type InferDmlEntityNameFromConfig = TConfig extends string diff --git a/packages/core/types/src/order/common.ts b/packages/core/types/src/order/common.ts index a06d56e4259be..a3b75441e4606 100644 --- a/packages/core/types/src/order/common.ts +++ b/packages/core/types/src/order/common.ts @@ -2727,6 +2727,21 @@ export interface FilterableOrderChangeProps */ order_id?: string | string[] | OperatorMap + /** + * Filter the changes by their associated return's ID. + */ + return_id?: string | string[] | OperatorMap + + /** + * Filter the changes by their associated claim's ID. + */ + claim_id?: string | string[] | OperatorMap + + /** + * Filter the changes by their associated exchange's ID. + */ + exchange_id?: string | string[] | OperatorMap + /** * Filter the order changes by their status. */ diff --git a/packages/core/types/src/order/mutations.ts b/packages/core/types/src/order/mutations.ts index 0288d380f14a0..0a1f7d92b5144 100644 --- a/packages/core/types/src/order/mutations.ts +++ b/packages/core/types/src/order/mutations.ts @@ -1738,7 +1738,7 @@ export interface UpdateOrderClaimDTO { * The associated return's ID, if the * claim's {@link type} is `replace`. */ - return_id?: string + return?: string /** * The type of the claim. @@ -1778,7 +1778,7 @@ export interface UpdateOrderExchangeDTO { /** * The associated return's ID. */ - return_id?: string + return?: string /** * Whether backorders are allowed on the exchange's items. diff --git a/packages/core/utils/package.json b/packages/core/utils/package.json index d92fe6bd4830f..058c018492281 100644 --- a/packages/core/utils/package.json +++ b/packages/core/utils/package.json @@ -26,10 +26,10 @@ "author": "Medusa", "license": "MIT", "devDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "@types/express": "^4.17.21", @@ -59,10 +59,10 @@ "ulid": "^2.3.0" }, "peerDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "express": "^4.21.0", "pg": "^8.13.0" diff --git a/packages/core/utils/src/dal/mikro-orm/__fixtures__/utils.ts b/packages/core/utils/src/dal/mikro-orm/__fixtures__/utils.ts index d3dec6ef446e0..4b8a839484a59 100644 --- a/packages/core/utils/src/dal/mikro-orm/__fixtures__/utils.ts +++ b/packages/core/utils/src/dal/mikro-orm/__fixtures__/utils.ts @@ -63,7 +63,7 @@ class ProductOptionValue { fieldName: "option_id", mapToPk: true, nullable: true, - onDelete: "cascade", + deleteRule: "cascade", }) option_id: string | null @@ -88,7 +88,7 @@ class ProductVariant { @ManyToOne(() => Product, { columnType: "text", nullable: true, - onDelete: "cascade", + deleteRule: "cascade", fieldName: "product_id", mapToPk: true, }) diff --git a/packages/core/utils/src/dal/mikro-orm/__tests__/base-entity.spec.ts b/packages/core/utils/src/dal/mikro-orm/__tests__/base-entity.spec.ts index 09afa1b181ed0..5a15dec87e8a2 100644 --- a/packages/core/utils/src/dal/mikro-orm/__tests__/base-entity.spec.ts +++ b/packages/core/utils/src/dal/mikro-orm/__tests__/base-entity.spec.ts @@ -1,4 +1,5 @@ import { Entity, MikroORM, OnInit, Property } from "@mikro-orm/core" +import { defineConfig } from "@mikro-orm/postgresql" import { BaseEntity } from "../base-entity" describe("BaseEntity", () => { @@ -10,11 +11,15 @@ describe("BaseEntity", () => { } } - const orm = await MikroORM.init({ - entities: [Entity1], - dbName: "test", - type: "postgresql", - }) + const orm = await MikroORM.init( + defineConfig({ + entities: [Entity1], + dbName: "test", + user: "postgres", + password: "", + connect: false, + }) + ) const manager = orm.em.fork() const entity1 = manager.create(Entity1, {}) @@ -28,11 +33,15 @@ describe("BaseEntity", () => { @Entity() class Entity1 extends BaseEntity {} - const orm = await MikroORM.init({ - entities: [Entity1], - dbName: "test", - type: "postgresql", - }) + const orm = await MikroORM.init( + defineConfig({ + entities: [Entity1], + dbName: "test", + user: "postgres", + password: "", + connect: false, + }) + ) const manager = orm.em.fork() const entity1 = manager.create(Entity1, {}) @@ -52,11 +61,15 @@ describe("BaseEntity", () => { @Entity() class ProductOptionValue extends BaseEntity {} - const orm = await MikroORM.init({ - entities: [ProductModel, ProductCategoryEntity, ProductOptionValue], - dbName: "test", - type: "postgresql", - }) + const orm = await MikroORM.init( + defineConfig({ + entities: [ProductModel, ProductCategoryEntity, ProductOptionValue], + dbName: "test", + user: "postgres", + password: "", + connect: false, + }) + ) const manager = orm.em.fork() @@ -105,11 +118,15 @@ describe("BaseEntity", () => { } } - const orm = await MikroORM.init({ - entities: [ProductModel, ProductCategoryEntity, ProductOptionValue], - dbName: "test", - type: "postgresql", - }) + const orm = await MikroORM.init( + defineConfig({ + entities: [ProductModel, ProductCategoryEntity, ProductOptionValue], + dbName: "test", + user: "postgres", + password: "", + connect: false, + }) + ) const manager = orm.em.fork() diff --git a/packages/core/utils/src/dal/mikro-orm/__tests__/big-number-field.spec.ts b/packages/core/utils/src/dal/mikro-orm/__tests__/big-number-field.spec.ts index 367ac15dff78a..a2e49231e2e4a 100644 --- a/packages/core/utils/src/dal/mikro-orm/__tests__/big-number-field.spec.ts +++ b/packages/core/utils/src/dal/mikro-orm/__tests__/big-number-field.spec.ts @@ -1,5 +1,6 @@ import { BigNumberRawValue } from "@medusajs/types" import { Entity, MikroORM, PrimaryKey } from "@mikro-orm/core" +import { defineConfig } from "@mikro-orm/postgresql" import { BigNumber } from "../../../totals/big-number" import { MikroOrmBigNumberProperty } from "../big-number-field" @@ -23,11 +24,15 @@ describe("@MikroOrmBigNumberProperty", () => { let orm!: MikroORM beforeEach(async () => { - orm = await MikroORM.init({ - entities: [TestAmount], - dbName: "test", - type: "postgresql", - }) + orm = await MikroORM.init( + defineConfig({ + entities: [TestAmount], + dbName: "test", + user: "postgres", + password: "", + connect: false, + }) + ) }) afterEach(async () => { @@ -51,9 +56,7 @@ describe("@MikroOrmBigNumberProperty", () => { try { ;(testAmount as any).amount = null } catch (e) { - expect(e.message).toEqual( - "Invalid BigNumber value: null. Should be one of: string, number, BigNumber (bignumber.js), BigNumberRawValue" - ) + expect(e.message).toEqual("Cannot set value null for amount.") } testAmount.nullable_amount = null diff --git a/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-free-text-search-filter.spec.ts b/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-free-text-search-filter.spec.ts index d932d5cb7f22c..eb4c4c92f8c0e 100644 --- a/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-free-text-search-filter.spec.ts +++ b/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-free-text-search-filter.spec.ts @@ -1,4 +1,5 @@ import { MikroORM } from "@mikro-orm/core" +import { defineConfig } from "@mikro-orm/postgresql" import { SearchableEntity1, SearchableEntity2 } from "../__fixtures__/utils" import { mikroOrmFreeTextSearchFilterOptionsFactory } from "../mikro-orm-free-text-search-filter" @@ -6,21 +7,23 @@ describe("mikroOrmFreeTextSearchFilterOptionsFactory", () => { let orm beforeEach(async () => { - orm = await MikroORM.init({ - entities: [SearchableEntity1, SearchableEntity2], - dbName: "test", - type: "postgresql", - }) + orm = await MikroORM.init( + defineConfig({ + entities: [SearchableEntity1, SearchableEntity2], + user: "postgres", + password: "", + dbName: "test", + connect: false, + }) + ) }) it("should return a filter function that filters entities based on the free text search value", async () => { const entityManager = orm.em.fork() const freeTextSearchValue = "search" - const models = [SearchableEntity1, SearchableEntity2] - let filterConstraints = mikroOrmFreeTextSearchFilterOptionsFactory( - models + SearchableEntity1.name ).cond( { value: freeTextSearchValue, @@ -51,7 +54,9 @@ describe("mikroOrmFreeTextSearchFilterOptionsFactory", () => { ], }) - filterConstraints = mikroOrmFreeTextSearchFilterOptionsFactory(models).cond( + filterConstraints = mikroOrmFreeTextSearchFilterOptionsFactory( + SearchableEntity2.name + ).cond( { value: freeTextSearchValue, fromEntity: SearchableEntity2.name, diff --git a/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-serializer.spec.ts b/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-serializer.spec.ts index dbeccea8fd449..5acd333a04ce4 100644 --- a/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-serializer.spec.ts +++ b/packages/core/utils/src/dal/mikro-orm/__tests__/mikro-orm-serializer.spec.ts @@ -1,4 +1,5 @@ import { MikroORM } from "@mikro-orm/core" +import { defineConfig } from "@mikro-orm/postgresql" import { Entity1WithUnDecoratedProp, Entity2WithUnDecoratedProp, @@ -11,18 +12,22 @@ import { mikroOrmSerializer } from "../mikro-orm-serializer" describe("mikroOrmSerializer", () => { beforeEach(async () => { - await MikroORM.init({ - entities: [ - Entity1WithUnDecoratedProp, - Entity2WithUnDecoratedProp, - Product, - ProductOption, - ProductOptionValue, - ProductVariant, - ], - dbName: "test", - type: "postgresql", - }) + await MikroORM.init( + defineConfig({ + entities: [ + Entity1WithUnDecoratedProp, + Entity2WithUnDecoratedProp, + Product, + ProductOption, + ProductOptionValue, + ProductVariant, + ], + user: "postgres", + password: "", + dbName: "test", + connect: false, + }) + ) }) it("should serialize an entity", async () => { diff --git a/packages/core/utils/src/dal/mikro-orm/__tests__/ts-migration-generator.spec.ts b/packages/core/utils/src/dal/mikro-orm/__tests__/ts-migration-generator.spec.ts index 71d7b4de21221..9135826e3da74 100644 --- a/packages/core/utils/src/dal/mikro-orm/__tests__/ts-migration-generator.spec.ts +++ b/packages/core/utils/src/dal/mikro-orm/__tests__/ts-migration-generator.spec.ts @@ -1,7 +1,7 @@ import { CustomTsMigrationGenerator } from "../mikro-orm-create-connection" function unwrapSql(sql: string) { - return sql.match(/this.addSql\('(.*?)'\)/)?.[1] + return sql.toString().match(/this.addSql\(`(.*?)`\)/)?.[1] } describe("CustomTsMigrationGenerator", () => { diff --git a/packages/core/utils/src/dal/mikro-orm/big-number-field.ts b/packages/core/utils/src/dal/mikro-orm/big-number-field.ts index 9aaa769929473..e3012fbcdec77 100644 --- a/packages/core/utils/src/dal/mikro-orm/big-number-field.ts +++ b/packages/core/utils/src/dal/mikro-orm/big-number-field.ts @@ -26,20 +26,24 @@ export function MikroOrmBigNumberProperty( set(value: BigNumberInput) { if (options?.nullable && !isPresent(value)) { this.__helper.__data[columnName] = null - this.__helper.__data[rawColumnName] + this.__helper.__data[rawColumnName] = null this[rawColumnName] = null } else { let bigNumber: BigNumber - if (value instanceof BigNumber) { - bigNumber = value - } else if (this[rawColumnName]) { - const precision = this[rawColumnName].precision - bigNumber = new BigNumber(value, { - precision, - }) - } else { - bigNumber = new BigNumber(value) + try { + if (value instanceof BigNumber) { + bigNumber = value + } else if (this[rawColumnName]) { + const precision = this[rawColumnName].precision + bigNumber = new BigNumber(value, { + precision, + }) + } else { + bigNumber = new BigNumber(value) + } + } catch (e) { + throw new Error(`Cannot set value ${value} for ${columnName}.`) } const raw = bigNumber.raw! @@ -80,6 +84,7 @@ export function MikroOrmBigNumberProperty( type: "any", columnType: "numeric", trackChanges: false, + runtimeType: "any", ...options, })(target, columnName) } diff --git a/packages/core/utils/src/dal/mikro-orm/integration-tests/__fixtures__/database.ts b/packages/core/utils/src/dal/mikro-orm/integration-tests/__fixtures__/database.ts index 34b07c08bc7d5..c7b4dace0269c 100644 --- a/packages/core/utils/src/dal/mikro-orm/integration-tests/__fixtures__/database.ts +++ b/packages/core/utils/src/dal/mikro-orm/integration-tests/__fixtures__/database.ts @@ -1,5 +1,5 @@ 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 export const pgGodCredentials = { diff --git a/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/mikro-orm-repository.spec.ts b/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/mikro-orm-repository.spec.ts index 2c5f51541f739..7101872fcd7ca 100644 --- a/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/mikro-orm-repository.spec.ts +++ b/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/mikro-orm-repository.spec.ts @@ -1,3 +1,4 @@ +import { BigNumberRawValue } from "@medusajs/types" import { BeforeCreate, Collection, @@ -13,11 +14,11 @@ import { Unique, wrap, } 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 { MikroOrmBigNumberProperty } from "../../big-number-field" -import BigNumber from "bignumber.js" -import { BigNumberRawValue } from "@medusajs/types" +import { mikroOrmBaseRepositoryFactory } from "../../mikro-orm-repository" import { getDatabaseURL, pgGodCredentials } from "../__fixtures__/database" const dbName = "mikroorm-integration-1" @@ -78,7 +79,7 @@ class Entity2 { nullable: true, mapToPk: true, fieldName: "entity1_id", - onDelete: "set null", + deleteRule: "set null", }) entity1_id: string @@ -143,11 +144,12 @@ describe("mikroOrmRepository", () => { pgGodCredentials ) - orm = await MikroORM.init({ - entities: [Entity1, Entity2], - clientUrl: getDatabaseURL(dbName), - type: "postgresql", - }) + orm = await MikroORM.init( + defineConfig({ + entities: [Entity1, Entity2], + clientUrl: getDatabaseURL(dbName), + }) + ) const generator = orm.getSchemaGenerator() await generator.ensureDatabase() diff --git a/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/utils.spec.ts b/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/utils.spec.ts index cbef2979e862b..6a492d6304e3e 100644 --- a/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/utils.spec.ts +++ b/packages/core/utils/src/dal/mikro-orm/integration-tests/__tests__/utils.spec.ts @@ -1,6 +1,8 @@ -import { mikroOrmUpdateDeletedAtRecursively } from "../../utils" 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 { DeepRecursiveEntity1, DeepRecursiveEntity2, @@ -12,8 +14,6 @@ import { RecursiveEntity1, RecursiveEntity2, } from "../__fixtures__/utils" -import { dropDatabase } from "pg-god" -import { getDatabaseURL, pgGodCredentials } from "../__fixtures__/database" const dbName = "mikroorm-utils-integration-1" @@ -38,21 +38,22 @@ describe("mikroOrmUpdateDeletedAtRecursively", () => { pgGodCredentials ) - orm = await MikroORM.init({ - entities: [ - Entity1, - Entity2, - RecursiveEntity1, - RecursiveEntity2, - DeepRecursiveEntity1, - DeepRecursiveEntity2, - DeepRecursiveEntity3, - DeepRecursiveEntity4, - InternalCircularDependencyEntity1, - ], - clientUrl: getDatabaseURL(dbName), - type: "postgresql", - }) + orm = await MikroORM.init( + defineConfig({ + entities: [ + Entity1, + Entity2, + RecursiveEntity1, + RecursiveEntity2, + DeepRecursiveEntity1, + DeepRecursiveEntity2, + DeepRecursiveEntity3, + DeepRecursiveEntity4, + InternalCircularDependencyEntity1, + ], + clientUrl: getDatabaseURL(dbName), + }) + ) const generator = orm.getSchemaGenerator() await generator.ensureDatabase() diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts index 6630af8ad437e..aba4d1a84df44 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts @@ -45,34 +45,38 @@ export async function mikroOrmCreateConnection( schema = database.connection.context?.client?.config?.searchPath } - const { MikroORM } = await import("@mikro-orm/postgresql") - return await MikroORM.init({ - discovery: { disableDynamicFileAccess: true, warnWhenNoEntities: false }, - entities, - debug: database.debug ?? process.env.NODE_ENV?.startsWith("dev") ?? false, - baseDir: process.cwd(), - clientUrl, - schema, - driverOptions, - tsNode: process.env.APP_ENV === "development", - type: "postgresql", - filters: database.filters ?? {}, - migrations: { - disableForeignKeys: false, - path: pathToMigrations, - generator: CustomTsMigrationGenerator, - silent: !( - database.debug ?? - process.env.NODE_ENV?.startsWith("dev") ?? - false - ), - }, - schemaGenerator: { - disableForeignKeys: false, - }, - pool: { - min: 2, - ...database.pool, - }, - }) + const { MikroORM, defineConfig } = await import("@mikro-orm/postgresql") + return await MikroORM.init( + defineConfig({ + discovery: { disableDynamicFileAccess: true, warnWhenNoEntities: false }, + entities, + debug: database.debug ?? process.env.NODE_ENV?.startsWith("dev") ?? false, + baseDir: process.cwd(), + clientUrl, + schema, + driverOptions, + tsNode: process.env.APP_ENV === "development", + filters: database.filters ?? {}, + assign: { + convertCustomTypes: true, + }, + migrations: { + disableForeignKeys: false, + path: pathToMigrations, + generator: CustomTsMigrationGenerator, + silent: !( + database.debug ?? + process.env.NODE_ENV?.startsWith("dev") ?? + false + ), + }, + schemaGenerator: { + disableForeignKeys: false, + }, + pool: { + min: 2, + ...database.pool, + }, + }) + ) } diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts index 4b50830b067ad..1b515069ca1f3 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts @@ -4,23 +4,20 @@ import type { FindOneOptions, FindOptions, } 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" -export const FreeTextSearchFilterKey = "freeTextSearch" +export const FreeTextSearchFilterKeyPrefix = "freeTextSearch_" interface FilterArgument { value: string fromEntity: string } -function getEntityProperties(entity: EntityClass | EntitySchema): { +function getEntityProperties(metadata: EntityMetadata): { [key: string]: EntityProperty } { - return ( - (entity as EntityClass)?.prototype.__meta?.properties ?? - (entity as EntitySchema).meta?.properties - ) + return metadata.properties } function retrieveRelationsConstraints( @@ -31,7 +28,7 @@ function retrieveRelationsConstraints( type: string name: string }, - models: (EntityClass | EntitySchema)[], + metadata: EntityMetadata, searchValue: string, visited: Set = new Set(), shouldStop: boolean = false @@ -46,13 +43,12 @@ function retrieveRelationsConstraints( const relationFreeTextSearchWhere: any = [] - const relationClass = models.find((m) => m.name === relation.type)! - const relationProperties = getEntityProperties(relationClass) + const relationProperties = getEntityProperties(metadata) for (const propertyConfiguration of Object.values(relationProperties)) { if ( !(propertyConfiguration as any).searchable || - propertyConfiguration.reference !== ReferenceType.SCALAR + propertyConfiguration.kind !== ReferenceKind.SCALAR ) { continue } @@ -69,9 +65,7 @@ function retrieveRelationsConstraints( }) } - const innerRelations: EntityProperty[] = - (relationClass as EntityClass)?.prototype.__meta?.relations ?? - (relationClass as EntitySchema).meta?.relations + const innerRelations: EntityProperty[] = metadata.relations for (const innerRelation of innerRelations) { const branchVisited = new Set(Array.from(visited)) @@ -108,7 +102,7 @@ function retrieveRelationsConstraints( mapToPk: innerRelation.mapToPk, type: innerRelation.type, }, - models, + innerRelation.targetMeta!, searchValue, branchVisited, isSelfCircularDependency @@ -128,10 +122,9 @@ function retrieveRelationsConstraints( return relationFreeTextSearchWhere } -export const mikroOrmFreeTextSearchFilterOptionsFactory = ( - models: (EntityClass | EntitySchema)[] -) => { +export const mikroOrmFreeTextSearchFilterOptionsFactory = (model: string) => { return { + name: FreeTextSearchFilterKeyPrefix + model, cond: ( freeTextSearchArgs: FilterArgument, operation: string, @@ -144,7 +137,7 @@ export const mikroOrmFreeTextSearchFilterOptionsFactory = ( return {} } - const { value, fromEntity } = freeTextSearchArgs + const { value } = freeTextSearchArgs 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( { targetMeta: entityMetadata, mapToPk: false, searchable: true, - type: fromEntity, + type: model, name: entityMetadata.name!, }, - models, + entityMetadata, value ) @@ -180,8 +173,5 @@ export const mikroOrmFreeTextSearchFilterOptionsFactory = ( $or: freeTextSearchWhere, } }, - default: true, - args: false, - entity: models.map((m) => m.name) as string[], } } diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts index c4281adfe9822..8506bb42176ba 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts @@ -20,7 +20,7 @@ import { LoadStrategy, FilterQuery as MikroFilterQuery, FindOptions as MikroOptions, - ReferenceType, + ReferenceKind, } from "@mikro-orm/core" import { SqlEntityManager } from "@mikro-orm/postgresql" import { @@ -245,24 +245,6 @@ export class MikroOrmBaseRepository return [entities, softDeletedEntitiesMap] } - - applyFreeTextSearchFilters( - findOptions: DAL.FindOptions, - 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["where"] - } } export class MikroOrmBaseTreeRepository< @@ -391,7 +373,7 @@ export function mikroOrmBaseRepositoryFactory( const relation = relations.find((relation) => relation.name === key) const shouldInit = relation && - relation.reference === ReferenceType.MANY_TO_MANY && + relation.kind === ReferenceKind.MANY_TO_MANY && Array.isArray(update[key]) && !update[key].length @@ -434,7 +416,9 @@ export function mikroOrmBaseRepositoryFactory( await this.initManyToManyToDetachAllItemsIfNeeded(data, context) 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) }) @@ -578,7 +562,7 @@ export function mikroOrmBaseRepositoryFactory( const existingEntity = existingEntitiesMap.get(key) if (existingEntity) { const updatedType = manager.assign(existingEntity, data_) - updatedEntities.push(updatedType) + updatedEntities.push(updatedType as any) } else { const newEntity = manager.create(this.entity, data_) createdEntities.push(newEntity as InferRepositoryReturnType) @@ -698,8 +682,8 @@ export function mikroOrmBaseRepositoryFactory( // 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 if ( - relation.reference === ReferenceType.ONE_TO_ONE || - relation.reference === ReferenceType.MANY_TO_ONE + relation.kind === ReferenceKind.ONE_TO_ONE || + relation.kind === ReferenceKind.MANY_TO_ONE ) { return } @@ -765,7 +749,7 @@ export function mikroOrmBaseRepositoryFactory( 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 parentPivotColumn = relation.joinColumns[0] @@ -805,7 +789,7 @@ export function mikroOrmBaseRepositoryFactory( return { entities: normalizedData, performedActions } } - if (relation.reference === ReferenceType.ONE_TO_MANY) { + if (relation.kind === ReferenceKind.ONE_TO_MANY) { const joinColumns = relation.targetMeta?.properties[relation.mappedBy]?.joinColumns @@ -815,7 +799,7 @@ export function mikroOrmBaseRepositoryFactory( joinColumnsConstraints[joinColumn] = data[referencedColumnName] }) - const toDeleteEntities = await manager.find( + const toDeleteEntities = await manager.find( relation.type, { ...joinColumnsConstraints, @@ -869,7 +853,7 @@ export function mikroOrmBaseRepositoryFactory( } // 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) { entryCopy[relation.joinColumns[0]] = null return null @@ -927,7 +911,7 @@ export function mikroOrmBaseRepositoryFactory( .filter( ([_, propDef]: any) => propDef.persist === false && - propDef.reference === ReferenceType.MANY_TO_ONE + propDef.kind === ReferenceKind.MANY_TO_ONE ) .forEach(([key]) => { delete resp[key] diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts index d0a8dce80c302..974211e2deca5 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts @@ -7,36 +7,45 @@ import { Loaded, Platform, Reference, - ReferenceType, + ReferenceKind, SerializationContext, SerializeOptions, Utils, } from "@mikro-orm/core" +type CustomSerializeOptions = SerializeOptions & { + preventCircularRef?: boolean + populate?: [keyof T][] | boolean +} + function isVisible( meta: EntityMetadata, propName: string, - options: SerializeOptions & { preventCircularRef?: boolean } = {} + options: CustomSerializeOptions = {} ): boolean { if (options.populate === true) { - return options.populate + return true } if ( Array.isArray(options.populate) && - options.populate?.find( - (item) => item === propName || item.startsWith(propName + ".") - ) + options.exclude?.find((item) => item === propName) ) { - return true + return false } - if (options.exclude?.find((item) => item === propName)) { - return false + if ( + Array.isArray(options.populate) && + (options.populate?.find( + (item) => item === propName || item.startsWith(propName + ".") + ) || + options.populate.includes("*")) + ) { + return true } 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 return visible && !prefixed @@ -45,13 +54,14 @@ function isVisible( function isPopulated( entity: T, propName: string, - options: SerializeOptions + options: CustomSerializeOptions ): boolean { if ( - typeof options.populate !== "boolean" && - options.populate?.find( + Array.isArray(options.populate) && + (options.populate?.find( (item) => item === propName || item.startsWith(propName + ".") - ) + ) || + options.populate.includes("*")) ) { return true } @@ -78,9 +88,7 @@ function filterEntityPropToSerialize({ }: { propName: string meta: EntityMetadata - options: SerializeOptions & { - preventCircularRef?: boolean - } + options: CustomSerializeOptions parents?: string[] }): boolean { parents ??= [] @@ -92,7 +100,7 @@ function filterEntityPropToSerialize({ prop && options.preventCircularRef && isVisibleRes && - prop.reference !== ReferenceType.SCALAR + prop.kind !== ReferenceKind.SCALAR ) { // mapToPk would represent a foreign key and we want to keep them if (!!prop.mapToPk) { @@ -108,7 +116,7 @@ function filterEntityPropToSerialize({ export class EntitySerializer { static serialize( entity: T, - options: SerializeOptions & { preventCircularRef?: boolean } = {}, + options: CustomSerializeOptions = {}, parents: string[] = [] ): EntityDTO> { const parents_ = Array.from(new Set(parents)) @@ -118,12 +126,11 @@ export class EntitySerializer { let contextCreated = false if (!wrapped.__serializationContext.root) { - const root = new SerializationContext() + const root = new SerializationContext({} as any) SerializationContext.propagate( root, entity, - (meta, prop) => - meta.properties[prop]?.reference !== ReferenceType.SCALAR + (meta, prop) => meta.properties[prop]?.kind !== ReferenceKind.SCALAR ) contextCreated = true } @@ -238,25 +245,25 @@ export class EntitySerializer { private static propertyName( meta: EntityMetadata, - prop: keyof T & string, + prop: string, platform?: Platform ): string { /* istanbul ignore next */ 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) { - return platform.getSerializedPrimaryKeyField(prop) as keyof T & string + return platform.getSerializedPrimaryKeyField(prop) as string } return prop } private static processProperty( - prop: keyof T & string, + prop: string, entity: T, - options: SerializeOptions, + options: CustomSerializeOptions, parents: string[] = [] ): T[keyof T] | undefined { const parents_ = [...parents, entity.constructor.name] @@ -284,12 +291,17 @@ export class EntitySerializer { } 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)) { return this.processEntity( - prop, + prop as keyof T & string, entity, wrapped.__platform, options, @@ -298,7 +310,7 @@ export class EntitySerializer { } /* istanbul ignore next */ - if (property?.reference === ReferenceType.EMBEDDED) { + if (property?.reference === ReferenceKind.EMBEDDED) { if (Array.isArray(entity[prop])) { return (entity[prop] as object[]).map((item) => helper(item).toJSON() @@ -322,9 +334,9 @@ export class EntitySerializer { } private static extractChildOptions( - options: SerializeOptions, + options: CustomSerializeOptions, prop: keyof T & string - ): SerializeOptions { + ): CustomSerializeOptions { const extractChildElements = (items: string[]) => { return items .filter((field) => field.startsWith(`${prop}.`)) @@ -333,20 +345,22 @@ export class EntitySerializer { return { ...options, - populate: Array.isArray(options.populate) - ? extractChildElements(options.populate) - : options.populate, - exclude: Array.isArray(options.exclude) - ? extractChildElements(options.exclude) - : options.exclude, - } as SerializeOptions + populate: + Array.isArray(options.populate) && !options.populate.includes("*") + ? extractChildElements(options.populate as unknown as string[]) + : options.populate, + exclude: + Array.isArray(options.exclude) && !options.exclude.includes("*") + ? extractChildElements(options.exclude) + : options.exclude, + } as CustomSerializeOptions } private static processEntity( prop: keyof T & string, entity: T, platform: Platform, - options: SerializeOptions, + options: CustomSerializeOptions, parents: string[] = [] ): T[keyof T] | undefined { const parents_ = [...parents, entity.constructor.name] @@ -373,7 +387,7 @@ export class EntitySerializer { private static processCollection( prop: keyof T & string, entity: T, - options: SerializeOptions, + options: CustomSerializeOptions, parents: string[] = [] ): T[keyof T] | undefined { const parents_ = [...parents, entity.constructor.name] @@ -401,6 +415,7 @@ export const mikroOrmSerializer = ( data: any, options?: Parameters[1] & { preventCircularRef?: boolean + populate?: string[] | boolean } ): Promise => { return new Promise((resolve) => { @@ -422,10 +437,11 @@ export const mikroOrmSerializer = ( let result: any = forSerialization.map((entity) => EntitySerializer.serialize(entity, { forceObject: true, - populate: true, + populate: ["*"], + preventCircularRef: true, ...options, - } as SerializeOptions) + } as CustomSerializeOptions) ) as TOutput[] if (notForSerialization.length) { diff --git a/packages/core/utils/src/dml/__tests__/entity-builder.spec.ts b/packages/core/utils/src/dml/__tests__/entity-builder.spec.ts index 8c29ad3a08111..82eeb8f13748d 100644 --- a/packages/core/utils/src/dml/__tests__/entity-builder.spec.ts +++ b/packages/core/utils/src/dml/__tests__/entity-builder.spec.ts @@ -24,7 +24,7 @@ describe("Entity builder", () => { fieldName: "created_at", nullable: false, onCreate: expect.any(Function), - reference: "scalar", + kind: "scalar", setter: false, type: "date", }, @@ -34,7 +34,7 @@ describe("Entity builder", () => { name: "deleted_at", fieldName: "deleted_at", nullable: true, - reference: "scalar", + kind: "scalar", setter: false, type: "date", }, @@ -47,7 +47,7 @@ describe("Entity builder", () => { nullable: false, onCreate: expect.any(Function), onUpdate: expect.any(Function), - reference: "scalar", + kind: "scalar", setter: false, type: "date", }, @@ -98,6 +98,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -108,7 +112,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -118,7 +122,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -128,7 +132,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -138,7 +142,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -155,10 +159,11 @@ describe("Entity builder", () => { name: "spend_limit", fieldName: "spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: true, trackChanges: false, type: "any", + runtimeType: "any", }, raw_spend_limit: { columnType: "jsonb", @@ -166,7 +171,7 @@ describe("Entity builder", () => { name: "raw_spend_limit", fieldName: "raw_spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: false, type: "any", }, @@ -175,12 +180,12 @@ describe("Entity builder", () => { name: "phones", fieldName: "phones", nullable: false, - reference: "scalar", + kind: "scalar", setter: false, type: ArrayType, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -193,7 +198,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -237,6 +242,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -247,7 +256,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -257,7 +266,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -267,7 +276,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -277,7 +286,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -294,10 +303,11 @@ describe("Entity builder", () => { name: "spend_limit", fieldName: "spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: true, trackChanges: false, type: "any", + runtimeType: "any", }, raw_spend_limit: { columnType: "jsonb", @@ -305,12 +315,12 @@ describe("Entity builder", () => { name: "raw_spend_limit", fieldName: "raw_spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: false, type: "any", }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -323,7 +333,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -367,6 +377,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("UserRole") expect(metaData.filters).toEqual({ + freeTextSearch_UserRole: { + cond: expect.any(Function), + name: "freeTextSearch_UserRole", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -377,7 +391,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -387,7 +401,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -397,7 +411,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -407,7 +421,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -424,10 +438,11 @@ describe("Entity builder", () => { name: "spend_limit", fieldName: "spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: true, trackChanges: false, type: "any", + runtimeType: "any", }, raw_spend_limit: { columnType: "jsonb", @@ -435,12 +450,12 @@ describe("Entity builder", () => { name: "raw_spend_limit", fieldName: "raw_spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: false, type: "any", }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -453,7 +468,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -486,6 +501,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -496,7 +515,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -506,7 +525,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", default: "foo", columnType: "text", @@ -517,7 +536,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -533,10 +552,11 @@ describe("Entity builder", () => { name: "spend_limit", fieldName: "spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: true, trackChanges: false, type: "any", + runtimeType: "any", }, raw_spend_limit: { columnType: "jsonb", @@ -544,12 +564,12 @@ describe("Entity builder", () => { name: "raw_spend_limit", fieldName: "raw_spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: false, type: "any", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -561,7 +581,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -574,7 +594,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -627,6 +647,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -637,7 +661,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -647,7 +671,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -658,7 +682,7 @@ describe("Entity builder", () => { searchable: true, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -674,10 +698,11 @@ describe("Entity builder", () => { name: "spend_limit", fieldName: "spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: true, trackChanges: false, type: "any", + runtimeType: "any", }, raw_spend_limit: { columnType: "jsonb", @@ -685,12 +710,12 @@ describe("Entity builder", () => { name: "raw_spend_limit", fieldName: "raw_spend_limit", nullable: false, - reference: "scalar", + kind: "scalar", setter: false, type: "any", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -702,7 +727,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -715,7 +740,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -771,6 +796,10 @@ describe("Entity builder", () => { }) expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -781,7 +810,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -791,7 +820,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -801,7 +830,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -816,7 +845,7 @@ describe("Entity builder", () => { name: "raw_spend_limit", fieldName: "raw_spend_limit", nullable: true, - reference: "scalar", + kind: "scalar", setter: false, type: "any", }, @@ -826,13 +855,14 @@ describe("Entity builder", () => { name: "spend_limit", fieldName: "spend_limit", nullable: true, - reference: "scalar", + kind: "scalar", setter: true, trackChanges: false, type: "any", + runtimeType: "any", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -844,7 +874,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -857,7 +887,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -892,6 +922,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -902,7 +936,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -912,7 +946,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -922,7 +956,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -932,7 +966,7 @@ describe("Entity builder", () => { setter: false, }, role: { - reference: "scalar", + kind: "scalar", enum: true, items: expect.any(Function), nullable: false, @@ -941,7 +975,7 @@ describe("Entity builder", () => { type: "string", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -953,7 +987,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -966,7 +1000,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1009,6 +1043,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1019,7 +1057,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -1029,7 +1067,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -1039,7 +1077,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -1049,7 +1087,7 @@ describe("Entity builder", () => { setter: false, }, role: { - reference: "scalar", + kind: "scalar", enum: true, default: "guest", items: expect.any(Function), @@ -1059,7 +1097,7 @@ describe("Entity builder", () => { type: "string", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1071,7 +1109,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1084,7 +1122,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1130,6 +1168,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1140,7 +1182,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -1150,7 +1192,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -1160,7 +1202,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -1170,7 +1212,7 @@ describe("Entity builder", () => { setter: false, }, role: { - reference: "scalar", + kind: "scalar", enum: true, items: expect.any(Function), nullable: true, @@ -1179,7 +1221,7 @@ describe("Entity builder", () => { type: "string", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1191,7 +1233,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1204,7 +1246,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1271,6 +1313,10 @@ describe("Entity builder", () => { expect(metaData.tableName).toEqual("public.user") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1281,7 +1327,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -1291,7 +1337,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -1301,7 +1347,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -1311,7 +1357,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1323,7 +1369,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1336,7 +1382,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1373,6 +1419,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1383,7 +1433,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -1393,7 +1443,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -1403,7 +1453,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1419,14 +1469,14 @@ describe("Entity builder", () => { name: "phones", fieldName: "phones", nullable: false, - reference: "scalar", + kind: "scalar", default: JSON.stringify({ number: "22222222" }), setter: false, columnType: "jsonb", type: "any", }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1439,7 +1489,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1471,6 +1521,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("Tax") expect(metaData.filters).toEqual({ + freeTextSearch_Tax: { + cond: expect.any(Function), + name: "freeTextSearch_Tax", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1481,7 +1535,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -1491,18 +1545,19 @@ describe("Entity builder", () => { setter: false, }, rate: { - reference: "scalar", + kind: "scalar", type: "number", + runtimeType: "number", columnType: "real", name: "rate", fieldName: "rate", - serializer: Number, + serializer: expect.any(Function), nullable: false, getter: false, setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1514,7 +1569,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1527,7 +1582,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1566,6 +1621,10 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1576,7 +1635,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -1586,7 +1645,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -1601,11 +1660,11 @@ describe("Entity builder", () => { mappedBy: "user", name: "emails", orphanRemoval: true, - reference: "1:m", + kind: "1:m", searchable: true, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1617,7 +1676,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1630,7 +1689,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1674,6 +1733,10 @@ describe("Entity builder", () => { }) expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1684,7 +1747,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "id", @@ -1694,7 +1757,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -1704,7 +1767,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -1714,7 +1777,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1726,7 +1789,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1739,7 +1802,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1784,6 +1847,10 @@ describe("Entity builder", () => { }) expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1794,7 +1861,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "id", @@ -1803,7 +1870,7 @@ describe("Entity builder", () => { primary: true, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -1813,7 +1880,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -1823,7 +1890,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1835,7 +1902,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1848,7 +1915,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1895,6 +1962,10 @@ describe("Entity builder", () => { }) expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -1905,7 +1976,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "id", @@ -1914,7 +1985,7 @@ describe("Entity builder", () => { primary: true, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -1924,7 +1995,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -1934,7 +2005,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -1946,7 +2017,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -1959,7 +2030,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -1992,7 +2063,7 @@ describe("Entity builder", () => { name: "id", fieldName: "id", nullable: false, - reference: "scalar", + kind: "scalar", type: "string", primary: true, }) @@ -2001,7 +2072,7 @@ describe("Entity builder", () => { name: "email", fieldName: "email", nullable: false, - reference: "scalar", + kind: "scalar", type: "string", primary: true, }) @@ -2047,6 +2118,10 @@ describe("Entity builder", () => { ]) expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -2057,7 +2132,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2067,7 +2142,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2077,7 +2152,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -2087,7 +2162,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2099,7 +2174,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2112,7 +2187,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2163,6 +2238,10 @@ describe("Entity builder", () => { ]) expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -2173,7 +2252,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2183,7 +2262,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2193,7 +2272,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -2203,7 +2282,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2215,7 +2294,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2228,7 +2307,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2278,6 +2357,10 @@ describe("Entity builder", () => { ]) expect(metaData.filters).toEqual({ + freeTextSearch_User: { + cond: expect.any(Function), + name: "freeTextSearch_User", + }, softDeletable: { name: "softDeletable", cond: expect.any(Function), @@ -2288,7 +2371,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2298,7 +2381,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2308,7 +2391,7 @@ describe("Entity builder", () => { setter: false, }, myEmail: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "myEmail", @@ -2318,7 +2401,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2330,7 +2413,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2343,7 +2426,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2391,7 +2474,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2401,7 +2484,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2411,13 +2494,13 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "user", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2429,7 +2512,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2442,7 +2525,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2484,7 +2567,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2494,7 +2577,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2504,14 +2587,14 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:1", + kind: "1:1", name: "emails", entity: "Email", nullable: true, mappedBy: "user", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2523,7 +2606,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2536,7 +2619,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2572,7 +2655,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2582,7 +2665,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2592,13 +2675,13 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", onDelete: undefined, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2610,7 +2693,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2623,7 +2706,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2659,7 +2742,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2669,7 +2752,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2679,13 +2762,13 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "owner", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2697,7 +2780,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2710,7 +2793,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2750,7 +2833,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2760,7 +2843,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2770,15 +2853,15 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "user", cascade: ["persist", "soft-remove"], - onDelete: "cascade", + deleteRule: "cascade", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2790,7 +2873,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2803,7 +2886,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2820,7 +2903,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -2830,7 +2913,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -2840,7 +2923,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2852,7 +2935,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2865,7 +2948,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2913,7 +2996,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -2923,7 +3006,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -2933,14 +3016,14 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "user", - onDelete: "cascade", + deleteRule: "cascade", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -2952,7 +3035,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -2965,7 +3048,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -2982,7 +3065,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -2992,7 +3075,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -3007,9 +3090,9 @@ describe("Entity builder", () => { mappedBy: "email", name: "user", nullable: false, - onDelete: "cascade", + deleteRule: "cascade", owner: true, - reference: "1:1", + kind: "1:1", cascade: ["persist", "soft-remove"], }, user_id: { @@ -3019,12 +3102,12 @@ describe("Entity builder", () => { name: "user_id", nullable: false, formula: expect.any(Function), - reference: "scalar", + kind: "scalar", setter: false, type: "string", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3036,7 +3119,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3049,7 +3132,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3101,7 +3184,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -3111,7 +3194,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -3121,7 +3204,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", fieldName: "email_id", @@ -3129,7 +3212,7 @@ describe("Entity builder", () => { email_id: { columnType: "text", type: "string", - reference: "scalar", + kind: "scalar", name: "email_id", formula: expect.any(Function), nullable: false, @@ -3138,7 +3221,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3150,7 +3233,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3163,7 +3246,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3212,7 +3295,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -3222,7 +3305,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -3232,7 +3315,7 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:1", + kind: "1:1", name: "emails", entity: "Email", nullable: true, @@ -3241,7 +3324,7 @@ describe("Entity builder", () => { emails_id: { columnType: "text", type: "string", - reference: "scalar", + kind: "scalar", name: "emails_id", formula: expect.any(Function), nullable: true, @@ -3250,7 +3333,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3262,7 +3345,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3275,7 +3358,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3315,7 +3398,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -3325,7 +3408,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -3335,7 +3418,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "owner", @@ -3344,7 +3427,7 @@ describe("Entity builder", () => { email_id: { columnType: "text", type: "string", - reference: "scalar", + kind: "scalar", name: "email_id", formula: expect.any(Function), nullable: false, @@ -3353,7 +3436,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3365,7 +3448,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3378,7 +3461,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3421,7 +3504,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -3431,7 +3514,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -3441,7 +3524,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", cascade: ["persist", "soft-remove"], @@ -3451,7 +3534,7 @@ describe("Entity builder", () => { email_id: { columnType: "text", type: "string", - reference: "scalar", + kind: "scalar", name: "email_id", formula: expect.any(Function), nullable: false, @@ -3460,7 +3543,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3472,7 +3555,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3485,7 +3568,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3502,7 +3585,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -3512,7 +3595,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -3522,7 +3605,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3534,7 +3617,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3547,7 +3630,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3598,7 +3681,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -3608,7 +3691,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -3618,7 +3701,7 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", cascade: ["persist", "soft-remove"], @@ -3628,7 +3711,7 @@ describe("Entity builder", () => { email_id: { columnType: "text", type: "string", - reference: "scalar", + kind: "scalar", formula: expect.any(Function), name: "email_id", nullable: false, @@ -3637,7 +3720,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3649,7 +3732,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3662,7 +3745,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3679,7 +3762,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -3689,7 +3772,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -3703,9 +3786,9 @@ describe("Entity builder", () => { mappedBy: "email", name: "user", nullable: false, - onDelete: "cascade", + deleteRule: "cascade", owner: true, - reference: "1:1", + kind: "1:1", cascade: ["persist", "soft-remove"], fieldName: "user_id", }, @@ -3714,14 +3797,14 @@ describe("Entity builder", () => { getter: false, name: "user_id", nullable: false, - reference: "scalar", + kind: "scalar", formula: expect.any(Function), setter: false, type: "string", persist: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -3733,7 +3816,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -3746,7 +3829,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -3796,7 +3879,7 @@ describe("Entity builder", () => { expect(metaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -3806,7 +3889,7 @@ describe("Entity builder", () => { setter: false, }, account: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "account", @@ -3821,7 +3904,7 @@ describe("Entity builder", () => { name: "organization", fieldName: "organization", nullable: false, - reference: "scalar", + kind: "scalar", setter: false, type: "string", }, @@ -3831,7 +3914,7 @@ describe("Entity builder", () => { name: "group", nullable: false, persist: false, - reference: "m:1", + kind: "m:1", }, group_id: { columnType: "text", @@ -3841,7 +3924,7 @@ describe("Entity builder", () => { name: "group_id", nullable: false, onDelete: undefined, - reference: "m:1", + kind: "m:1", }, ...defaultColumnMetadata, }) @@ -4079,7 +4162,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -4089,7 +4172,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -4099,14 +4182,14 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:m", + kind: "1:m", name: "emails", entity: "Email", orphanRemoval: true, mappedBy: "user", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4118,7 +4201,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4131,7 +4214,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4170,7 +4253,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -4180,7 +4263,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -4190,14 +4273,14 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:m", + kind: "1:m", name: "emails", entity: "Email", mappedBy: "the_user", orphanRemoval: true, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4209,7 +4292,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4222,7 +4305,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4262,7 +4345,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -4272,7 +4355,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -4282,7 +4365,7 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:m", + kind: "1:m", name: "emails", entity: "Email", orphanRemoval: true, @@ -4290,7 +4373,7 @@ describe("Entity builder", () => { cascade: ["persist", "soft-remove"], }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4302,7 +4385,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4315,7 +4398,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4357,7 +4440,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -4367,7 +4450,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -4377,7 +4460,7 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:m", + kind: "1:m", name: "emails", entity: "Email", orphanRemoval: true, @@ -4385,7 +4468,7 @@ describe("Entity builder", () => { cascade: ["persist", "soft-remove"], }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4397,7 +4480,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4410,7 +4493,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4426,7 +4509,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -4436,7 +4519,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -4451,7 +4534,7 @@ describe("Entity builder", () => { name: "user", nullable: false, persist: false, - reference: "m:1", + kind: "m:1", }, user_id: { columnType: "text", @@ -4460,11 +4543,11 @@ describe("Entity builder", () => { fieldName: "user_id", name: "user_id", nullable: false, - onDelete: "cascade", - reference: "m:1", + deleteRule: "cascade", + kind: "m:1", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4476,7 +4559,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4489,7 +4572,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4561,7 +4644,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -4571,7 +4654,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -4581,13 +4664,13 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "user", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4599,7 +4682,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4612,7 +4695,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4628,7 +4711,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -4638,7 +4721,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -4650,7 +4733,7 @@ describe("Entity builder", () => { user: { name: "user", fieldName: "user_id", - reference: "1:1", + kind: "1:1", entity: "User", nullable: false, mappedBy: "email", @@ -4658,7 +4741,7 @@ describe("Entity builder", () => { owner: true, }, user_id: { - reference: "scalar", + kind: "scalar", persist: false, type: "string", formula: expect.any(Function), @@ -4669,7 +4752,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4681,7 +4764,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4694,7 +4777,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4722,7 +4805,7 @@ describe("Entity builder", () => { const User = toMikroORMEntity(user) const Email = toMikroORMEntity(email) - expectTypeOf(new User()).toMatchTypeOf<{ + expectTypeOf(new User()).toEqualTypeOf<{ id: number username: string email: { @@ -4731,9 +4814,20 @@ describe("Entity builder", () => { user: { id: number username: string - } | null + email: any + created_at: Date + updated_at: Date + deleted_at: Date | null + } + created_at: Date + updated_at: Date + deleted_at: Date | null + user_id: string | null } - }>() + created_at: Date + updated_at: Date + deleted_at: Date | null + }>({} as any) const userInstance = new User() expectTypeOf<(typeof userInstance)["email"]["user_id"]>().toEqualTypeOf< @@ -4749,6 +4843,11 @@ describe("Entity builder", () => { email: { email: string isVerified: boolean + user: any + created_at: Date + updated_at: Date + deleted_at: Date | null + user_id: string | null } } | null }>() @@ -4759,7 +4858,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -4769,7 +4868,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -4779,13 +4878,13 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "user", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4797,7 +4896,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4810,7 +4909,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4826,7 +4925,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -4836,7 +4935,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -4848,7 +4947,7 @@ describe("Entity builder", () => { user: { name: "user", fieldName: "user_id", - reference: "1:1", + kind: "1:1", entity: "User", nullable: true, onDelete: undefined, @@ -4856,7 +4955,7 @@ describe("Entity builder", () => { owner: true, }, user_id: { - reference: "scalar", + kind: "scalar", persist: false, type: "string", columnType: "text", @@ -4867,7 +4966,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4879,7 +4978,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -4892,7 +4991,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -4951,7 +5050,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -4961,7 +5060,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -4971,14 +5070,14 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:m", + kind: "1:m", name: "emails", entity: "Email", mappedBy: "user", orphanRemoval: true, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -4990,7 +5089,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5003,7 +5102,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5019,7 +5118,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -5029,7 +5128,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -5040,7 +5139,7 @@ describe("Entity builder", () => { }, user: { name: "user", - reference: "m:1", + kind: "m:1", entity: "User", fieldName: "user_id", persist: false, @@ -5048,7 +5147,7 @@ describe("Entity builder", () => { }, user_id: { name: "user_id", - reference: "m:1", + kind: "m:1", entity: "User", columnType: "text", mapToPk: true, @@ -5056,7 +5155,7 @@ describe("Entity builder", () => { nullable: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5068,7 +5167,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5081,7 +5180,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5140,7 +5239,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -5150,7 +5249,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -5160,14 +5259,14 @@ describe("Entity builder", () => { setter: false, }, emails: { - reference: "1:m", + kind: "1:m", name: "emails", entity: "Email", mappedBy: "user", orphanRemoval: true, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5179,7 +5278,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5192,7 +5291,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5208,7 +5307,7 @@ describe("Entity builder", () => { expect(emailMetaData.path).toEqual("Email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -5218,7 +5317,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -5229,7 +5328,7 @@ describe("Entity builder", () => { }, user: { name: "user", - reference: "m:1", + kind: "m:1", fieldName: "user_id", entity: "User", persist: false, @@ -5237,7 +5336,7 @@ describe("Entity builder", () => { }, user_id: { name: "user_id", - reference: "m:1", + kind: "m:1", entity: "User", columnType: "text", mapToPk: true, @@ -5245,7 +5344,7 @@ describe("Entity builder", () => { nullable: true, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5257,7 +5356,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5270,7 +5369,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5377,7 +5476,7 @@ describe("Entity builder", () => { expect(metaData.tableName).toEqual("platform.user") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -5387,7 +5486,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -5397,13 +5496,13 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "user", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5415,7 +5514,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5428,7 +5527,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5445,7 +5544,7 @@ describe("Entity builder", () => { expect(emailMetaData.tableName).toEqual("platform.email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -5455,7 +5554,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -5467,7 +5566,7 @@ describe("Entity builder", () => { user: { name: "user", fieldName: "user_id", - reference: "1:1", + kind: "1:1", entity: "User", nullable: false, mappedBy: "email", @@ -5475,7 +5574,7 @@ describe("Entity builder", () => { owner: true, }, user_id: { - reference: "scalar", + kind: "scalar", type: "string", persist: false, columnType: "text", @@ -5486,7 +5585,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5498,7 +5597,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5511,7 +5610,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5577,7 +5676,7 @@ describe("Entity builder", () => { expect(metaData.tableName).toEqual("public.user") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -5587,7 +5686,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -5597,13 +5696,13 @@ describe("Entity builder", () => { setter: false, }, email: { - reference: "1:1", + kind: "1:1", name: "email", entity: "Email", mappedBy: "user", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5615,7 +5714,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5628,7 +5727,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5645,7 +5744,7 @@ describe("Entity builder", () => { expect(emailMetaData.tableName).toEqual("platform.email") expect(emailMetaData.properties).toEqual({ email: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "email", @@ -5655,7 +5754,7 @@ describe("Entity builder", () => { setter: false, }, isVerified: { - reference: "scalar", + kind: "scalar", type: "boolean", columnType: "boolean", name: "isVerified", @@ -5667,7 +5766,7 @@ describe("Entity builder", () => { user: { name: "user", fieldName: "user_id", - reference: "1:1", + kind: "1:1", entity: "User", nullable: false, mappedBy: "email", @@ -5675,7 +5774,7 @@ describe("Entity builder", () => { owner: true, }, user_id: { - reference: "scalar", + kind: "scalar", persist: false, type: "string", columnType: "text", @@ -5686,7 +5785,7 @@ describe("Entity builder", () => { setter: false, }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5698,7 +5797,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5711,7 +5810,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5754,7 +5853,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -5764,7 +5863,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -5776,14 +5875,14 @@ describe("Entity builder", () => { parent: { name: "parent", fieldName: "parent_id", - reference: "m:1", + kind: "m:1", entity: "User", persist: false, nullable: false, }, parent_id: { name: "parent_id", - reference: "m:1", + kind: "m:1", entity: "User", columnType: "text", fieldName: "parent_id", @@ -5797,10 +5896,10 @@ describe("Entity builder", () => { mappedBy: "parent", name: "children", orphanRemoval: true, - reference: "1:m", + kind: "1:m", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5812,7 +5911,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5825,7 +5924,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -5868,7 +5967,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -5878,7 +5977,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -5891,7 +5990,7 @@ describe("Entity builder", () => { name: "parent", fieldName: "parent_id", mappedBy: "child", - reference: "1:1", + kind: "1:1", entity: "User", nullable: false, onDelete: undefined, @@ -5901,7 +6000,7 @@ describe("Entity builder", () => { name: "parent_id", type: "string", columnType: "text", - reference: "scalar", + kind: "scalar", formula: expect.any(Function), persist: false, getter: false, @@ -5913,10 +6012,10 @@ describe("Entity builder", () => { entity: "User", mappedBy: "parent", name: "child", - reference: "1:1", + kind: "1:1", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -5928,7 +6027,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -5941,7 +6040,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6004,7 +6103,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6014,7 +6113,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -6024,7 +6123,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: false, @@ -6032,7 +6131,7 @@ describe("Entity builder", () => { mappedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6044,7 +6143,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6057,7 +6156,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6073,7 +6172,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("Team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6083,7 +6182,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -6093,7 +6192,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", inversedBy: "teams", entity: "User", @@ -6101,7 +6200,7 @@ describe("Entity builder", () => { pivotTable: "team_users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6113,7 +6212,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6126,7 +6225,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6185,7 +6284,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6195,7 +6294,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -6205,7 +6304,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: false, @@ -6213,7 +6312,7 @@ describe("Entity builder", () => { mappedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6225,7 +6324,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6238,7 +6337,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6254,7 +6353,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("Team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6264,7 +6363,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -6274,7 +6373,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", entity: "User", owner: true, @@ -6282,7 +6381,7 @@ describe("Entity builder", () => { pivotTable: "team_users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6294,7 +6393,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6307,7 +6406,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6360,8 +6459,8 @@ describe("Entity builder", () => { expect(teamUserMetadata.properties).toEqual( expect.objectContaining({ user_id: { - reference: "scalar", - type: "User", + kind: "scalar", + type: "string", columnType: "text", fieldName: "user_id", nullable: false, @@ -6371,15 +6470,15 @@ describe("Entity builder", () => { }, user: { name: "user", - reference: "m:1", + kind: "m:1", entity: "User", nullable: false, persist: false, - onDelete: "cascade", + deleteRule: "cascade", }, team_id: { - reference: "scalar", - type: "Team", + kind: "scalar", + type: "string", columnType: "text", fieldName: "team_id", nullable: false, @@ -6389,11 +6488,11 @@ describe("Entity builder", () => { }, team: { name: "team", - reference: "m:1", + kind: "m:1", entity: "Team", nullable: false, persist: false, - onDelete: "cascade", + deleteRule: "cascade", }, }) ) @@ -6480,7 +6579,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6490,7 +6589,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -6500,7 +6599,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: false, @@ -6508,7 +6607,7 @@ describe("Entity builder", () => { mappedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6520,7 +6619,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6533,7 +6632,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6549,7 +6648,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("Team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6559,7 +6658,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -6569,7 +6668,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", entity: "User", owner: true, @@ -6577,7 +6676,7 @@ describe("Entity builder", () => { inversedBy: "teams", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6589,7 +6688,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6602,7 +6701,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6661,7 +6760,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6671,7 +6770,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -6681,7 +6780,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: false, @@ -6689,7 +6788,7 @@ describe("Entity builder", () => { mappedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6701,7 +6800,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6714,7 +6813,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6730,7 +6829,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("Team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6740,7 +6839,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -6750,7 +6849,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", entity: "User", owner: true, @@ -6758,7 +6857,7 @@ describe("Entity builder", () => { inversedBy: "teams", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6770,7 +6869,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6783,7 +6882,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6860,7 +6959,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6870,7 +6969,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -6880,7 +6979,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: false, @@ -6888,7 +6987,7 @@ describe("Entity builder", () => { mappedBy: "users", }, activeTeams: { - reference: "m:n", + kind: "m:n", name: "activeTeams", entity: "Team", owner: false, @@ -6896,7 +6995,7 @@ describe("Entity builder", () => { mappedBy: "activeTeamsUsers", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6908,7 +7007,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6921,7 +7020,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -6937,7 +7036,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("Team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -6947,7 +7046,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -6957,7 +7056,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", entity: "User", owner: true, @@ -6965,7 +7064,7 @@ describe("Entity builder", () => { inversedBy: "teams", }, activeTeamsUsers: { - reference: "m:n", + kind: "m:n", name: "activeTeamsUsers", entity: "User", owner: true, @@ -6973,7 +7072,7 @@ describe("Entity builder", () => { inversedBy: "activeTeams", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -6985,7 +7084,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -6998,7 +7097,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7060,7 +7159,7 @@ describe("Entity builder", () => { expect(metaData.tableName).toEqual("platform.user") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7070,7 +7169,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -7080,7 +7179,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: false, @@ -7088,7 +7187,7 @@ describe("Entity builder", () => { mappedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7100,7 +7199,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7113,7 +7212,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7130,7 +7229,7 @@ describe("Entity builder", () => { expect(teamMetaData.tableName).toEqual("platform.team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7140,7 +7239,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -7150,7 +7249,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", entity: "User", owner: true, @@ -7158,7 +7257,7 @@ describe("Entity builder", () => { pivotTable: "platform.team_users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7170,7 +7269,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7183,7 +7282,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7218,7 +7317,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("RandomUser") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7228,7 +7327,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -7238,7 +7337,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "TeamSquad", owner: true, @@ -7246,7 +7345,7 @@ describe("Entity builder", () => { inversedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7258,7 +7357,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7271,7 +7370,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7287,7 +7386,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("TeamSquad") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7297,7 +7396,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -7307,7 +7406,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", entity: "RandomUser", owner: false, @@ -7315,7 +7414,7 @@ describe("Entity builder", () => { pivotTable: "random_user_team_squads", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7327,7 +7426,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7340,7 +7439,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7402,7 +7501,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7412,7 +7511,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -7422,7 +7521,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: true, @@ -7430,7 +7529,7 @@ describe("Entity builder", () => { inversedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7442,7 +7541,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7455,7 +7554,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7471,7 +7570,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("Team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7481,7 +7580,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -7491,7 +7590,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", owner: false, entity: "User", @@ -7499,7 +7598,7 @@ describe("Entity builder", () => { pivotTable: "users_teams", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7511,7 +7610,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7524,7 +7623,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7595,7 +7694,7 @@ describe("Entity builder", () => { expect(squadMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", columnType: "integer", type: "number", nullable: false, @@ -7606,16 +7705,16 @@ describe("Entity builder", () => { }, user_id: { name: "user_id", - reference: "scalar", + kind: "scalar", columnType: "text", fieldName: "user_id", getter: false, setter: false, nullable: false, - type: "User", + type: "string", }, user: { - reference: "m:1", + kind: "m:1", entity: "User", persist: false, nullable: false, @@ -7623,23 +7722,23 @@ describe("Entity builder", () => { }, team_id: { name: "team_id", - reference: "scalar", + kind: "scalar", columnType: "text", fieldName: "team_id", nullable: false, getter: false, setter: false, - type: "Team", + type: "string", }, team: { - reference: "m:1", + kind: "m:1", entity: "Team", persist: false, nullable: false, name: "team", }, created_at: { - reference: "scalar", + kind: "scalar", columnType: "timestamptz", type: "date", nullable: false, @@ -7651,7 +7750,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", columnType: "timestamptz", type: "date", nullable: false, @@ -7664,7 +7763,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", columnType: "timestamptz", type: "date", nullable: true, @@ -7680,7 +7779,7 @@ describe("Entity builder", () => { expect(teamMetaData.path).toEqual("Team") expect(teamMetaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7690,7 +7789,7 @@ describe("Entity builder", () => { setter: false, }, name: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "name", @@ -7700,7 +7799,7 @@ describe("Entity builder", () => { setter: false, }, users: { - reference: "m:n", + kind: "m:n", name: "users", entity: "User", owner: true, @@ -7708,7 +7807,7 @@ describe("Entity builder", () => { pivotEntity: "TeamUsers", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7720,7 +7819,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7733,7 +7832,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", @@ -7749,7 +7848,7 @@ describe("Entity builder", () => { expect(metaData.path).toEqual("User") expect(metaData.properties).toEqual({ id: { - reference: "scalar", + kind: "scalar", type: "number", columnType: "integer", name: "id", @@ -7759,7 +7858,7 @@ describe("Entity builder", () => { setter: false, }, username: { - reference: "scalar", + kind: "scalar", type: "string", columnType: "text", name: "username", @@ -7769,7 +7868,7 @@ describe("Entity builder", () => { setter: false, }, teams: { - reference: "m:n", + kind: "m:n", name: "teams", entity: "Team", owner: false, @@ -7777,7 +7876,7 @@ describe("Entity builder", () => { mappedBy: "users", }, created_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "created_at", @@ -7789,7 +7888,7 @@ describe("Entity builder", () => { setter: false, }, updated_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "updated_at", @@ -7802,7 +7901,7 @@ describe("Entity builder", () => { setter: false, }, deleted_at: { - reference: "scalar", + kind: "scalar", type: "date", columnType: "timestamptz", name: "deleted_at", diff --git a/packages/core/utils/src/dml/entity-builder.ts b/packages/core/utils/src/dml/entity-builder.ts index 0d473a6871842..9da9b3a2db786 100644 --- a/packages/core/utils/src/dml/entity-builder.ts +++ b/packages/core/utils/src/dml/entity-builder.ts @@ -6,6 +6,7 @@ import { import { DmlEntity, DMLEntitySchemaBuilder } from "./entity" import { createBigNumberProperties } from "./helpers/entity-builder/create-big-number-properties" import { createDefaultProperties } from "./helpers/entity-builder/create-default-properties" +import { FloatProperty } from "./properties" import { ArrayProperty } from "./properties/array" import { AutoIncrementProperty } from "./properties/autoincrement" import { BigNumberProperty } from "./properties/big-number" @@ -21,7 +22,6 @@ import { HasMany } from "./relations/has-many" import { HasOne } from "./relations/has-one" import { HasOneWithForeignKey } from "./relations/has-one-fk" import { ManyToMany } from "./relations/many-to-many" -import { FloatProperty } from "./properties" /** * The implicit properties added by EntityBuilder in every schema @@ -128,7 +128,7 @@ export class EntityBuilder { ): DmlEntity, TConfig> { this.#disallowImplicitProperties(schema) - return new DmlEntity(nameOrConfig, { + return new DmlEntity(nameOrConfig, { ...schema, ...createBigNumberProperties(schema), ...createDefaultProperties(), diff --git a/packages/core/utils/src/dml/entity.ts b/packages/core/utils/src/dml/entity.ts index ddcfb2e753ef7..0db09781da485 100644 --- a/packages/core/utils/src/dml/entity.ts +++ b/packages/core/utils/src/dml/entity.ts @@ -1,21 +1,19 @@ import { - IDmlEntity, - DMLSchema, - EntityIndex, CheckConstraint, + DMLSchema, EntityCascades, - QueryCondition, - IDmlEntityConfig, + EntityIndex, ExtractEntityRelations, + IDmlEntity, + IDmlEntityConfig, InferDmlEntityNameFromConfig, + QueryCondition, } from "@medusajs/types" import { isObject, isString, toCamelCase, upperCaseFirst } from "../common" 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 { - DMLSchemaDefaults, - DMLSchemaWithBigNumber, -} from "./helpers/entity-builder" const IsDmlEntity = Symbol.for("isDmlEntity") @@ -68,7 +66,7 @@ function extractNameAndTableName( * name, its schema and relationships. */ export class DmlEntity< - Schema extends DMLSchema, + const Schema extends DMLSchema, const TConfig extends IDmlEntityConfig > implements IDmlEntity { @@ -79,6 +77,7 @@ export class DmlEntity< readonly #tableName: string #cascades: EntityCascades = {} + #indexes: EntityIndex[] = [] #checks: CheckConstraint[] = [] @@ -251,8 +250,6 @@ export class DmlEntity< return this } - /** - */ checks(checks: CheckConstraint[]) { this.#checks = checks return this diff --git a/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts b/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts index 5fca76d11111b..d5ed8f85d9c35 100644 --- a/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts +++ b/packages/core/utils/src/dml/helpers/create-mikro-orm-entity.ts @@ -8,15 +8,18 @@ import type { } from "@medusajs/types" import { Entity, Filter } from "@mikro-orm/core" +import { + mikroOrmFreeTextSearchFilterOptionsFactory, + mikroOrmSoftDeletableFilterOptions, +} from "../../dal" import { DmlEntity } from "../entity" -import { IdProperty } from "../properties/id" import { DuplicateIdPropertyError } from "../errors" -import { applyChecks } from "./mikro-orm/apply-checks" -import { mikroOrmSoftDeletableFilterOptions } from "../../dal" -import { defineProperty } from "./entity-builder/define-property" +import { IdProperty } from "../properties/id" 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 { parseEntityName } from "./entity-builder/parse-entity-name" +import { applyChecks } from "./mikro-orm/apply-checks" import { applyEntityIndexes, applyIndexes } from "./mikro-orm/apply-indexes" /** @@ -48,8 +51,16 @@ function createMikrORMEntity() { function createEntity>(entity: T): Infer { class MikroORMEntity {} - const { schema, cascades, indexes: entityIndexes, checks } = entity.parse() + const { + schema, + cascades, + indexes: entityIndexes = [], + //params, + checks, + } = entity.parse() + const { modelName, tableName } = parseEntityName(entity) + if (ENTITIES[modelName]) { return ENTITIES[modelName] as Infer } @@ -102,6 +113,9 @@ function createMikrORMEntity() { /** * Converting class to a MikroORM entity */ + Filter(mikroOrmFreeTextSearchFilterOptionsFactory(modelName))( + MikroORMEntity + ) const RegisteredEntity = Entity({ tableName })( Filter(mikroOrmSoftDeletableFilterOptions)(MikroORMEntity) ) as Infer diff --git a/packages/core/utils/src/dml/helpers/entity-builder/define-property.ts b/packages/core/utils/src/dml/helpers/entity-builder/define-property.ts index 4504a3d0919bc..dcd68a656779b 100644 --- a/packages/core/utils/src/dml/helpers/entity-builder/define-property.ts +++ b/packages/core/utils/src/dml/helpers/entity-builder/define-property.ts @@ -12,7 +12,6 @@ import { PrimaryKey, Property, Utils, - t as mikroOrmType, } from "@mikro-orm/core" import { generateEntityId, isDefined } from "../../../common" import { MikroOrmBigNumberProperty } from "../../../dal" @@ -122,7 +121,8 @@ export function defineProperty( ) { 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) { const defaultValueSetterHookName = `${field.fieldName}_setDefaultValueOnBeforeCreate` @@ -274,11 +274,12 @@ export function defineProperty( : Property Prop({ - columnType: "serial", - type: mikroOrmType.integer, - nullable: true, + autoincrement: true, + type: "number", + runtimeType: "number", + nullable: field.nullable, fieldName: field.fieldName, - serializer: Number, + serializer: (value) => (value == null ? value : Number(value)), })(MikroORMEntity.prototype, field.fieldName) return } @@ -290,13 +291,14 @@ export function defineProperty( Property({ columnType: "real", type: "number", + runtimeType: "number", nullable: field.nullable, fieldName: field.fieldName, /** * Applying number serializer to convert value back to a * JavaScript number */ - serializer: Number, + serializer: (value) => (value == null ? value : Number(value)), /** * MikroORM does not ignore undefined values for default when generating * the database schema SQL. Conditionally add it here to prevent undefined diff --git a/packages/core/utils/src/dml/helpers/entity-builder/define-relationship.ts b/packages/core/utils/src/dml/helpers/entity-builder/define-relationship.ts index c1bfaf37d3687..8cf16e0b607ca 100644 --- a/packages/core/utils/src/dml/helpers/entity-builder/define-relationship.ts +++ b/packages/core/utils/src/dml/helpers/entity-builder/define-relationship.ts @@ -162,7 +162,7 @@ export function defineHasOneRelationship( entity: relatedModelName, ...(relationship.nullable ? { nullable: relationship.nullable } : {}), ...(mappedBy ? { mappedBy } : {}), - onDelete: shouldRemoveRelated ? "cascade" : undefined, + deleteRule: shouldRemoveRelated ? "cascade" : undefined, } as OneToOneOptions if (shouldRemoveRelated && !isOthersideBelongsTo) { @@ -322,7 +322,7 @@ export function defineBelongsToRelationship( /** * In DML the relationships are cascaded from parent to child. A belongsTo * 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. */ const shouldCascade = !!relationCascades.delete?.includes(mappedBy) @@ -435,27 +435,33 @@ export function defineBelongsToRelationship( if (DmlManyToMany.isManyToMany(otherSideRelation)) { Property({ - type: relatedModelName, + type: "string", columnType: "text", fieldName: foreignKeyName, nullable: relationship.nullable, })(MikroORMEntity.prototype, foreignKeyName) - ManyToOne({ + const conf = { entity: relatedModelName, nullable: relationship.nullable, persist: false, - onDelete: shouldCascade || detachCascade ? "cascade" : undefined, - })(MikroORMEntity.prototype, relationship.name) + } + if (shouldCascade || detachCascade) { + conf["deleteRule"] = "cascade" + } + ManyToOne(conf)(MikroORMEntity.prototype, relationship.name) } else { - ManyToOne({ + const conf = { entity: relatedModelName, columnType: "text", mapToPk: true, fieldName: foreignKeyName, nullable: relationship.nullable, - onDelete: shouldCascade ? "cascade" : undefined, - })(MikroORMEntity.prototype, foreignKeyName) + } + if (shouldCascade) { + conf["deleteRule"] = "cascade" + } + ManyToOne(conf)(MikroORMEntity.prototype, foreignKeyName) ManyToOne({ entity: relatedModelName, @@ -486,7 +492,6 @@ export function defineBelongsToRelationship( const foreignKeyName = relationship.options.foreignKeyName ?? camelToSnakeCase(`${relationship.name}Id`) - Property({ columnType: "text", type: "string", @@ -504,10 +509,10 @@ export function defineBelongsToRelationship( fieldName: foreignKeyName, owner: true, // orphanRemoval: true, - onDelete: shouldCascade ? "cascade" : undefined, } if (shouldCascade) { + oneToOneOptions.deleteRule = "cascade" oneToOneOptions.cascade = [Cascade.PERSIST, "soft-remove"] as any } @@ -741,8 +746,15 @@ export function defineManyToManyRelationship( : {}), ...(pivotEntityName ? { pivotEntity: pivotEntityName } : {}), ...({ [mappedByProp]: mappedByPropValue } as any), - [joinColumnProp]: joinColumn ?? joinColumns, - [inverseJoinColumnProp]: inverseJoinColumn ?? inverseJoinColumns, + } as any + + if (joinColumn || joinColumns) { + manytoManyOptions[joinColumnProp] = joinColumn ?? joinColumns + } + + if (inverseJoinColumn || inverseJoinColumns) { + manytoManyOptions[inverseJoinColumnProp] = + inverseJoinColumn ?? inverseJoinColumns } ManyToMany(manytoManyOptions)(MikroORMEntity.prototype, relationship.name) diff --git a/packages/core/utils/src/dml/index.ts b/packages/core/utils/src/dml/index.ts index 59ed09397612a..a99e40fb5c349 100644 --- a/packages/core/utils/src/dml/index.ts +++ b/packages/core/utils/src/dml/index.ts @@ -4,3 +4,5 @@ export * from "./helpers/entity-builder/index" export * from "./helpers/create-mikro-orm-entity" export * from "./relations/index" export * from "./properties/index" + +export * from "./helpers/entity-builder/index" diff --git a/packages/core/utils/src/dml/integration-tests/__tests__/entity.spec.ts b/packages/core/utils/src/dml/integration-tests/__tests__/entity.spec.ts index 6846ceee6fda7..f8d426cd17d77 100644 --- a/packages/core/utils/src/dml/integration-tests/__tests__/entity.spec.ts +++ b/packages/core/utils/src/dml/integration-tests/__tests__/entity.spec.ts @@ -1,15 +1,16 @@ +import { EntityConstructor } from "@medusajs/types" 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 { mikroORMEntityBuilder, toMikroOrmEntities, } 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 { FileSystem } from "../../../common" -import { join } from "path" export const fileSystem = new FileSystem( join(__dirname, "../../integration-tests-migrations-enum") @@ -40,19 +41,20 @@ describe("EntityBuilder", () => { await createDatabase({ databaseName: dbName }, pgGodCredentials) - orm = await MikroORM.init({ - entities: [User], - tsNode: true, - dbName, - password: pgGodCredentials.password, - host: pgGodCredentials.host, - user: pgGodCredentials.user, - type: "postgresql", - migrations: { - generator: CustomTsMigrationGenerator, - path: fileSystem.basePath, - }, - }) + orm = await MikroORM.init( + defineConfig({ + entities: [User], + tsNode: true, + dbName, + password: pgGodCredentials.password, + host: pgGodCredentials.host, + user: pgGodCredentials.user, + migrations: { + generator: CustomTsMigrationGenerator, + path: fileSystem.basePath, + }, + }) + ) const migrator = orm.getMigrator() await migrator.createMigration() diff --git a/packages/core/utils/src/dml/integration-tests/__tests__/enum.spec.ts b/packages/core/utils/src/dml/integration-tests/__tests__/enum.spec.ts index 8cbddb5b33c35..b193959076cfe 100644 --- a/packages/core/utils/src/dml/integration-tests/__tests__/enum.spec.ts +++ b/packages/core/utils/src/dml/integration-tests/__tests__/enum.spec.ts @@ -1,19 +1,20 @@ +import { EntityConstructor } from "@medusajs/types" import { CheckConstraintViolationException, 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 { mikroORMEntityBuilder, toMikroOrmEntities, } 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 { FileSystem } from "../../../common" -import { join } from "path" export const fileSystem = new FileSystem( join(__dirname, "../../integration-tests-migrations-enum") @@ -43,19 +44,20 @@ describe("EntityBuilder | enum", () => { await createDatabase({ databaseName: dbName }, pgGodCredentials) - orm = await MikroORM.init({ - entities: [User], - tsNode: true, - dbName, - password: pgGodCredentials.password, - host: pgGodCredentials.host, - user: pgGodCredentials.user, - type: "postgresql", - migrations: { - generator: CustomTsMigrationGenerator, - path: fileSystem.basePath, - }, - }) + orm = await MikroORM.init( + defineConfig({ + entities: [User], + tsNode: true, + dbName, + password: pgGodCredentials.password, + host: pgGodCredentials.host, + user: pgGodCredentials.user, + migrations: { + generator: CustomTsMigrationGenerator, + path: fileSystem.basePath, + }, + }) + ) const migrator = orm.getMigrator() await migrator.createMigration() diff --git a/packages/core/utils/src/dml/integration-tests/__tests__/has-one-belongs-to.spec.ts b/packages/core/utils/src/dml/integration-tests/__tests__/has-one-belongs-to.spec.ts index ba58d8b035d60..7fe0fded46981 100644 --- a/packages/core/utils/src/dml/integration-tests/__tests__/has-one-belongs-to.spec.ts +++ b/packages/core/utils/src/dml/integration-tests/__tests__/has-one-belongs-to.spec.ts @@ -1,15 +1,16 @@ +import { EntityConstructor } from "@medusajs/types" 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 { mikroORMEntityBuilder, toMikroOrmEntities, } 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 { FileSystem } from "../../../common" -import { join } from "path" export const fileSystem = new FileSystem( join(__dirname, "../../integration-tests-migrations-has-one-belongs-to") @@ -45,19 +46,20 @@ describe("hasOne - belongTo", () => { await createDatabase({ databaseName: dbName }, pgGodCredentials) - orm = await MikroORM.init({ - entities: [Team, User], - tsNode: true, - dbName, - password: pgGodCredentials.password, - host: pgGodCredentials.host, - user: pgGodCredentials.user, - type: "postgresql", - migrations: { - generator: CustomTsMigrationGenerator, - path: fileSystem.basePath, - }, - }) + orm = await MikroORM.init( + defineConfig({ + entities: [Team, User], + tsNode: true, + dbName, + password: pgGodCredentials.password, + host: pgGodCredentials.host, + user: pgGodCredentials.user, + migrations: { + generator: CustomTsMigrationGenerator, + path: fileSystem.basePath, + }, + }) + ) const migrator = orm.getMigrator() await migrator.createMigration() diff --git a/packages/core/utils/src/dml/integration-tests/__tests__/many-to-many.spec.ts b/packages/core/utils/src/dml/integration-tests/__tests__/many-to-many.spec.ts index b350e8de51187..d88db258d168f 100644 --- a/packages/core/utils/src/dml/integration-tests/__tests__/many-to-many.spec.ts +++ b/packages/core/utils/src/dml/integration-tests/__tests__/many-to-many.spec.ts @@ -1,15 +1,16 @@ -import { join } from "path" +import { EntityConstructor } from "@medusajs/types" 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 { mikroORMEntityBuilder, toMikroOrmEntities, } 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 { FileSystem } from "../../../common" jest.setTimeout(30000) @@ -62,19 +63,20 @@ describe("manyToMany - manyToMany", () => { await createDatabase({ databaseName: dbName }, pgGodCredentials) - orm = await MikroORM.init({ - entities: [Team, User, Squad], - tsNode: true, - dbName, - password: pgGodCredentials.password, - host: pgGodCredentials.host, - user: pgGodCredentials.user, - type: "postgresql", - migrations: { - generator: CustomTsMigrationGenerator, - path: fileSystem.basePath, - }, - }) + orm = await MikroORM.init( + defineConfig({ + entities: [Team, User, Squad], + tsNode: true, + dbName, + password: pgGodCredentials.password, + host: pgGodCredentials.host, + user: pgGodCredentials.user, + migrations: { + generator: CustomTsMigrationGenerator, + path: fileSystem.basePath, + }, + }) + ) const migrator = orm.getMigrator() await migrator.createMigration() diff --git a/packages/core/utils/src/dml/integration-tests/__tests__/many-to-one.spec.ts b/packages/core/utils/src/dml/integration-tests/__tests__/many-to-one.spec.ts index a44ce4826d71e..3fa4971a47f8e 100644 --- a/packages/core/utils/src/dml/integration-tests/__tests__/many-to-one.spec.ts +++ b/packages/core/utils/src/dml/integration-tests/__tests__/many-to-one.spec.ts @@ -1,21 +1,21 @@ +import { EntityConstructor } from "@medusajs/types" import { MetadataStorage, MikroORM } from "@mikro-orm/core" -import { model } from "../../entity-builder" -import { - mikroORMEntityBuilder, - toMikroOrmEntities, -} from "../../helpers/create-mikro-orm-entity" +import { defineConfig, SqlEntityManager } from "@mikro-orm/postgresql" +import { join } from "path" import { createDatabase, dropDatabase } from "pg-god" +import { FileSystem } from "../../../common" import { CustomTsMigrationGenerator, mikroOrmSerializer, mikroOrmUpdateDeletedAtRecursively, SoftDeletableFilterKey, } 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 { FileSystem } from "../../../common" -import { join } from "path" -import { SqlEntityManager } from "@mikro-orm/postgresql" export const fileSystem = new FileSystem( join(__dirname, "../../integration-tests-migrations-many-to-one") @@ -55,19 +55,20 @@ describe("manyToOne - belongTo", () => { await createDatabase({ databaseName: dbName }, pgGodCredentials) - orm = await MikroORM.init({ - entities: [Team, User], - tsNode: true, - dbName, - password: pgGodCredentials.password, - host: pgGodCredentials.host, - user: pgGodCredentials.user, - type: "postgresql", - migrations: { - generator: CustomTsMigrationGenerator, - path: fileSystem.basePath, - }, - }) + orm = await MikroORM.init( + defineConfig({ + entities: [Team, User], + tsNode: true, + dbName, + password: pgGodCredentials.password, + host: pgGodCredentials.host, + user: pgGodCredentials.user, + migrations: { + generator: CustomTsMigrationGenerator, + path: fileSystem.basePath, + }, + }) + ) const migrator = orm.getMigrator() await migrator.createMigration() diff --git a/packages/core/utils/src/dml/integration-tests/utils.ts b/packages/core/utils/src/dml/integration-tests/utils.ts index 687c8942fd600..865ee07aaf421 100644 --- a/packages/core/utils/src/dml/integration-tests/utils.ts +++ b/packages/core/utils/src/dml/integration-tests/utils.ts @@ -1,5 +1,5 @@ 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 ?? "" export const pgGodCredentials = { diff --git a/packages/core/utils/src/dml/properties/number.ts b/packages/core/utils/src/dml/properties/number.ts index a541bd3783224..36affe4d5af31 100644 --- a/packages/core/utils/src/dml/properties/number.ts +++ b/packages/core/utils/src/dml/properties/number.ts @@ -8,7 +8,10 @@ import { PrimaryKeyModifier } from "./primary-key" export class NumberProperty extends BaseProperty { protected dataType: { name: "number" - options: {} + options: { + primaryKey?: boolean + searchable?: boolean + } } /** @@ -30,6 +33,27 @@ export class NumberProperty extends BaseProperty { return new PrimaryKeyModifier(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 }) { super() diff --git a/packages/core/utils/src/migrations/index.ts b/packages/core/utils/src/migrations/index.ts index b3f09f8268c75..3b3c9564695e5 100644 --- a/packages/core/utils/src/migrations/index.ts +++ b/packages/core/utils/src/migrations/index.ts @@ -4,7 +4,7 @@ import { MigrationResult, UmzugMigration, } from "@mikro-orm/migrations" -import { PostgreSqlDriver } from "@mikro-orm/postgresql" +import { defineConfig, PostgreSqlDriver } from "@mikro-orm/postgresql" import { EventEmitter } from "events" import { access, mkdir, writeFile } from "fs/promises" import { dirname } from "path" @@ -42,13 +42,15 @@ export class Migrations extends EventEmitter { return this.#configOrConnection as MikroORM } - return await MikroORM.init({ - ...this.#configOrConnection, - migrations: { - ...this.#configOrConnection.migrations, - silent: true, - }, - }) + return await MikroORM.init( + defineConfig({ + ...(this.#configOrConnection as any), + migrations: { + ...this.#configOrConnection.migrations, + silent: true, + }, + }) + ) } /** diff --git a/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-revert.spec.ts b/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-revert.spec.ts index 1cd6dab42a62e..50de45462ad32 100644 --- a/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-revert.spec.ts +++ b/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-revert.spec.ts @@ -1,13 +1,13 @@ -import { join } from "path" -import { MikroORM } from "@mikro-orm/postgresql" import { MetadataStorage } from "@mikro-orm/core" -import { createDatabase, dropDatabase } from "pg-god" 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 { Migrations, MigrationsEvents } from "../../index" +import { model } from "../../../dml" import { defineMikroOrmCliConfig } from "../../../modules-sdk" +import { Migrations, MigrationsEvents } from "../../index" const DB_HOST = process.env.DB_HOST ?? "localhost" const DB_USERNAME = process.env.DB_USERNAME ?? "" @@ -22,8 +22,8 @@ const migrationFileNameGenerator = (_: string, name?: string) => { } const pgGodCredentials = { - user: DB_USERNAME, - password: DB_PASSWORD, + user: DB_USERNAME ?? "postgres", + password: DB_PASSWORD ?? "", host: DB_HOST, } diff --git a/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-run.spec.ts b/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-run.spec.ts index da1d8bc708fab..1ff76cf74d56c 100644 --- a/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-run.spec.ts +++ b/packages/core/utils/src/migrations/integration-tests/__tests__/migrations-run.spec.ts @@ -23,8 +23,8 @@ const moduleName = "myTestServiceRun" const fs = new FileSystem(join(__dirname, "./migrations-run")) const pgGodCredentials = { - user: DB_USERNAME, - password: DB_PASSWORD, + user: DB_USERNAME ?? "postgres", + password: DB_PASSWORD ?? "", host: DB_HOST, } diff --git a/packages/core/utils/src/modules-sdk/__tests__/mikro-orm-cli-config-builder.spec.ts b/packages/core/utils/src/modules-sdk/__tests__/mikro-orm-cli-config-builder.spec.ts index 9d6d90af000d1..2c47ce8d92fed 100644 --- a/packages/core/utils/src/modules-sdk/__tests__/mikro-orm-cli-config-builder.spec.ts +++ b/packages/core/utils/src/modules-sdk/__tests__/mikro-orm-cli-config-builder.spec.ts @@ -19,7 +19,7 @@ describe("defineMikroOrmCliConfig", () => { expect(config).toEqual({ entities: [{}], - type: "postgresql", + driver: expect.any(Function), host: "127.0.0.1", user: "postgres", password: "", @@ -37,7 +37,7 @@ describe("defineMikroOrmCliConfig", () => { expect(config).toEqual({ entities: [{}], - type: "postgresql", + driver: expect.any(Function), dbName: "medusa-my-test", host: "127.0.0.1", user: "postgres", diff --git a/packages/core/utils/src/modules-sdk/loaders/mikro-orm-connection-loader.ts b/packages/core/utils/src/modules-sdk/loaders/mikro-orm-connection-loader.ts index 94a671c71ccf9..2c86a86ae31a5 100644 --- a/packages/core/utils/src/modules-sdk/loaders/mikro-orm-connection-loader.ts +++ b/packages/core/utils/src/modules-sdk/loaders/mikro-orm-connection-loader.ts @@ -2,11 +2,7 @@ import { Logger, MedusaContainer, ModulesSdkTypes } from "@medusajs/types" import { PostgreSqlDriver, SqlEntityManager } from "@mikro-orm/postgresql" import { asValue } from "awilix" import { ContainerRegistrationKeys, MedusaError } from "../../common" -import { - FreeTextSearchFilterKey, - mikroOrmCreateConnection, - mikroOrmFreeTextSearchFilterOptionsFactory, -} from "../../dal" +import { mikroOrmCreateConnection } from "../../dal" import { isSharedConnectionSymbol } from "../create-pg-connection" import { loadDatabaseConfig } from "../load-module-database-config" @@ -39,9 +35,6 @@ export async function mikroOrmConnectionLoader({ logger?: Logger pathToMigrations: string }) { - const freeTextSearchGlobalFilter = - mikroOrmFreeTextSearchFilterOptionsFactory(entities) - let manager = ( options as ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions )?.manager @@ -68,9 +61,6 @@ export async function mikroOrmConnectionLoader({ return await loadShared({ database: { ...dbConfig, - filters: { - [FreeTextSearchFilterKey as string]: freeTextSearchGlobalFilter, - }, }, container, entities, @@ -98,9 +88,6 @@ export async function mikroOrmConnectionLoader({ manager ??= await loadDefault({ database: { ...dbConfig, - filters: { - [FreeTextSearchFilterKey as string]: freeTextSearchGlobalFilter, - }, }, entities, pathToMigrations, diff --git a/packages/core/utils/src/modules-sdk/medusa-internal-service.ts b/packages/core/utils/src/modules-sdk/medusa-internal-service.ts index 3689869adbe48..d18fe53d29812 100644 --- a/packages/core/utils/src/modules-sdk/medusa-internal-service.ts +++ b/packages/core/utils/src/modules-sdk/medusa-internal-service.ts @@ -2,9 +2,9 @@ import { BaseFilterable, Context, FilterQuery, - FilterQuery as InternalFilterQuery, FindConfig, InferEntityType, + FilterQuery as InternalFilterQuery, ModulesSdkTypes, PerformedActions, UpsertWithReplaceConfig, @@ -18,7 +18,7 @@ import { lowerCaseFirst, MedusaError, } from "../common" -import { FreeTextSearchFilterKey } from "../dal" +import { FreeTextSearchFilterKeyPrefix } from "../dal" import { DmlEntity, toMikroORMEntity } from "../dml" import { buildQuery } from "./build-query" import { @@ -67,7 +67,7 @@ export function MedusaInternalService< ): void { if (isDefined(filters?.q)) { config.filters ??= {} - config.filters[FreeTextSearchFilterKey] = { + config.filters[FreeTextSearchFilterKeyPrefix + model.name] = { value: filters.q, fromEntity: model.name, } diff --git a/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts b/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts index 48bb1c62abb72..d61db08c4c956 100644 --- a/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts +++ b/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts @@ -5,6 +5,7 @@ import type { EntitySchema, MikroORMOptions, } from "@mikro-orm/core" +import { defineConfig } from "@mikro-orm/postgresql" import { kebabCase } from "../common" import { CustomTsMigrationGenerator } from "../dal" import { DmlEntity, toMikroOrmEntities } from "../dml" @@ -21,7 +22,6 @@ type Options = Partial> & { type ReturnedOptions = Partial & { entities: MikroORMOptions["entities"] - type: MikroORMOptions["type"] migrations: MikroORMOptions["migrations"] } @@ -43,7 +43,7 @@ export function defineMikroOrmCliConfig( const dmlEntities = options.entities.filter(DmlEntity.isDmlEntity) const nonDmlEntities = options.entities.filter( - (entity) => !DmlEntity.isDmlEntity(entity) + (entity) => entity && !DmlEntity.isDmlEntity(entity) ) const entities = nonDmlEntities.concat( @@ -53,17 +53,16 @@ export function defineMikroOrmCliConfig( const normalizedModuleName = kebabCase(moduleName.replace("Service", "")) const databaseName = `medusa-${normalizedModuleName}` - return { - type: "postgresql", + return defineConfig({ dbName: databaseName, host: "127.0.0.1", user: "postgres", password: "", - ...options, + ...(options as any), entities, migrations: { generator: CustomTsMigrationGenerator, ...options.migrations, }, - } + }) as ReturnedOptions } diff --git a/packages/core/workflows-sdk/package.json b/packages/core/workflows-sdk/package.json index 51a82a4d9733b..6b07dc9abeab8 100644 --- a/packages/core/workflows-sdk/package.json +++ b/packages/core/workflows-sdk/package.json @@ -27,10 +27,10 @@ "author": "Medusa", "license": "MIT", "devDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "awilix": "^8.0.1", @@ -47,10 +47,10 @@ "ulid": "^2.3.0" }, "peerDependencies": { - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "express": "^4.21.0", "pg": "^8.13.0" diff --git a/packages/design-system/ui/package.json b/packages/design-system/ui/package.json index aaa8c4f02392a..5228309638d9d 100644 --- a/packages/design-system/ui/package.json +++ b/packages/design-system/ui/package.json @@ -81,7 +81,7 @@ "vitest": "^0.32.2" }, "dependencies": { - "@medusajs/icons": "^2.2.0", + "@medusajs/icons": "^2.3.0", "@radix-ui/react-accordion": "1.2.0", "@radix-ui/react-alert-dialog": "1.1.1", "@radix-ui/react-avatar": "1.1.0", diff --git a/packages/medusa-test-utils/package.json b/packages/medusa-test-utils/package.json index 4bda181164403..359b87362c589 100644 --- a/packages/medusa-test-utils/package.json +++ b/packages/medusa-test-utils/package.json @@ -26,10 +26,10 @@ "license": "MIT", "devDependencies": { "@medusajs/framework": "^2.3.1", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "jest": "^29.7.0", "pg": "^8.13.0", @@ -47,7 +47,7 @@ "peerDependencies": { "@medusajs/framework": "^2.0.0", "@medusajs/medusa": "^2.0.0", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" }, "peerDependenciesMeta": { diff --git a/packages/medusa-test-utils/src/database.ts b/packages/medusa-test-utils/src/database.ts index df093c60080d4..341af26a23a92 100644 --- a/packages/medusa-test-utils/src/database.ts +++ b/packages/medusa-test-utils/src/database.ts @@ -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" const DB_HOST = process.env.DB_HOST ?? "localhost" @@ -13,8 +18,8 @@ const pgGodCredentials = { export function getDatabaseURL(dbName?: string): string { const DB_HOST = process.env.DB_HOST ?? "localhost" - const DB_USERNAME = process.env.DB_USERNAME ?? "" - const DB_PASSWORD = process.env.DB_PASSWORD + const DB_USERNAME = process.env.DB_USERNAME ?? "postgres" + const DB_PASSWORD = process.env.DB_PASSWORD ?? "" const DB_NAME = dbName ?? process.env.DB_TEMP_NAME return `postgres://${DB_USERNAME}${ @@ -35,8 +40,7 @@ export function getMikroOrmConfig({ }): Options { const DB_URL = clientUrl ?? getDatabaseURL() - return { - type: "postgresql", + return defineConfig({ clientUrl: DB_URL, entities: Object.values(mikroOrmEntities), schema: schema ?? process.env.MEDUSA_DB_SCHEMA, @@ -48,7 +52,7 @@ export function getMikroOrmConfig({ pathTs: pathToMigrations, silent: true, }, - } + }) } export interface TestDatabase { diff --git a/packages/medusa/package.json b/packages/medusa/package.json index 01f222c6e9358..5269fba7ca80a 100644 --- a/packages/medusa/package.json +++ b/packages/medusa/package.json @@ -128,10 +128,10 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1", "yalc": "1.0.0-pre.53" }, diff --git a/packages/medusa/src/api/admin/claims/[id]/inbound/items/[action_id]/route.ts b/packages/medusa/src/api/admin/claims/[id]/inbound/items/[action_id]/route.ts index d5f716b04bbec..b5e07bfd97b4b 100644 --- a/packages/medusa/src/api/admin/claims/[id]/inbound/items/[action_id]/route.ts +++ b/packages/medusa/src/api/admin/claims/[id]/inbound/items/[action_id]/route.ts @@ -2,18 +2,18 @@ import { removeItemReturnActionWorkflow, updateRequestItemReturnWorkflow, } from "@medusajs/core-flows" -import { - ContainerRegistrationKeys, - remoteQueryObjectFromString, -} from "@medusajs/framework/utils" import { AuthenticatedMedusaRequest, MedusaResponse, refetchEntity, } from "@medusajs/framework/http" +import { HttpTypes } from "@medusajs/framework/types" +import { + ContainerRegistrationKeys, + remoteQueryObjectFromString, +} from "@medusajs/framework/utils" import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config" import { AdminPostReturnsRequestItemsActionReqSchemaType } from "../../../../../returns/validators" -import { HttpTypes } from "@medusajs/framework/types" export const POST = async ( req: AuthenticatedMedusaRequest, @@ -29,7 +29,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, @@ -67,7 +67,10 @@ export const DELETE = async ( ) => { 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( req.scope diff --git a/packages/medusa/src/api/admin/claims/[id]/inbound/items/route.ts b/packages/medusa/src/api/admin/claims/[id]/inbound/items/route.ts index 6eb8899479c49..eeb30607ae188 100644 --- a/packages/medusa/src/api/admin/claims/[id]/inbound/items/route.ts +++ b/packages/medusa/src/api/admin/claims/[id]/inbound/items/route.ts @@ -8,9 +8,9 @@ import { AuthenticatedMedusaRequest, MedusaResponse, } from "@medusajs/framework/http" +import { HttpTypes } from "@medusajs/framework/types" import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config" import { AdminPostReturnsRequestItemsReqSchemaType } from "../../../../returns/validators" -import { HttpTypes } from "@medusajs/framework/types" export const POST = async ( req: AuthenticatedMedusaRequest, @@ -26,7 +26,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, @@ -41,10 +41,11 @@ export const POST = async ( }, }) + const returnId = result.order_change.return_id const queryObject = remoteQueryObjectFromString({ entryPoint: "return", variables: { - id: claim.return_id, + id: returnId, }, fields: defaultAdminDetailsReturnFields, }) diff --git a/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/[action_id]/route.ts b/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/[action_id]/route.ts index ee2bc56a4cfee..6c9a7a477cf19 100644 --- a/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/[action_id]/route.ts +++ b/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/[action_id]/route.ts @@ -2,17 +2,17 @@ import { removeClaimShippingMethodWorkflow, updateReturnShippingMethodWorkflow, } from "@medusajs/core-flows" -import { - ContainerRegistrationKeys, - remoteQueryObjectFromString, -} from "@medusajs/framework/utils" import { AuthenticatedMedusaRequest, MedusaResponse, } from "@medusajs/framework/http" +import { HttpTypes } from "@medusajs/framework/types" +import { + ContainerRegistrationKeys, + remoteQueryObjectFromString, +} from "@medusajs/framework/utils" import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config" import { AdminPostClaimsShippingActionReqSchemaType } from "../../../../validators" -import { HttpTypes } from "@medusajs/framework/types" export const POST = async ( req: AuthenticatedMedusaRequest, @@ -28,7 +28,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, diff --git a/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/route.ts b/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/route.ts index 1f1f8344c9684..21bda50691803 100644 --- a/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/route.ts +++ b/packages/medusa/src/api/admin/claims/[id]/inbound/shipping-method/route.ts @@ -8,9 +8,9 @@ import { AuthenticatedMedusaRequest, MedusaResponse, } from "@medusajs/framework/http" +import { HttpTypes } from "@medusajs/framework/types" import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config" import { AdminPostReturnsShippingReqSchemaType } from "../../../../returns/validators" -import { HttpTypes } from "@medusajs/framework/types" export const POST = async ( req: AuthenticatedMedusaRequest, @@ -26,7 +26,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, @@ -41,10 +41,11 @@ export const POST = async ( }, }) + const returnId = result.order_change.return_id const queryObject = remoteQueryObjectFromString({ entryPoint: "return", variables: { - id: claim.return_id, + id: returnId, }, fields: defaultAdminDetailsReturnFields, }) diff --git a/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/[action_id]/route.ts b/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/[action_id]/route.ts index 9e43aeeaaca6f..b0d7405a32da3 100644 --- a/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/[action_id]/route.ts +++ b/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/[action_id]/route.ts @@ -2,16 +2,16 @@ import { removeItemReturnActionWorkflow, updateRequestItemReturnWorkflow, } from "@medusajs/core-flows" -import { HttpTypes } from "@medusajs/framework/types" -import { - ContainerRegistrationKeys, - remoteQueryObjectFromString, -} from "@medusajs/framework/utils" import { AuthenticatedMedusaRequest, MedusaResponse, refetchEntity, } from "@medusajs/framework/http" +import { HttpTypes } from "@medusajs/framework/types" +import { + ContainerRegistrationKeys, + remoteQueryObjectFromString, +} from "@medusajs/framework/utils" import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config" import { AdminPostExchangesRequestItemsReturnActionReqSchemaType } from "../../../../validators" @@ -29,7 +29,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, diff --git a/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/route.ts b/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/route.ts index d3cc37326bc86..75183a213372d 100644 --- a/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/route.ts +++ b/packages/medusa/src/api/admin/exchanges/[id]/inbound/items/route.ts @@ -8,9 +8,9 @@ import { AuthenticatedMedusaRequest, MedusaResponse, } from "@medusajs/framework/http" +import { HttpTypes } from "@medusajs/framework/types" import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config" import { AdminPostExchangesReturnRequestItemsReqSchemaType } from "../../../validators" -import { HttpTypes } from "@medusajs/framework/types" export const POST = async ( req: AuthenticatedMedusaRequest, @@ -26,7 +26,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, @@ -43,10 +43,11 @@ export const POST = async ( }, }) + const returnId = result.order_change.return_id const queryObject = remoteQueryObjectFromString({ entryPoint: "return", variables: { - id: exchange.return_id, + id: returnId, }, fields: defaultAdminDetailsReturnFields, }) diff --git a/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/[action_id]/route.ts b/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/[action_id]/route.ts index dd80ae96d8fe0..ba8141928c592 100644 --- a/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/[action_id]/route.ts +++ b/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/[action_id]/route.ts @@ -2,17 +2,17 @@ import { removeReturnShippingMethodWorkflow, updateReturnShippingMethodWorkflow, } from "@medusajs/core-flows" -import { - ContainerRegistrationKeys, - remoteQueryObjectFromString, -} from "@medusajs/framework/utils" import { AuthenticatedMedusaRequest, MedusaResponse, } 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 { AdminPostExchangesShippingActionReqSchemaType } from "../../../../validators" -import { AdminOrderPreview, HttpTypes } from "@medusajs/framework/types" export const POST = async ( req: AuthenticatedMedusaRequest, @@ -28,7 +28,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, @@ -76,7 +76,7 @@ export const DELETE = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, diff --git a/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/route.ts b/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/route.ts index 77ed17423b69c..9b23b23506fc9 100644 --- a/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/route.ts +++ b/packages/medusa/src/api/admin/exchanges/[id]/inbound/shipping-method/route.ts @@ -8,9 +8,9 @@ import { AuthenticatedMedusaRequest, MedusaResponse, } from "@medusajs/framework/http" +import { HttpTypes } from "@medusajs/framework/types" import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config" import { AdminPostReturnsShippingReqSchemaType } from "../../../../returns/validators" -import { HttpTypes } from "@medusajs/framework/types" export const POST = async ( req: AuthenticatedMedusaRequest, @@ -26,7 +26,7 @@ export const POST = async ( variables: { id, }, - fields: ["return_id"], + fields: ["id", "return_id"], }), { throwIfKeyNotFound: true, @@ -41,10 +41,11 @@ export const POST = async ( }, }) + const returnId = result.order_change.return_id const queryObject = remoteQueryObjectFromString({ entryPoint: "return", variables: { - id: exchange.return_id, + id: returnId, }, fields: defaultAdminDetailsReturnFields, }) diff --git a/packages/modules/api-key/package.json b/packages/modules/api-key/package.json index f980e1fe7560d..690255559d8c9 100644 --- a/packages/modules/api-key/package.json +++ b/packages/modules/api-key/package.json @@ -30,15 +30,15 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^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/jest": "^0.2.36", "jest": "^29.7.0", @@ -48,9 +48,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/auth/package.json b/packages/modules/auth/package.json index 08a9b141a2f6a..d6026b9e8deeb 100644 --- a/packages/modules/auth/package.json +++ b/packages/modules/auth/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/cart/package.json b/packages/modules/cart/package.json index dbdb803512650..ca6e165899a9b 100644 --- a/packages/modules/cart/package.json +++ b/packages/modules/cart/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/currency/package.json b/packages/modules/currency/package.json index f096e8d2d9043..12c303eca53a5 100644 --- a/packages/modules/currency/package.json +++ b/packages/modules/currency/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/customer/package.json b/packages/modules/customer/package.json index 50851f31462fb..74c5990e531d5 100644 --- a/packages/modules/customer/package.json +++ b/packages/modules/customer/package.json @@ -30,19 +30,19 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", - "migration:generate": "MIKRO_ORM_CLI=./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:create": "MIKRO_ORM_CLI=./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", - "orm:cache:clear": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:generate": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:generate", + "migration:initial": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -52,9 +52,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/file/package.json b/packages/modules/file/package.json index efd2af95d363d..163974ead9e24 100644 --- a/packages/modules/file/package.json +++ b/packages/modules/file/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", diff --git a/packages/modules/fulfillment/integration-tests/__tests__/fulfillment-module-service/shipping-option.spec.ts b/packages/modules/fulfillment/integration-tests/__tests__/fulfillment-module-service/shipping-option.spec.ts index c73595bbb9030..441c7e9e2b64a 100644 --- a/packages/modules/fulfillment/integration-tests/__tests__/fulfillment-module-service/shipping-option.spec.ts +++ b/packages/modules/fulfillment/integration-tests/__tests__/fulfillment-module-service/shipping-option.spec.ts @@ -137,7 +137,7 @@ moduleIntegrationTestRunner({ { attribute: "test-attribute", operator: "in", - value: ["test"], + value: ["true"], }, ], }), @@ -161,7 +161,7 @@ moduleIntegrationTestRunner({ { attribute: "test-attribute", operator: "eq", - value: "test", + value: "true", }, { attribute: "test-attribute2.options", @@ -174,7 +174,7 @@ moduleIntegrationTestRunner({ let listedOptions = await service.listShippingOptionsForContext({ context: { - "test-attribute": "test", + "test-attribute": "true", "test-attribute2": { options: "test2", }, @@ -774,7 +774,7 @@ moduleIntegrationTestRunner({ rules: expect.arrayContaining([ expect.objectContaining({ id: existingRule.id, - value: '"false"', + value: "false", }), expect.objectContaining({ id: expect.any(String), diff --git a/packages/modules/fulfillment/package.json b/packages/modules/fulfillment/package.json index 74293911895b2..ed70937bd3db1 100644 --- a/packages/modules/fulfillment/package.json +++ b/packages/modules/fulfillment/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit --passWithNoTests -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json b/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json index 029dbf91db475..0c2078c51bbf3 100644 --- a/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json +++ b/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json @@ -154,6 +154,7 @@ "keyName": "IDX_fulfillment_address_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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" ], "composite": false, + "constraint": true, "primary": true, "unique": true } ], "checks": [], - "foreignKeys": {} + "foreignKeys": {}, + "nativeEnums": {} }, { "columns": { @@ -232,6 +235,7 @@ "keyName": "IDX_fulfillment_provider_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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" ], "composite": false, + "constraint": true, "primary": true, "unique": true } ], "checks": [], - "foreignKeys": {} + "foreignKeys": {}, + "nativeEnums": {} }, { "columns": { @@ -327,6 +333,7 @@ "keyName": "IDX_fulfillment_set_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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" ], "composite": false, + "constraint": true, "primary": true, "unique": true } ], "checks": [], - "foreignKeys": {} + "foreignKeys": {}, + "nativeEnums": {} }, { "columns": { @@ -430,6 +440,7 @@ "keyName": "IDX_service_zone_fulfillment_set_id", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -438,6 +449,7 @@ "keyName": "IDX_service_zone_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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" ], "composite": false, + "constraint": true, "primary": true, "unique": true } @@ -475,7 +489,8 @@ "deleteRule": "cascade", "updateRule": "cascade" } - } + }, + "nativeEnums": {} }, { "columns": { @@ -598,6 +613,7 @@ "keyName": "IDX_geo_zone_service_zone_id", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -606,6 +622,7 @@ "keyName": "IDX_geo_zone_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_geo_zone_city\" ON \"geo_zone\" (city) WHERE deleted_at IS NULL" @@ -640,6 +660,7 @@ "id" ], "composite": false, + "constraint": true, "primary": true, "unique": true } @@ -659,7 +680,8 @@ "deleteRule": "cascade", "updateRule": "cascade" } - } + }, + "nativeEnums": {} }, { "columns": { @@ -739,6 +761,7 @@ "keyName": "IDX_shipping_option_type_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -749,12 +772,14 @@ "id" ], "composite": false, + "constraint": true, "primary": true, "unique": true } ], "checks": [], - "foreignKeys": {} + "foreignKeys": {}, + "nativeEnums": {} }, { "columns": { @@ -834,6 +859,7 @@ "keyName": "IDX_shipping_profile_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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" ], "composite": false, + "constraint": true, "primary": true, "unique": true } ], "checks": [], - "foreignKeys": {} + "foreignKeys": {}, + "nativeEnums": {} }, { "columns": { @@ -983,10 +1012,21 @@ "name": "shipping_option", "schema": "public", "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", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -995,14 +1035,25 @@ "keyName": "IDX_shipping_option_shipping_profile_id", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" }, + { + "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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" ], "composite": false, + "constraint": true, "primary": true, "unique": true } @@ -1044,8 +1096,34 @@ "referencedTableName": "public.shipping_profile", "deleteRule": "set null", "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": { @@ -1144,6 +1222,7 @@ "keyName": "IDX_shipping_option_rule_shipping_option_id", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -1152,6 +1231,7 @@ "keyName": "IDX_shipping_option_rule_deleted_at", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -1162,6 +1242,7 @@ "id" ], "composite": false, + "constraint": true, "primary": true, "unique": true } @@ -1181,7 +1262,8 @@ "deleteRule": "cascade", "updateRule": "cascade" } - } + }, + "nativeEnums": {} }, { "columns": { @@ -1352,10 +1434,31 @@ "name": "fulfillment", "schema": "public", "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_fulfillment_location_id\" ON \"fulfillment\" (location_id) WHERE deleted_at IS NULL" @@ -1382,12 +1487,26 @@ "id" ], "composite": false, + "constraint": true, "primary": true, "unique": true } ], "checks": [], "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": { "constraintName": "fulfillment_shipping_option_id_foreign", "columnNames": [ @@ -1400,8 +1519,22 @@ "referencedTableName": "public.shipping_option", "deleteRule": "set null", "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": { @@ -1490,6 +1623,7 @@ "keyName": "IDX_fulfillment_label_fulfillment_id", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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" ], "composite": false, + "constraint": true, "primary": true, "unique": true } @@ -1527,7 +1663,8 @@ "deleteRule": "cascade", "updateRule": "cascade" } - } + }, + "nativeEnums": {} }, { "columns": { @@ -1652,6 +1789,7 @@ "keyName": "IDX_fulfillment_item_fulfillment_id", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": false, "unique": false, "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", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -1676,6 +1816,7 @@ "keyName": "IDX_fulfillment_item_line_item_id", "columnNames": [], "composite": false, + "constraint": false, "primary": 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" @@ -1686,6 +1827,7 @@ "id" ], "composite": false, + "constraint": true, "primary": true, "unique": true } @@ -1705,7 +1847,9 @@ "deleteRule": "cascade", "updateRule": "cascade" } - } + }, + "nativeEnums": {} } - ] + ], + "nativeEnums": {} } diff --git a/packages/modules/fulfillment/src/migrations/Migration20250113122235.ts b/packages/modules/fulfillment/src/migrations/Migration20250113122235.ts new file mode 100644 index 0000000000000..2a409cd85b99b --- /dev/null +++ b/packages/modules/fulfillment/src/migrations/Migration20250113122235.ts @@ -0,0 +1,29 @@ +import { Migration } from "@mikro-orm/migrations" + +export class Migration20250113122235 extends Migration { + override async up(): Promise { + 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 { + 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; + `) + } +} diff --git a/packages/modules/fulfillment/src/utils/utils.ts b/packages/modules/fulfillment/src/utils/utils.ts index 7e3fe27fb088c..5017e8359e8f8 100644 --- a/packages/modules/fulfillment/src/utils/utils.ts +++ b/packages/modules/fulfillment/src/utils/utils.ts @@ -146,12 +146,12 @@ export function validateRule(rule: Record): boolean { } export function normalizeRulesValue>(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") { - rule.value = rule.value === "true" ? '"true"' : '"false"' + if (rule.value === true || rule.value === false) { + rule.value = rule.value === true ? "true" : "false" } return rule diff --git a/packages/modules/index/integration-tests/__tests__/index-engine-module.spec.ts b/packages/modules/index/integration-tests/__tests__/index-engine-module.spec.ts index 8916ba3440b83..69c6396333d72 100644 --- a/packages/modules/index/integration-tests/__tests__/index-engine-module.spec.ts +++ b/packages/modules/index/integration-tests/__tests__/index-engine-module.spec.ts @@ -722,57 +722,11 @@ describe("IndexModuleService", function () { it("should consume all deleted events and delete the index entries", async () => { const indexEntries = await manager.find(toMikroORMEntity(IndexData), {}) const indexRelationEntries = await manager.find( - toMikroORMEntity(IndexRelation), - {}, - { - populate: ["parent", "child"], - } + toMikroORMEntity(IndexRelation) ) expect(indexEntries).toHaveLength(3) 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) }) }) }) diff --git a/packages/modules/index/package.json b/packages/modules/index/package.json index ff0e6eba7ee9d..489df27ebd4c7 100644 --- a/packages/modules/index/package.json +++ b/packages/modules/index/package.json @@ -30,19 +30,19 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests ./src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -52,10 +52,10 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/knex": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/knex": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/index/src/migrations/.snapshot-medusa-index.json b/packages/modules/index/src/migrations/.snapshot-medusa-index.json index 4f1381987680c..57ef691d6f1cb 100644 --- a/packages/modules/index/src/migrations/.snapshot-medusa-index.json +++ b/packages/modules/index/src/migrations/.snapshot-medusa-index.json @@ -120,11 +120,11 @@ "columns": { "id": { "name": "id", - "type": "number", + "type": "serial", "unsigned": true, "autoincrement": true, "primary": true, - "nullable": false, + "nullable": true, "mappedType": "integer" }, "pivot": { @@ -145,8 +145,8 @@ "nullable": false, "mappedType": "text" }, - "child_name": { - "name": "child_name", + "parent_id": { + "name": "parent_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -154,8 +154,8 @@ "nullable": false, "mappedType": "text" }, - "parent_id": { - "name": "parent_id", + "child_name": { + "name": "child_name", "type": "text", "unsigned": false, "autoincrement": false, diff --git a/packages/modules/index/src/models/index-data.ts b/packages/modules/index/src/models/index-data.ts index b56cb86674fad..0326e34f14cbf 100644 --- a/packages/modules/index/src/models/index-data.ts +++ b/packages/modules/index/src/models/index-data.ts @@ -1,20 +1,10 @@ import { model } from "@medusajs/framework/utils" -import IndexRelation from "./index-relation" const IndexData = model .define("IndexData", { id: model.text().primaryKey(), name: model.text().primaryKey(), data: model.json().default({}), - parents: model.manyToMany(() => IndexData, { - mappedBy: "children", - pivotEntity: () => IndexRelation, - joinColumn: ["child_id", "child_name"], - inverseJoinColumn: ["parent_id", "parent_name"], - }), - children: model.manyToMany(() => IndexData, { - mappedBy: "parents", - }), }) .indexes([ { diff --git a/packages/modules/index/src/models/index-relation.ts b/packages/modules/index/src/models/index-relation.ts index d2ae894ed8557..bf983bcf4160b 100644 --- a/packages/modules/index/src/models/index-relation.ts +++ b/packages/modules/index/src/models/index-relation.ts @@ -1,16 +1,11 @@ import { model } from "@medusajs/framework/utils" -import IndexData from "./index-data" const IndexRelation = model.define("IndexRelation", { id: model.autoincrement().primaryKey(), pivot: model.text(), parent_name: model.text(), + parent_id: model.text().index("IDX_index_relation_parent_id"), child_name: model.text(), - parent: model.belongsTo(() => IndexData, { - mappedBy: "parents", - }), - child: model.belongsTo(() => IndexData, { - mappedBy: "children", - }), + child_id: model.text().index("IDX_index_relation_child_id"), }) export default IndexRelation diff --git a/packages/modules/index/src/services/postgres-provider.ts b/packages/modules/index/src/services/postgres-provider.ts index 4b4e4429686d9..c0dbe177c2d93 100644 --- a/packages/modules/index/src/services/postgres-provider.ts +++ b/packages/modules/index/src/services/postgres-provider.ts @@ -403,7 +403,9 @@ export class PostgresProvider implements IndexTypes.StorageProvider { child_name: entity, pivot: `${parentEntity}-${entity}`, }) - indexRelationRepository.persist(parentIndexRelationEntry) + indexRelationRepository + .getEntityManager() + .persist(parentIndexRelationEntry) } } } @@ -628,10 +630,9 @@ export class PostgresProvider implements IndexTypes.StorageProvider { pivot: `${entity}-${childEntityName}`, }) - indexRelationRepository.persist([ - parentIndexRelationEntry, - childIndexRelationEntry, - ]) + indexRelationRepository + .getEntityManager() + .persist([parentIndexRelationEntry, childIndexRelationEntry]) } } diff --git a/packages/modules/inventory/package.json b/packages/modules/inventory/package.json index 6ecbfcb7730b4..39ef105e7f178 100644 --- a/packages/modules/inventory/package.json +++ b/packages/modules/inventory/package.json @@ -25,10 +25,10 @@ "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -38,9 +38,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" }, "scripts": { @@ -50,9 +50,9 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --runInBand --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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" } } diff --git a/packages/modules/inventory/src/migrations/Migration20240719123015.ts b/packages/modules/inventory/src/migrations/Migration20240719123015.ts index 01ceffa8753c9..bf66e54607dc5 100644 --- a/packages/modules/inventory/src/migrations/Migration20240719123015.ts +++ b/packages/modules/inventory/src/migrations/Migration20240719123015.ts @@ -43,13 +43,13 @@ export class Migration20240719123015 extends Migration { ALTER TABLE "reservation_item" DROP COLUMN IF EXISTS "raw_quantity"; ALTER TABLE "inventory_level" ALTER COLUMN "stocked_quantity" TYPE integer; - ALTER TABLE "inventory_level" DROP COLUMN IF NOT EXISTS "raw_stocked_quantity"; + ALTER TABLE "inventory_level" DROP COLUMN IF EXISTS "raw_stocked_quantity"; ALTER TABLE "inventory_level" ALTER COLUMN "reserved_quantity" TYPE integer; - ALTER TABLE "inventory_level" DROP COLUMN IF NOT EXISTS "raw_reserved_quantity"; + ALTER TABLE "inventory_level" DROP COLUMN IF EXISTS "raw_reserved_quantity"; ALTER TABLE "inventory_level" ALTER COLUMN "incoming_quantity" TYPE integer; - ALTER TABLE "inventory_level" DROP COLUMN IF NOT EXISTS "raw_incoming_quantity"; + ALTER TABLE "inventory_level" DROP COLUMN IF EXISTS "raw_incoming_quantity"; DROP INDEX IF EXISTS "IDX_inventory_item_sku_unique"; diff --git a/packages/modules/link-modules/integration-tests/__tests__/migrations.spec.ts b/packages/modules/link-modules/integration-tests/__tests__/migrations.spec.ts index 15faf8cc89225..b9a2458e15fc3 100644 --- a/packages/modules/link-modules/integration-tests/__tests__/migrations.spec.ts +++ b/packages/modules/link-modules/integration-tests/__tests__/migrations.spec.ts @@ -69,13 +69,43 @@ moduleIntegrationTestRunner({ toModel: "car", }, tableName: "user_user_car_car", - sql: 'create table if not exists "user_user_car_car" ("user_id" varchar(255) not null, "car_id" varchar(255) not null, "id" varchar(255) not null, "created_at" timestamptz(0) not null default CURRENT_TIMESTAMP, "updated_at" timestamptz(0) not null default CURRENT_TIMESTAMP, "deleted_at" timestamptz(0) null, constraint "user_user_car_car_pkey" primary key ("user_id", "car_id"));\ncreate index if not exists "IDX_car_id_-92128f74" on "user_user_car_car" ("car_id");\ncreate index if not exists "IDX_id_-92128f74" on "user_user_car_car" ("id");\ncreate index if not exists "IDX_user_id_-92128f74" on "user_user_car_car" ("user_id");\ncreate index if not exists "IDX_deleted_at_-92128f74" on "user_user_car_car" ("deleted_at");\n\n', + sql: + "set names 'utf8';\n" + + "\n" + + 'create table if not exists "user_user_car_car" ("user_id" varchar(255) not null, "car_id" varchar(255) not null, "id" varchar(255) not null, "created_at" timestamptz not null default CURRENT_TIMESTAMP, "updated_at" timestamptz not null default CURRENT_TIMESTAMP, "deleted_at" timestamptz null, constraint "user_user_car_car_pkey" primary key ("user_id", "car_id"));\n' + + 'create index if not exists "IDX_car_id_-92128f74" on "user_user_car_car" ("car_id");\n' + + 'create index if not exists "IDX_id_-92128f74" on "user_user_car_car" ("id");\n' + + 'create index if not exists "IDX_user_id_-92128f74" on "user_user_car_car" ("user_id");\n' + + 'create index if not exists "IDX_deleted_at_-92128f74" on "user_user_car_car" ("deleted_at");\n' + + "\n", + }) + + expect(actionPlan[1]).toEqual({ + action: "create", + linkDescriptor: { + fromModule: "user", + toModule: + "CustomModuleImplementationContainingAReallyBigNameThatExceedsPosgresLimitToNameATable", + fromModel: "user", + toModel: "very_long_table_name_of_custom_module", + }, + tableName: "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de", + sql: + "set names 'utf8';\n" + + "\n" + + 'create table if not exists "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("user_id" varchar(255) not null, "very_long_table_name_of_custom_module_id" varchar(255) not null, "id" varchar(255) not null, "created_at" timestamptz not null default CURRENT_TIMESTAMP, "updated_at" timestamptz not null default CURRENT_TIMESTAMP, "deleted_at" timestamptz null, constraint "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de_pkey" primary key ("user_id", "very_long_table_name_of_custom_module_id"));\n' + + 'create index if not exists "IDX_very_long_table_name_of_custom_module_id_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("very_long_table_name_of_custom_module_id");\n' + + 'create index if not exists "IDX_id_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("id");\n' + + 'create index if not exists "IDX_user_id_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("user_id");\n' + + 'create index if not exists "IDX_deleted_at_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("deleted_at");\n' + + "\n", }) /** * Expect an update plan */ - ;(MedusaModule as any).customLinks_.length = 0 + // @ts-ignore + MedusaModule.customLinks_.length = 0 defineLink(UserModule.linkable.user, CarModule.linkable.car, { database: { @@ -114,7 +144,7 @@ moduleIntegrationTestRunner({ toModel: "car", }, tableName: "user_user_car_car", - sql: 'alter table if exists "user_user_car_car" add column if not exists "data" jsonb not null;\n\n', + sql: 'alter table if exists "user_user_car_car" add column if not exists "data" jsonb not null;', }) /** diff --git a/packages/modules/link-modules/package.json b/packages/modules/link-modules/package.json index ed5cd3cef5d5d..7a630c72953da 100644 --- a/packages/modules/link-modules/package.json +++ b/packages/modules/link-modules/package.json @@ -35,9 +35,9 @@ "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "cross-env": "^5.2.1", @@ -48,9 +48,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/link-modules/src/migration/index.ts b/packages/modules/link-modules/src/migration/index.ts index 6d5ac9b939bfc..f20949d9b35e0 100644 --- a/packages/modules/link-modules/src/migration/index.ts +++ b/packages/modules/link-modules/src/migration/index.ts @@ -233,6 +233,28 @@ export class MigrationsExecutionPlanner implements ILinkMigrationsPlanner { })) } + private pickTableRelatedCommands(tableName: string, sqlCommand: string) { + const ignoreColumns = ["created_at", "updated_at", "deleted_at"] + const commands = sqlCommand.split(";") + const returnedCommands = commands + .filter((command) => { + const cmd = command.trim() + return ( + cmd.length && + cmd !== "set names 'utf8'" && + cmd.includes(`"${tableName}"`) && + !ignoreColumns.some((column) => cmd.includes(`column "${column}"`)) + ) + }) + .map((cmd) => cmd.trim()) + + if (returnedCommands.length > 0) { + // adds ; at the end of each command + returnedCommands.push("") + } + + return returnedCommands.join(";") + } /** * Returns the migration plan for a specific link entity. */ @@ -282,12 +304,14 @@ export class MigrationsExecutionPlanner implements ILinkMigrationsPlanner { }, ]) - const updateSQL = normalizeMigrationSQL( + let updateSQL = normalizeMigrationSQL( await generator.getUpdateSchemaSQL({ fromSchema: dbSchema, }) ) + updateSQL = this.pickTableRelatedCommands(tableName, updateSQL) + /** * Entity is upto-date and hence we do not have to perform * any updates on it. diff --git a/packages/modules/link-modules/src/utils/generate-entity.ts b/packages/modules/link-modules/src/utils/generate-entity.ts index 595518e607e95..333f7ab75fc76 100644 --- a/packages/modules/link-modules/src/utils/generate-entity.ts +++ b/packages/modules/link-modules/src/utils/generate-entity.ts @@ -74,16 +74,22 @@ export function generateEntity( }, ...fields, created_at: { - type: "Date", + columnType: "timestamptz", + type: "date", nullable: false, defaultRaw: "CURRENT_TIMESTAMP", }, updated_at: { - type: "Date", + columnType: "timestamptz", + type: "date", nullable: false, defaultRaw: "CURRENT_TIMESTAMP", }, - deleted_at: { type: "Date", nullable: true }, + deleted_at: { + columnType: "timestamptz", + type: "date", + nullable: true, + }, }, filters: { [SoftDeletableFilterKey]: mikroOrmSoftDeletableFilterOptions, diff --git a/packages/modules/locking/package.json b/packages/modules/locking/package.json index 443e6cdfc8100..6d0df16addea1 100644 --- a/packages/modules/locking/package.json +++ b/packages/modules/locking/package.json @@ -26,18 +26,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src/", "test:integration": "jest --runInBand --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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -47,9 +47,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/notification/package.json b/packages/modules/notification/package.json index ea5902c52e2fe..10c1d96615f5f 100644 --- a/packages/modules/notification/package.json +++ b/packages/modules/notification/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit --passWithNoTests -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/order/integration-tests/__tests__/index.spec.ts b/packages/modules/order/integration-tests/__tests__/index.spec.ts index a01bd0992e243..5443aed1a8777 100644 --- a/packages/modules/order/integration-tests/__tests__/index.spec.ts +++ b/packages/modules/order/integration-tests/__tests__/index.spec.ts @@ -12,19 +12,21 @@ moduleIntegrationTestRunner({ service: OrderModuleService, }).linkable - expect(Object.keys(linkable)).toEqual([ - "order", - "orderAddress", - "orderChange", - "orderClaim", - "orderExchange", - "orderItem", - "orderLineItem", - "orderShippingMethod", - "orderTransaction", - "return", - "returnReason", - ]) + expect(Object.keys(linkable)).toEqual( + expect.arrayContaining([ + "order", + "orderAddress", + "orderChange", + "orderClaim", + "orderExchange", + "orderItem", + "orderLineItem", + "orderShippingMethod", + "orderTransaction", + "return", + "returnReason", + ]) + ) Object.keys(linkable).forEach((key) => { delete linkable[key].toJSON diff --git a/packages/modules/order/integration-tests/__tests__/order-claim.ts b/packages/modules/order/integration-tests/__tests__/order-claim.ts index 9a5badaa58efd..a7d1992d1b57a 100644 --- a/packages/modules/order/integration-tests/__tests__/order-claim.ts +++ b/packages/modules/order/integration-tests/__tests__/order-claim.ts @@ -2,7 +2,7 @@ import { CreateOrderDTO, IOrderModuleService } from "@medusajs/framework/types" import { ClaimType, Modules } from "@medusajs/framework/utils" import { SuiteOptions, moduleIntegrationTestRunner } from "@medusajs/test-utils" -jest.setTimeout(100000) +jest.setTimeout(1000000) moduleIntegrationTestRunner({ moduleName: Modules.ORDER, @@ -140,9 +140,9 @@ moduleIntegrationTestRunner({ internal_note: "user wants to return all items", shipping_methods: [ { + shipping_option_id: "shipping_dhl_id", name: "Claim method", amount: 35, - provider_id: "dhl", }, ], claim_items: [ diff --git a/packages/modules/order/integration-tests/__tests__/order-return.ts b/packages/modules/order/integration-tests/__tests__/order-return.ts index 8d8ffbac083b2..d1e7961dae7d9 100644 --- a/packages/modules/order/integration-tests/__tests__/order-return.ts +++ b/packages/modules/order/integration-tests/__tests__/order-return.ts @@ -627,7 +627,7 @@ moduleIntegrationTestRunner({ "items.detail.return_received_quantity", "shipping_methods.id", ], - relations: ["items", "items.detail"], + relations: ["items", "items.detail", "shipping_methods"], }) serializedOrder = JSON.parse(JSON.stringify(getOrder)) diff --git a/packages/modules/order/package.json b/packages/modules/order/package.json index 33523cffe7983..f461cd6bc628d 100644 --- a/packages/modules/order/package.json +++ b/packages/modules/order/package.json @@ -29,19 +29,19 @@ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "test:integration": "jest --forceExit", + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/order/src/migrations/.snapshot-medusa-order.json b/packages/modules/order/src/migrations/.snapshot-medusa-order.json index 499109f0d3513..97d3281315614 100644 --- a/packages/modules/order/src/migrations/.snapshot-medusa-order.json +++ b/packages/modules/order/src/migrations/.snapshot-medusa-order.json @@ -144,20 +144,36 @@ "length": 6, "default": "now()", "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, "name": "order_address", "schema": "public", "indexes": [ + { + "keyName": "IDX_order_address_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_address_deleted_at\" ON \"order_address\" (deleted_at) WHERE deleted_at IS NULL" + }, { "keyName": "IDX_order_address_customer_id", - "columnNames": [ - "customer_id" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_address_customer_id\" ON \"order_address\" (customer_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_address_customer_id\" ON \"order_address\" (customer_id) WHERE deleted_at IS NULL" }, { "keyName": "order_address_pkey", @@ -186,10 +202,10 @@ "display_id": { "name": "display_id", "type": "serial", - "unsigned": true, - "autoincrement": true, + "unsigned": false, + "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "integer" }, "region_id": { @@ -275,41 +291,51 @@ "nullable": false, "mappedType": "text" }, - "shipping_address_id": { - "name": "shipping_address_id", - "type": "text", + "no_notification": { + "name": "no_notification", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "boolean" }, - "billing_address_id": { - "name": "billing_address_id", - "type": "text", + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, - "no_notification": { - "name": "no_notification", - "type": "boolean", + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "boolean" + "length": 6, + "mappedType": "datetime" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + "shipping_address_id": { + "name": "shipping_address_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" + }, + "billing_address_id": { + "name": "billing_address_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" }, "created_at": { "name": "created_at", @@ -342,36 +368,48 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" } }, "name": "order", "schema": "public", "indexes": [ { - "keyName": "IDX_order_display_id", "columnNames": [ - "display_id" + "shipping_address_id" + ], + "composite": false, + "keyName": "order_shipping_address_id_unique", + "primary": false, + "unique": true + }, + { + "columnNames": [ + "billing_address_id" ], "composite": false, + "keyName": "order_billing_address_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_order_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (deleted_at) WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_order_display_id", + "columnNames": [], + "composite": false, "primary": false, "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_display_id\" ON \"order\" (display_id) WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_region_id", - "columnNames": [ - "region_id" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, @@ -379,39 +417,31 @@ }, { "keyName": "IDX_order_customer_id", - "columnNames": [ - "customer_id" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (customer_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_customer_id", - "columnNames": [ - "sales_channel_id" - ], + "keyName": "IDX_order_sales_channel_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (customer_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_sales_channel_id\" ON \"order\" (sales_channel_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_is_draft_order", - "columnNames": [ - "is_draft_order" - ], + "keyName": "IDX_order_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_is_draft_order\" ON \"order\" (is_draft_order) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_currency_code", - "columnNames": [ - "currency_code" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, @@ -419,9 +449,7 @@ }, { "keyName": "IDX_order_shipping_address_id", - "columnNames": [ - "shipping_address_id" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, @@ -429,23 +457,19 @@ }, { "keyName": "IDX_order_billing_address_id", - "columnNames": [ - "billing_address_id" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_billing_address_id\" ON \"order\" (billing_address_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_is_draft_order", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_is_draft_order\" ON \"order\" (is_draft_order) WHERE deleted_at IS NOT NULL" }, { "keyName": "order_pkey", @@ -498,17 +522,17 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "return_id": { + "name": "return_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "reference": { - "name": "reference", + "claim_id": { + "name": "claim_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -516,8 +540,8 @@ "nullable": true, "mappedType": "text" }, - "reference_id": { - "name": "reference_id", + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -525,57 +549,98 @@ "nullable": true, "mappedType": "text" }, - "amount": { - "name": "amount", - "type": "numeric", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "mappedType": "integer" }, - "raw_amount": { - "name": "raw_amount", - "type": "jsonb", + "change_type": { + "name": "change_type", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + "description": { + "name": "description", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "created_at": { - "name": "created_at", - "type": "timestamptz", + "status": { + "name": "status", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "nullable": true, + "default": "'pending'", + "enumItems": [ + "confirmed", + "declined", + "requested", + "pending", + "canceled" + ], + "mappedType": "enum" }, - "updated_at": { - "name": "updated_at", + "internal_note": { + "name": "internal_note", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "created_by": { + "name": "created_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "requested_by": { + "name": "requested_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "requested_at": { + "name": "requested_at", "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "length": 6, - "default": "now()", "mappedType": "datetime" }, - "deleted_at": { - "name": "deleted_at", + "confirmed_by": { + "name": "confirmed_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "confirmed_at": { + "name": "confirmed_at", "type": "timestamptz", "unsigned": false, "autoincrement": false, @@ -583,33 +648,182 @@ "nullable": true, "length": 6, "mappedType": "datetime" - } - }, - "name": "order_credit_line", - "schema": "public", - "indexes": [ - { - "keyName": "IDX_order_credit_line_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_order_id\" ON \"order_credit_line\" (order_id) WHERE deleted_at IS NOT NULL" }, + "declined_by": { + "name": "declined_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "declined_reason": { + "name": "declined_reason", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "declined_at": { + "name": "declined_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "canceled_by": { + "name": "canceled_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_change", + "schema": "public", + "indexes": [ { - "keyName": "IDX_order_credit_line_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_change_order_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_deleted_at\" ON \"order_credit_line\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (order_id) WHERE deleted_at IS NULL" }, { - "keyName": "order_credit_line_pkey", + "keyName": "IDX_order_change_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (deleted_at) WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_order_change_order_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_return_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_return_id\" ON \"order_change\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_claim_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_claim_id\" ON \"order_change\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_exchange_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_exchange_id\" ON \"order_change\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_status", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (status) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_version", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_change_pkey", "columnNames": [ "id" ], @@ -620,12 +834,12 @@ ], "checks": [], "foreignKeys": { - "order_credit_line_order_id_foreign": { - "constraintName": "order_credit_line_order_id_foreign", + "order_change_order_id_foreign": { + "constraintName": "order_change_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_credit_line", + "localTableName": "public.order_change", "referencedColumnNames": [ "id" ], @@ -645,8 +859,8 @@ "nullable": false, "mappedType": "text" }, - "title": { - "name": "title", + "order_id": { + "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -654,8 +868,8 @@ "nullable": false, "mappedType": "text" }, - "subtitle": { - "name": "subtitle", + "return_id": { + "name": "return_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -663,8 +877,8 @@ "nullable": true, "mappedType": "text" }, - "thumbnail": { - "name": "thumbnail", + "claim_id": { + "name": "claim_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -672,8 +886,8 @@ "nullable": true, "mappedType": "text" }, - "variant_id": { - "name": "variant_id", + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -681,26 +895,26 @@ "nullable": true, "mappedType": "text" }, - "product_id": { - "name": "product_id", - "type": "text", + "ordering": { + "name": "ordering", + "type": "serial", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "integer" }, - "product_title": { - "name": "product_title", - "type": "text", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "integer" }, - "product_description": { - "name": "product_description", + "reference": { + "name": "reference", "type": "text", "unsigned": false, "autoincrement": false, @@ -708,8 +922,8 @@ "nullable": true, "mappedType": "text" }, - "product_subtitle": { - "name": "product_subtitle", + "reference_id": { + "name": "reference_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -717,35 +931,36 @@ "nullable": true, "mappedType": "text" }, - "product_type": { - "name": "product_type", + "action": { + "name": "action", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "product_type_id": { - "name": "product_type_id", - "type": "text", + "details": { + "name": "details", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "'{}'", + "mappedType": "json" }, - "product_collection": { - "name": "product_collection", - "type": "text", + "amount": { + "name": "amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "decimal" }, - "product_handle": { - "name": "product_handle", + "internal_note": { + "name": "internal_note", "type": "text", "unsigned": false, "autoincrement": false, @@ -753,17 +968,18 @@ "nullable": true, "mappedType": "text" }, - "variant_sku": { - "name": "variant_sku", - "type": "text", + "applied": { + "name": "applied", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "false", + "mappedType": "boolean" }, - "variant_barcode": { - "name": "variant_barcode", + "order_change_id": { + "name": "order_change_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -771,96 +987,205 @@ "nullable": true, "mappedType": "text" }, - "variant_title": { - "name": "variant_title", - "type": "text", + "raw_amount": { + "name": "raw_amount", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, - "variant_option_values": { - "name": "variant_option_values", - "type": "jsonb", + "created_at": { + "name": "created_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "json" + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" }, - "requires_shipping": { - "name": "requires_shipping", - "type": "boolean", + "updated_at": { + "name": "updated_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "boolean" + "length": 6, + "default": "now()", + "mappedType": "datetime" }, - "is_discountable": { - "name": "is_discountable", - "type": "boolean", + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "boolean" + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_change_action", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_change_action_order_change_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_change_id\" ON \"order_change_action\" (order_change_id) WHERE deleted_at IS NULL" }, - "is_tax_inclusive": { - "name": "is_tax_inclusive", - "type": "boolean", + { + "keyName": "IDX_order_change_action_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (deleted_at) WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_order_change_action_order_change_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_change_id\" ON \"order_change_action\" (order_change_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_order_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_return_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_return_id\" ON \"order_change_action\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_claim_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_claim_id\" ON \"order_change_action\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_exchange_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_exchange_id\" ON \"order_change_action\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_ordering", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (ordering) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_change_action_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_change_action_order_change_id_foreign": { + "constraintName": "order_change_action_order_change_id_foreign", + "columnNames": [ + "order_change_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_change", + "deleteRule": "cascade", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "boolean" + "mappedType": "text" }, - "compare_at_unit_price": { - "name": "compare_at_unit_price", - "type": "numeric", + "order_id": { + "name": "order_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "decimal" + "nullable": false, + "mappedType": "text" }, - "raw_compare_at_unit_price": { - "name": "raw_compare_at_unit_price", - "type": "jsonb", + "reference": { + "name": "reference", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "unit_price": { - "name": "unit_price", - "type": "numeric", + "reference_id": { + "name": "reference_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "decimal" + "mappedType": "text" }, - "raw_unit_price": { - "name": "raw_unit_price", - "type": "jsonb", + "amount": { + "name": "amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "mappedType": "decimal" }, - "is_custom_price": { - "name": "is_custom_price", - "type": "boolean", + "raw_amount": { + "name": "raw_amount", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "false", - "mappedType": "boolean" + "mappedType": "json" }, "metadata": { "name": "metadata", @@ -904,51 +1229,43 @@ "mappedType": "datetime" } }, - "name": "order_line_item", + "name": "order_credit_line", "schema": "public", "indexes": [ { - "keyName": "IDX_order_line_item_variant_id", - "columnNames": [ - "variant_id" - ], + "keyName": "IDX_order_credit_line_order_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (variant_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_order_id\" ON \"order_credit_line\" (order_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_line_item_product_id", - "columnNames": [ - "product_id" - ], + "keyName": "IDX_order_credit_line_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (product_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_deleted_at\" ON \"order_credit_line\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_line_item_product_type_id", - "columnNames": [ - "product_type_id" - ], + "keyName": "IDX_order_credit_line_order_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_product_type_id\" ON \"order_line_item\" (product_type_id) WHERE deleted_at IS NOT NULL AND product_type_id IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_order_id\" ON \"order_credit_line\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_line_item_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_credit_line_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_deleted_at\" ON \"order_credit_line\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_line_item_pkey", + "keyName": "order_credit_line_pkey", "columnNames": [ "id" ], @@ -958,7 +1275,20 @@ } ], "checks": [], - "foreignKeys": {} + "foreignKeys": { + "order_credit_line_order_id_foreign": { + "constraintName": "order_credit_line_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.order_credit_line", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "updateRule": "cascade" + } + } }, { "columns": { @@ -971,8 +1301,8 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "title": { + "name": "title", "type": "text", "unsigned": false, "autoincrement": false, @@ -980,206 +1310,219 @@ "nullable": false, "mappedType": "text" }, - "version": { - "name": "version", - "type": "integer", + "subtitle": { + "name": "subtitle", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "item_id": { - "name": "item_id", + "nullable": true, + "mappedType": "text" + }, + "thumbnail": { + "name": "thumbnail", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "unit_price": { - "name": "unit_price", - "type": "numeric", + "variant_id": { + "name": "variant_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "decimal" + "mappedType": "text" }, - "raw_unit_price": { - "name": "raw_unit_price", - "type": "jsonb", + "product_id": { + "name": "product_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "compare_at_unit_price": { - "name": "compare_at_unit_price", - "type": "numeric", + "product_title": { + "name": "product_title", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "decimal" + "mappedType": "text" }, - "raw_compare_at_unit_price": { - "name": "raw_compare_at_unit_price", - "type": "jsonb", + "product_description": { + "name": "product_description", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "quantity": { - "name": "quantity", - "type": "numeric", + "product_subtitle": { + "name": "product_subtitle", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_quantity": { - "name": "raw_quantity", - "type": "jsonb", + "product_type": { + "name": "product_type", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "fulfilled_quantity": { - "name": "fulfilled_quantity", - "type": "numeric", + "product_type_id": { + "name": "product_type_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_fulfilled_quantity": { - "name": "raw_fulfilled_quantity", - "type": "jsonb", + "product_collection": { + "name": "product_collection", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "delivered_quantity": { - "name": "delivered_quantity", - "type": "numeric", + "product_handle": { + "name": "product_handle", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_delivered_quantity": { - "name": "raw_delivered_quantity", - "type": "jsonb", + "variant_sku": { + "name": "variant_sku", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "shipped_quantity": { - "name": "shipped_quantity", - "type": "numeric", + "variant_barcode": { + "name": "variant_barcode", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_shipped_quantity": { - "name": "raw_shipped_quantity", + "variant_title": { + "name": "variant_title", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "variant_option_values": { + "name": "variant_option_values", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "json" }, - "return_requested_quantity": { - "name": "return_requested_quantity", - "type": "numeric", + "requires_shipping": { + "name": "requires_shipping", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "default": "true", + "mappedType": "boolean" }, - "raw_return_requested_quantity": { - "name": "raw_return_requested_quantity", - "type": "jsonb", + "is_discountable": { + "name": "is_discountable", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "default": "true", + "mappedType": "boolean" }, - "return_received_quantity": { - "name": "return_received_quantity", - "type": "numeric", + "is_tax_inclusive": { + "name": "is_tax_inclusive", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "default": "false", + "mappedType": "boolean" }, - "raw_return_received_quantity": { - "name": "raw_return_received_quantity", - "type": "jsonb", + "compare_at_unit_price": { + "name": "compare_at_unit_price", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "decimal" }, - "return_dismissed_quantity": { - "name": "return_dismissed_quantity", + "unit_price": { + "name": "unit_price", "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "decimal" }, - "raw_return_dismissed_quantity": { - "name": "raw_return_dismissed_quantity", - "type": "jsonb", + "is_custom_price": { + "name": "is_custom_price", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "default": "false", + "mappedType": "boolean" }, - "written_off_quantity": { - "name": "written_off_quantity", - "type": "numeric", + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "json" }, - "raw_written_off_quantity": { - "name": "raw_written_off_quantity", + "raw_compare_at_unit_price": { + "name": "raw_compare_at_unit_price", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "json" }, - "metadata": { - "name": "metadata", + "raw_unit_price": { + "name": "raw_unit_price", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -1220,51 +1563,51 @@ "mappedType": "datetime" } }, - "name": "order_item", + "name": "order_line_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_item_order_id", - "columnNames": [ - "order_id" - ], + "keyName": "IDX_order_line_item_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_item_version", - "columnNames": [ - "version" - ], + "keyName": "IDX_order_line_item_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_version\" ON \"order_item\" (version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_item_item_id", - "columnNames": [ - "item_id" - ], + "keyName": "IDX_order_line_item_product_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_item_id\" ON \"order_item\" (item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (product_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_item_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_line_item_product_type_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_product_type_id\" ON \"order_line_item\" (product_type_id) WHERE deleted_at IS NOT NULL AND product_type_id IS NOT NULL" }, { - "keyName": "order_item_pkey", + "keyName": "IDX_order_line_item_variant_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (variant_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_line_item_pkey", "columnNames": [ "id" ], @@ -1274,32 +1617,7 @@ } ], "checks": [], - "foreignKeys": { - "order_item_order_id_foreign": { - "constraintName": "order_item_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_item", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "updateRule": "cascade" - }, - "order_item_item_id_foreign": { - "constraintName": "order_item_item_id_foreign", - "columnNames": [ - "item_id" - ], - "localTableName": "public.order_item", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_line_item", - "updateRule": "cascade" - } - } + "foreignKeys": {} }, { "columns": { @@ -1312,35 +1630,36 @@ "nullable": false, "mappedType": "text" }, - "description": { - "name": "description", - "type": "text", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "1", + "mappedType": "integer" }, - "promotion_id": { - "name": "promotion_id", - "type": "text", + "unit_price": { + "name": "unit_price", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "decimal" }, - "code": { - "name": "code", - "type": "text", + "compare_at_unit_price": { + "name": "compare_at_unit_price", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "decimal" }, - "amount": { - "name": "amount", + "quantity": { + "name": "quantity", "type": "numeric", "unsigned": false, "autoincrement": false, @@ -1348,110 +1667,96 @@ "nullable": false, "mappedType": "decimal" }, - "raw_amount": { - "name": "raw_amount", - "type": "jsonb", + "fulfilled_quantity": { + "name": "fulfilled_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "default": "0", + "mappedType": "decimal" }, - "provider_id": { - "name": "provider_id", - "type": "text", + "delivered_quantity": { + "name": "delivered_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "created_at": { - "name": "created_at", - "type": "timestamptz", + "shipped_quantity": { + "name": "shipped_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "default": "0", + "mappedType": "decimal" }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", + "return_requested_quantity": { + "name": "return_requested_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "default": "0", + "mappedType": "decimal" }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", + "return_received_quantity": { + "name": "return_received_quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "decimal" + }, + "return_dismissed_quantity": { + "name": "return_dismissed_quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "decimal" + }, + "written_off_quantity": { + "name": "written_off_quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "decimal" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "length": 6, - "mappedType": "datetime" + "mappedType": "json" }, - "item_id": { - "name": "item_id", + "order_id": { + "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, "mappedType": "text" - } - }, - "name": "order_line_item_adjustment", - "schema": "public", - "indexes": [ - { - "keyName": "IDX_order_line_item_adjustment_item_id", - "columnNames": [ - "item_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (item_id)" }, - { - "keyName": "order_line_item_adjustment_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_line_item_adjustment_item_id_foreign": { - "constraintName": "order_line_item_adjustment_item_id_foreign", - "columnNames": [ - "item_id" - ], - "localTableName": "public.order_line_item_adjustment", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_line_item", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1459,44 +1764,44 @@ "nullable": false, "mappedType": "text" }, - "description": { - "name": "description", - "type": "text", + "raw_unit_price": { + "name": "raw_unit_price", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, - "tax_rate_id": { - "name": "tax_rate_id", - "type": "text", + "raw_compare_at_unit_price": { + "name": "raw_compare_at_unit_price", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, - "code": { - "name": "code", - "type": "text", + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "mappedType": "json" }, - "rate": { - "name": "rate", - "type": "numeric", + "raw_fulfilled_quantity": { + "name": "raw_fulfilled_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "mappedType": "json" }, - "raw_rate": { - "name": "raw_rate", + "raw_delivered_quantity": { + "name": "raw_delivered_quantity", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -1504,14 +1809,50 @@ "nullable": false, "mappedType": "json" }, - "provider_id": { - "name": "provider_id", - "type": "text", + "raw_shipped_quantity": { + "name": "raw_shipped_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" + }, + "raw_return_requested_quantity": { + "name": "raw_return_requested_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "raw_return_received_quantity": { + "name": "raw_return_received_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "raw_return_dismissed_quantity": { + "name": "raw_return_dismissed_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "raw_written_off_quantity": { + "name": "raw_written_off_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" }, "created_at": { "name": "created_at", @@ -1544,32 +1885,70 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "item_id": { - "name": "item_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" } }, - "name": "order_line_item_tax_line", + "name": "order_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_line_item_tax_line_item_id", "columnNames": [ "item_id" ], "composite": false, + "keyName": "order_item_item_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_order_item_order_id", + "columnNames": [], + "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_item_id\" ON \"order_line_item_tax_line\" (item_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (order_id) WHERE deleted_at IS NULL" }, { - "keyName": "order_line_item_tax_line_pkey", + "keyName": "IDX_order_item_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_order_item_order_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_item_version", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_version\" ON \"order_item\" (version) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_item_item_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_item_id\" ON \"order_item\" (item_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_item_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_item_pkey", "columnNames": [ "id" ], @@ -1580,17 +1959,29 @@ ], "checks": [], "foreignKeys": { - "order_line_item_tax_line_item_id_foreign": { - "constraintName": "order_line_item_tax_line_item_id_foreign", + "order_item_order_id_foreign": { + "constraintName": "order_item_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.order_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_item_item_id_foreign": { + "constraintName": "order_item_item_id_foreign", "columnNames": [ "item_id" ], - "localTableName": "public.order_line_item_tax_line", + "localTableName": "public.order_item", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order_line_item", - "deleteRule": "cascade", "updateRule": "cascade" } } @@ -1606,64 +1997,44 @@ "nullable": false, "mappedType": "text" }, - "name": { - "name": "name", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, "description": { "name": "description", - "type": "jsonb", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" - }, - "amount": { - "name": "amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" + "mappedType": "text" }, - "raw_amount": { - "name": "raw_amount", - "type": "jsonb", + "promotion_id": { + "name": "promotion_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "is_tax_inclusive": { - "name": "is_tax_inclusive", - "type": "boolean", + "code": { + "name": "code", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" + "nullable": true, + "mappedType": "text" }, - "is_custom_amount": { - "name": "is_custom_amount", - "type": "boolean", + "amount": { + "name": "amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "false", - "mappedType": "boolean" + "mappedType": "decimal" }, - "shipping_option_id": { - "name": "shipping_option_id", + "provider_id": { + "name": "provider_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1671,22 +2042,22 @@ "nullable": true, "mappedType": "text" }, - "data": { - "name": "data", - "type": "jsonb", + "item_id": { + "name": "item_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "json" + "nullable": false, + "mappedType": "text" }, - "metadata": { - "name": "metadata", + "raw_amount": { + "name": "raw_amount", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "json" }, "created_at": { @@ -1722,31 +2093,35 @@ "mappedType": "datetime" } }, - "name": "order_shipping_method", + "name": "order_line_item_adjustment", "schema": "public", "indexes": [ { - "keyName": "IDX_order_shipping_method_shipping_option_id", - "columnNames": [ - "shipping_option_id" - ], + "keyName": "IDX_order_line_item_adjustment_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_shipping_option_id\" ON \"order_shipping_method\" (shipping_option_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (item_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_shipping_method_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_line_item_adjustment_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_deleted_at\" ON \"order_shipping_method\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_deleted_at\" ON \"order_line_item_adjustment\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "order_shipping_method_pkey", + "keyName": "IDX_order_order_line_item_adjustment_item_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (item_id) WHERE deleted_at IS NULL" + }, + { + "keyName": "order_line_item_adjustment_pkey", "columnNames": [ "id" ], @@ -1756,7 +2131,21 @@ } ], "checks": [], - "foreignKeys": {} + "foreignKeys": { + "order_line_item_adjustment_item_id_foreign": { + "constraintName": "order_line_item_adjustment_item_id_foreign", + "columnNames": [ + "item_id" + ], + "localTableName": "public.order_line_item_adjustment", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_line_item", + "deleteRule": "cascade", + "updateRule": "cascade" + } + } }, { "columns": { @@ -1778,8 +2167,8 @@ "nullable": true, "mappedType": "text" }, - "promotion_id": { - "name": "promotion_id", + "tax_rate_id": { + "name": "tax_rate_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1793,11 +2182,11 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "amount": { - "name": "amount", + "rate": { + "name": "rate", "type": "numeric", "unsigned": false, "autoincrement": false, @@ -1805,24 +2194,33 @@ "nullable": false, "mappedType": "decimal" }, - "raw_amount": { - "name": "raw_amount", - "type": "jsonb", + "provider_id": { + "name": "provider_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "provider_id": { - "name": "provider_id", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, + "raw_rate": { + "name": "raw_rate", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -1854,32 +2252,29 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "shipping_method_id": { - "name": "shipping_method_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" } }, - "name": "order_shipping_method_adjustment", + "name": "order_line_item_tax_line", "schema": "public", "indexes": [ { - "keyName": "IDX_order_shipping_method_adjustment_shipping_method_id", - "columnNames": [ - "shipping_method_id" - ], + "keyName": "IDX_order_line_item_tax_line_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_shipping_method_id\" ON \"order_shipping_method_adjustment\" (shipping_method_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_item_id\" ON \"order_line_item_tax_line\" (item_id) WHERE deleted_at IS NULL" }, { - "keyName": "order_shipping_method_adjustment_pkey", + "keyName": "IDX_order_line_item_tax_line_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_deleted_at\" ON \"order_line_item_tax_line\" (deleted_at) WHERE deleted_at IS NULL" + }, + { + "keyName": "order_line_item_tax_line_pkey", "columnNames": [ "id" ], @@ -1890,16 +2285,16 @@ ], "checks": [], "foreignKeys": { - "order_shipping_method_adjustment_shipping_method_id_foreign": { - "constraintName": "order_shipping_method_adjustment_shipping_method_id_foreign", + "order_line_item_tax_line_item_id_foreign": { + "constraintName": "order_line_item_tax_line_item_id_foreign", "columnNames": [ - "shipping_method_id" + "item_id" ], - "localTableName": "public.order_shipping_method_adjustment", + "localTableName": "public.order_line_item_tax_line", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_shipping_method", + "referencedTableName": "public.order_line_item", "deleteRule": "cascade", "updateRule": "cascade" } @@ -1916,53 +2311,55 @@ "nullable": false, "mappedType": "text" }, - "description": { - "name": "description", - "type": "text", + "name": { + "name": "name", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "tax_rate_id": { - "name": "tax_rate_id", - "type": "text", + "description": { + "name": "description", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, - "code": { - "name": "code", - "type": "text", + "amount": { + "name": "amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "mappedType": "decimal" }, - "rate": { - "name": "rate", - "type": "numeric", + "is_tax_inclusive": { + "name": "is_tax_inclusive", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "default": "false", + "mappedType": "boolean" }, - "raw_rate": { - "name": "raw_rate", - "type": "jsonb", + "is_custom_amount": { + "name": "is_custom_amount", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "default": "false", + "mappedType": "boolean" }, - "provider_id": { - "name": "provider_id", + "shipping_option_id": { + "name": "shipping_option_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1970,6 +2367,33 @@ "nullable": true, "mappedType": "text" }, + "data": { + "name": "data", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "raw_amount": { + "name": "raw_amount", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -2001,32 +2425,29 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "shipping_method_id": { - "name": "shipping_method_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" } }, - "name": "order_shipping_method_tax_line", + "name": "order_shipping_method", "schema": "public", "indexes": [ { - "keyName": "IDX_order_shipping_method_tax_line_shipping_method_id", - "columnNames": [ - "shipping_method_id" - ], + "keyName": "IDX_order_shipping_method_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_shipping_method_id\" ON \"order_shipping_method_tax_line\" (shipping_method_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_deleted_at\" ON \"order_shipping_method\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "order_shipping_method_tax_line_pkey", + "keyName": "IDX_order_shipping_method_shipping_option_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_shipping_option_id\" ON \"order_shipping_method\" (shipping_option_id) WHERE deleted_at IS NULL" + }, + { + "keyName": "order_shipping_method_pkey", "columnNames": [ "id" ], @@ -2036,21 +2457,7 @@ } ], "checks": [], - "foreignKeys": { - "order_shipping_method_tax_line_shipping_method_id_foreign": { - "constraintName": "order_shipping_method_tax_line_shipping_method_id_foreign", - "columnNames": [ - "shipping_method_id" - ], - "localTableName": "public.order_shipping_method_tax_line", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_shipping_method", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } + "foreignKeys": {} }, { "columns": { @@ -2063,27 +2470,62 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "description": { + "name": "description", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "promotion_id": { + "name": "promotion_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "code": { + "name": "code", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, + "nullable": true, + "mappedType": "text" + }, + "amount": { + "name": "amount", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, "nullable": false, + "mappedType": "decimal" + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, "mappedType": "text" }, - "version": { - "name": "version", - "type": "integer", + "shipping_method_id": { + "name": "shipping_method_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "1", - "mappedType": "integer" + "mappedType": "text" }, - "totals": { - "name": "totals", + "raw_amount": { + "name": "raw_amount", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -2124,29 +2566,27 @@ "mappedType": "datetime" } }, - "name": "order_summary", + "name": "order_shipping_method_adjustment", "schema": "public", "indexes": [ { - "keyName": "IDX_order_summary_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_shipping_method_adjustment_shipping_method_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_shipping_method_id\" ON \"order_shipping_method_adjustment\" (shipping_method_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_summary_order_id_version", + "keyName": "IDX_order_shipping_method_adjustment_deleted_at", "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id_version\" ON \"order_summary\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_deleted_at\" ON \"order_shipping_method_adjustment\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "order_summary_pkey", + "keyName": "order_shipping_method_adjustment_pkey", "columnNames": [ "id" ], @@ -2157,16 +2597,16 @@ ], "checks": [], "foreignKeys": { - "order_summary_order_id_foreign": { - "constraintName": "order_summary_order_id_foreign", + "order_shipping_method_adjustment_shipping_method_id_foreign": { + "constraintName": "order_shipping_method_adjustment_shipping_method_id_foreign", "columnNames": [ - "order_id" + "shipping_method_id" ], - "localTableName": "public.order_summary", + "localTableName": "public.order_shipping_method_adjustment", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order", + "referencedTableName": "public.order_shipping_method", "deleteRule": "cascade", "updateRule": "cascade" } @@ -2183,17 +2623,17 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "description": { + "name": "description", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "exchange_id": { - "name": "exchange_id", + "tax_rate_id": { + "name": "tax_rate_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -2201,158 +2641,193 @@ "nullable": true, "mappedType": "text" }, - "claim_id": { - "name": "claim_id", + "code": { + "name": "code", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "order_version": { - "name": "order_version", - "type": "integer", + "rate": { + "name": "rate", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "integer" - }, - "display_id": { - "name": "display_id", - "type": "serial", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" + "mappedType": "decimal" }, - "status": { - "name": "status", + "provider_id": { + "name": "provider_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "default": "'open'", - "enumItems": [ - "open", - "requested", - "received", - "partially_received", - "canceled" - ], - "mappedType": "enum" + "nullable": true, + "mappedType": "text" }, - "location_id": { - "name": "location_id", + "shipping_method_id": { + "name": "shipping_method_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "no_notification": { - "name": "no_notification", - "type": "boolean", + "raw_rate": { + "name": "raw_rate", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "boolean" + "nullable": false, + "mappedType": "json" }, - "refund_amount": { - "name": "refund_amount", - "type": "numeric", + "created_at": { + "name": "created_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "decimal" + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" }, - "raw_refund_amount": { - "name": "raw_refund_amount", - "type": "jsonb", + "updated_at": { + "name": "updated_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "json" + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" }, - "created_by": { - "name": "created_by", - "type": "text", + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_shipping_method_tax_line", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_shipping_method_tax_line_shipping_method_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_shipping_method_id\" ON \"order_shipping_method_tax_line\" (shipping_method_id) WHERE deleted_at IS NULL" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + { + "keyName": "IDX_order_shipping_method_tax_line_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_deleted_at\" ON \"order_shipping_method_tax_line\" (deleted_at) WHERE deleted_at IS NULL" + }, + { + "keyName": "order_shipping_method_tax_line_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_shipping_method_tax_line_shipping_method_id_foreign": { + "constraintName": "order_shipping_method_tax_line_shipping_method_id_foreign", + "columnNames": [ + "shipping_method_id" + ], + "localTableName": "public.order_shipping_method_tax_line", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_shipping_method", + "deleteRule": "cascade", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "json" + "nullable": false, + "mappedType": "text" }, - "created_at": { - "name": "created_at", - "type": "timestamptz", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "default": "1", + "mappedType": "integer" }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", + "totals": { + "name": "totals", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "mappedType": "json" }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", + "order_id": { + "name": "order_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "mappedType": "text" }, - "requested_at": { - "name": "requested_at", + "created_at": { + "name": "created_at", "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, - "received_at": { - "name": "received_at", + "updated_at": { + "name": "updated_at", "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "length": 6, + "default": "now()", "mappedType": "datetime" }, - "canceled_at": { - "name": "canceled_at", + "deleted_at": { + "name": "deleted_at", "type": "timestamptz", "unsigned": false, "autoincrement": false, @@ -2362,79 +2837,43 @@ "mappedType": "datetime" } }, - "name": "return", + "name": "order_summary", "schema": "public", "indexes": [ { - "columnNames": [ - "exchange_id" - ], - "composite": false, - "keyName": "return_exchange_id_unique", - "primary": false, - "unique": true - }, - { - "columnNames": [ - "claim_id" - ], - "composite": false, - "keyName": "return_claim_id_unique", - "primary": false, - "unique": true - }, - { - "keyName": "IDX_return_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (order_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_return_exchange_id", - "columnNames": [ - "exchange_id" - ], + "keyName": "IDX_order_summary_order_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_exchange_id\" ON \"return\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id\" ON \"order_summary\" (order_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_return_claim_id", - "columnNames": [ - "claim_id" - ], + "keyName": "IDX_order_summary_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_claim_id\" ON \"return\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_return_display_id", - "columnNames": [ - "display_id" - ], + "keyName": "IDX_order_summary_order_id_version", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_display_id\" ON \"return\" (display_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id_version\" ON \"order_summary\" (order_id, version) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_return_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_summary_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "return_pkey", + "keyName": "order_summary_pkey", "columnNames": [ "id" ], @@ -2445,42 +2884,17 @@ ], "checks": [], "foreignKeys": { - "return_order_id_foreign": { - "constraintName": "return_order_id_foreign", + "order_summary_order_id_foreign": { + "constraintName": "order_summary_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.return", + "localTableName": "public.order_summary", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", - "updateRule": "cascade" - }, - "return_exchange_id_foreign": { - "constraintName": "return_exchange_id_foreign", - "columnNames": [ - "exchange_id" - ], - "localTableName": "public.return", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_exchange", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "return_claim_id_foreign": { - "constraintName": "return_claim_id_foreign", - "columnNames": [ - "claim_id" - ], - "localTableName": "public.return", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_claim", - "deleteRule": "set null", + "deleteRule": "cascade", "updateRule": "cascade" } } @@ -2496,24 +2910,6 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "return_id": { - "name": "return_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, "order_version": { "name": "order_version", "type": "integer", @@ -2526,23 +2922,49 @@ "display_id": { "name": "display_id", "type": "serial", - "unsigned": true, - "autoincrement": true, + "unsigned": false, + "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "integer" }, - "no_notification": { - "name": "no_notification", - "type": "boolean", + "status": { + "name": "status", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "boolean" - }, - "difference_due": { - "name": "difference_due", + "nullable": false, + "default": "'open'", + "enumItems": [ + "open", + "requested", + "received", + "partially_received", + "canceled" + ], + "mappedType": "enum" + }, + "location_id": { + "name": "location_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "no_notification": { + "name": "no_notification", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "boolean" + }, + "refund_amount": { + "name": "refund_amount", "type": "numeric", "unsigned": false, "autoincrement": false, @@ -2550,8 +2972,17 @@ "nullable": true, "mappedType": "decimal" }, - "raw_difference_due": { - "name": "raw_difference_due", + "created_by": { + "name": "created_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -2559,18 +2990,47 @@ "nullable": true, "mappedType": "json" }, - "allow_backorder": { - "name": "allow_backorder", - "type": "boolean", + "requested_at": { + "name": "requested_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "received_at": { + "name": "received_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "order_id": { + "name": "order_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "false", - "mappedType": "boolean" + "mappedType": "text" }, - "created_by": { - "name": "created_by", + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -2578,8 +3038,17 @@ "nullable": true, "mappedType": "text" }, - "metadata": { - "name": "metadata", + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "raw_refund_amount": { + "name": "raw_refund_amount", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -2618,72 +3087,87 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" } }, - "name": "order_exchange", + "name": "return", "schema": "public", "indexes": [ { "columnNames": [ - "return_id" + "exchange_id" ], "composite": false, - "keyName": "order_exchange_return_id_unique", + "keyName": "return_exchange_id_unique", "primary": false, "unique": true }, { - "keyName": "IDX_order_exchange_order_id", "columnNames": [ - "order_id" + "claim_id" ], "composite": false, + "keyName": "return_claim_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_return_order_id", + "columnNames": [], + "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_order_id\" ON \"order_exchange\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (order_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_exchange_return_id", - "columnNames": [ - "return_id" - ], + "keyName": "IDX_return_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_return_id\" ON \"order_exchange\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_exchange_display_id", - "columnNames": [ - "display_id" - ], + "keyName": "IDX_return_display_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_display_id\" ON \"order_exchange\" (display_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_display_id\" ON \"return\" (display_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_exchange_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_return_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_exchange_pkey", + "keyName": "IDX_return_order_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_return_exchange_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_exchange_id\" ON \"return\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_return_claim_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_claim_id\" ON \"return\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "return_pkey", "columnNames": [ "id" ], @@ -2694,28 +3178,41 @@ ], "checks": [], "foreignKeys": { - "order_exchange_order_id_foreign": { - "constraintName": "order_exchange_order_id_foreign", + "return_order_id_foreign": { + "constraintName": "return_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_exchange", + "localTableName": "public.return", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", "updateRule": "cascade" }, - "order_exchange_return_id_foreign": { - "constraintName": "order_exchange_return_id_foreign", + "return_exchange_id_foreign": { + "constraintName": "return_exchange_id_foreign", "columnNames": [ - "return_id" + "exchange_id" ], - "localTableName": "public.order_exchange", + "localTableName": "public.return", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.return", + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "return_claim_id_foreign": { + "constraintName": "return_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.return", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", "deleteRule": "set null", "updateRule": "cascade" } @@ -2732,44 +3229,54 @@ "nullable": false, "mappedType": "text" }, - "quantity": { - "name": "quantity", - "type": "numeric", + "order_version": { + "name": "order_version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "mappedType": "integer" }, - "raw_quantity": { - "name": "raw_quantity", - "type": "jsonb", + "display_id": { + "name": "display_id", + "type": "serial", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "integer" }, - "exchange_id": { - "name": "exchange_id", - "type": "text", + "no_notification": { + "name": "no_notification", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "text" + "nullable": true, + "mappedType": "boolean" }, - "item_id": { - "name": "item_id", - "type": "text", + "difference_due": { + "name": "difference_due", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "decimal" + }, + "allow_backorder": { + "name": "allow_backorder", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "default": "false", + "mappedType": "boolean" }, - "note": { - "name": "note", + "created_by": { + "name": "created_by", "type": "text", "unsigned": false, "autoincrement": false, @@ -2786,6 +3293,43 @@ "nullable": true, "mappedType": "json" }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "raw_difference_due": { + "name": "raw_difference_due", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -2819,41 +3363,69 @@ "mappedType": "datetime" } }, - "name": "order_exchange_item", + "name": "order_exchange", "schema": "public", "indexes": [ { - "keyName": "IDX_order_exchange_item_exchange_id", "columnNames": [ - "exchange_id" + "order_id" ], "composite": false, + "keyName": "order_exchange_order_id_unique", "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_exchange_id\" ON \"order_exchange_item\" (exchange_id) WHERE deleted_at IS NOT NULL" + "unique": true }, { - "keyName": "IDX_order_exchange_item_item_id", "columnNames": [ - "item_id" + "return_id" ], "composite": false, + "keyName": "order_exchange_return_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_order_exchange_deleted_at", + "columnNames": [], + "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_item_id\" ON \"order_exchange_item\" (item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_claim_item_image_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_exchange_display_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_display_id\" ON \"order_exchange\" (display_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_exchange_item_pkey", + "keyName": "IDX_order_exchange_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_exchange_order_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_order_id\" ON \"order_exchange\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_exchange_return_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_return_id\" ON \"order_exchange\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "order_exchange_pkey", "columnNames": [ "id" ], @@ -2864,29 +3436,29 @@ ], "checks": [], "foreignKeys": { - "order_exchange_item_exchange_id_foreign": { - "constraintName": "order_exchange_item_exchange_id_foreign", + "order_exchange_order_id_foreign": { + "constraintName": "order_exchange_order_id_foreign", "columnNames": [ - "exchange_id" + "order_id" ], - "localTableName": "public.order_exchange_item", + "localTableName": "public.order_exchange", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_exchange", - "deleteRule": "cascade", + "referencedTableName": "public.order", "updateRule": "cascade" }, - "order_exchange_item_item_id_foreign": { - "constraintName": "order_exchange_item_item_id_foreign", + "order_exchange_return_id_foreign": { + "constraintName": "order_exchange_return_id_foreign", "columnNames": [ - "item_id" + "return_id" ], - "localTableName": "public.order_exchange_item", + "localTableName": "public.order_exchange", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_line_item", + "referencedTableName": "public.return", + "deleteRule": "set null", "updateRule": "cascade" } } @@ -2902,17 +3474,17 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", - "type": "text", + "quantity": { + "name": "quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "mappedType": "decimal" }, - "return_id": { - "name": "return_id", + "note": { + "name": "note", "type": "text", "unsigned": false, "autoincrement": false, @@ -2920,80 +3492,40 @@ "nullable": true, "mappedType": "text" }, - "order_version": { - "name": "order_version", - "type": "integer", + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "display_id": { - "name": "display_id", - "type": "serial", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" + "nullable": true, + "mappedType": "json" }, - "type": { - "name": "type", + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "enumItems": [ - "refund", - "replace" - ], - "mappedType": "enum" - }, - "no_notification": { - "name": "no_notification", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "boolean" - }, - "refund_amount": { - "name": "refund_amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "decimal" - }, - "raw_refund_amount": { - "name": "raw_refund_amount", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "created_by": { - "name": "created_by", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "metadata": { - "name": "metadata", + "raw_quantity": { + "name": "raw_quantity", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "json" }, "created_at": { @@ -3027,72 +3559,61 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" } }, - "name": "order_claim", + "name": "order_exchange_item", "schema": "public", "indexes": [ { - "columnNames": [ - "return_id" - ], + "keyName": "IDX_order_exchange_item_exchange_id", + "columnNames": [], "composite": false, - "keyName": "order_claim_return_id_unique", "primary": false, - "unique": true + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_exchange_id\" ON \"order_exchange_item\" (exchange_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_claim_order_id", - "columnNames": [ - "order_id" - ], + "keyName": "IDX_order_exchange_item_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_order_id\" ON \"order_claim\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_item_id\" ON \"order_exchange_item\" (item_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_claim_return_id", - "columnNames": [ - "return_id" - ], + "keyName": "IDX_order_exchange_item_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_return_id\" ON \"order_claim\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_deleted_at\" ON \"order_exchange_item\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_claim_display_id", - "columnNames": [ - "display_id" - ], + "keyName": "IDX_order_exchange_item_exchange_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_display_id\" ON \"order_claim\" (display_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_exchange_id\" ON \"order_exchange_item\" (exchange_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_exchange_item_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_item_id\" ON \"order_exchange_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_claim_pkey", + "keyName": "IDX_order_exchange_item_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_deleted_at\" ON \"order_exchange_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_exchange_item_pkey", "columnNames": [ "id" ], @@ -3103,29 +3624,29 @@ ], "checks": [], "foreignKeys": { - "order_claim_order_id_foreign": { - "constraintName": "order_claim_order_id_foreign", + "order_exchange_item_exchange_id_foreign": { + "constraintName": "order_exchange_item_exchange_id_foreign", "columnNames": [ - "order_id" + "exchange_id" ], - "localTableName": "public.order_claim", + "localTableName": "public.order_exchange_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order", + "referencedTableName": "public.order_exchange", + "deleteRule": "cascade", "updateRule": "cascade" }, - "order_claim_return_id_foreign": { - "constraintName": "order_claim_return_id_foreign", + "order_exchange_item_item_id_foreign": { + "constraintName": "order_exchange_item_item_id_foreign", "columnNames": [ - "return_id" + "item_id" ], - "localTableName": "public.order_claim", + "localTableName": "public.order_exchange_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.return", - "deleteRule": "set null", + "referencedTableName": "public.order_line_item", "updateRule": "cascade" } } @@ -3141,72 +3662,85 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", - "type": "text", + "order_version": { + "name": "order_version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "mappedType": "integer" }, - "return_id": { - "name": "return_id", - "type": "text", + "display_id": { + "name": "display_id", + "type": "serial", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "integer" }, - "exchange_id": { - "name": "exchange_id", + "type": { + "name": "type", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, + "nullable": false, + "enumItems": [ + "refund", + "replace" + ], + "mappedType": "enum" + }, + "no_notification": { + "name": "no_notification", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "boolean" }, - "claim_id": { - "name": "claim_id", - "type": "text", + "refund_amount": { + "name": "refund_amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "decimal" }, - "version": { - "name": "version", - "type": "integer", + "created_by": { + "name": "created_by", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "default": "1", - "mappedType": "integer" + "nullable": true, + "mappedType": "text" }, - "amount": { - "name": "amount", - "type": "numeric", + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "length": 6, + "mappedType": "datetime" }, - "raw_amount": { - "name": "raw_amount", + "metadata": { + "name": "metadata", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "json" }, - "currency_code": { - "name": "currency_code", + "order_id": { + "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3214,8 +3748,8 @@ "nullable": false, "mappedType": "text" }, - "reference": { - "name": "reference", + "return_id": { + "name": "return_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3223,14 +3757,14 @@ "nullable": true, "mappedType": "text" }, - "reference_id": { - "name": "reference_id", - "type": "text", + "raw_refund_amount": { + "name": "raw_refund_amount", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, "created_at": { "name": "created_at", @@ -3265,89 +3799,69 @@ "mappedType": "datetime" } }, - "name": "order_transaction", + "name": "order_claim", "schema": "public", "indexes": [ { - "keyName": "IDX_order_transaction_order_id", "columnNames": [ "order_id" ], "composite": false, + "keyName": "order_claim_order_id_unique", "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id) WHERE deleted_at IS NOT NULL" + "unique": true }, { - "keyName": "IDX_order_transaction_return_id", "columnNames": [ "return_id" ], "composite": false, + "keyName": "order_claim_return_id_unique", "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_transaction_exchange_id", - "columnNames": [ - "exchange_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "unique": true }, { - "keyName": "IDX_order_transaction_claim_id", - "columnNames": [ - "claim_id" - ], + "keyName": "IDX_order_claim_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_transaction_currency_code", - "columnNames": [ - "currency_code" - ], + "keyName": "IDX_order_claim_display_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (currency_code) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_display_id\" ON \"order_claim\" (display_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_transaction_reference_id", - "columnNames": [ - "reference_id" - ], + "keyName": "IDX_order_claim_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (reference_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_transaction_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_claim_order_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_order_id\" ON \"order_claim\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_transaction_order_id_version", + "keyName": "IDX_order_claim_return_id", "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id_version\" ON \"order_transaction\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_return_id\" ON \"order_claim\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "order_transaction_pkey", + "keyName": "order_claim_pkey", "columnNames": [ "id" ], @@ -3358,57 +3872,30 @@ ], "checks": [], "foreignKeys": { - "order_transaction_order_id_foreign": { - "constraintName": "order_transaction_order_id_foreign", + "order_claim_order_id_foreign": { + "constraintName": "order_claim_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_transaction", + "localTableName": "public.order_claim", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", - "deleteRule": "cascade", "updateRule": "cascade" }, - "order_transaction_return_id_foreign": { - "constraintName": "order_transaction_return_id_foreign", + "order_claim_return_id_foreign": { + "constraintName": "order_claim_return_id_foreign", "columnNames": [ "return_id" ], - "localTableName": "public.order_transaction", + "localTableName": "public.order_claim", "referencedColumnNames": [ "id" ], "referencedTableName": "public.return", "deleteRule": "set null", "updateRule": "cascade" - }, - "order_transaction_exchange_id_foreign": { - "constraintName": "order_transaction_exchange_id_foreign", - "columnNames": [ - "exchange_id" - ], - "localTableName": "public.order_transaction", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_exchange", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_transaction_claim_id_foreign": { - "constraintName": "order_transaction_claim_id_foreign", - "columnNames": [ - "claim_id" - ], - "localTableName": "public.order_transaction", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_claim", - "deleteRule": "set null", - "updateRule": "cascade" } } }, @@ -3423,6 +3910,52 @@ "nullable": false, "mappedType": "text" }, + "version": { + "name": "version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "1", + "mappedType": "integer" + }, + "amount": { + "name": "amount", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "decimal" + }, + "currency_code": { + "name": "currency_code", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "reference": { + "name": "reference", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "order_id": { "name": "order_id", "type": "text", @@ -3459,23 +3992,14 @@ "nullable": true, "mappedType": "text" }, - "version": { - "name": "version", - "type": "integer", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "shipping_method_id": { - "name": "shipping_method_id", - "type": "text", + "raw_amount": { + "name": "raw_amount", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "mappedType": "json" }, "created_at": { "name": "created_at", @@ -3510,81 +4034,115 @@ "mappedType": "datetime" } }, - "name": "order_shipping", + "name": "order_transaction", "schema": "public", "indexes": [ { - "keyName": "IDX_order_shipping_order_id", - "columnNames": [ - "order_id" - ], + "keyName": "IDX_order_transaction_order_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_shipping_return_id", - "columnNames": [ - "return_id" - ], + "keyName": "IDX_order_transaction_return_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (return_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_shipping_exchange_id", - "columnNames": [ - "exchange_id" - ], + "keyName": "IDX_order_transaction_exchange_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (exchange_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_shipping_claim_id", - "columnNames": [ - "claim_id" - ], + "keyName": "IDX_order_transaction_claim_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (claim_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_shipping_version", - "columnNames": [ - "version" - ], + "keyName": "IDX_order_transaction_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_version\" ON \"order_shipping\" (version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_shipping_shipping_method_id", - "columnNames": [ - "shipping_method_id" - ], + "keyName": "IDX_order_transaction_reference_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_shipping_method_id\" ON \"order_shipping\" (shipping_method_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (reference_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_transaction_order_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_shipping_pkey", + "keyName": "IDX_order_transaction_return_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_exchange_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_claim_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_currency_code", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (currency_code) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_order_id_version", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id_version\" ON \"order_transaction\" (order_id, version) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_transaction_pkey", "columnNames": [ "id" ], @@ -3595,67 +4153,56 @@ ], "checks": [], "foreignKeys": { - "order_shipping_order_id_foreign": { - "constraintName": "order_shipping_order_id_foreign", + "order_transaction_order_id_foreign": { + "constraintName": "order_transaction_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", + "deleteRule": "cascade", "updateRule": "cascade" }, - "order_shipping_return_id_foreign": { - "constraintName": "order_shipping_return_id_foreign", + "order_transaction_return_id_foreign": { + "constraintName": "order_transaction_return_id_foreign", "columnNames": [ "return_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], "referencedTableName": "public.return", - "deleteRule": "set null", + "deleteRule": "cascade", "updateRule": "cascade" }, - "order_shipping_exchange_id_foreign": { - "constraintName": "order_shipping_exchange_id_foreign", + "order_transaction_exchange_id_foreign": { + "constraintName": "order_transaction_exchange_id_foreign", "columnNames": [ "exchange_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order_exchange", - "deleteRule": "set null", + "deleteRule": "cascade", "updateRule": "cascade" }, - "order_shipping_claim_id_foreign": { - "constraintName": "order_shipping_claim_id_foreign", + "order_transaction_claim_id_foreign": { + "constraintName": "order_transaction_claim_id_foreign", "columnNames": [ "claim_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order_claim", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_shipping_shipping_method_id_foreign": { - "constraintName": "order_shipping_shipping_method_id_foreign", - "columnNames": [ - "shipping_method_id" - ], - "localTableName": "public.order_shipping", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_shipping_method", + "deleteRule": "cascade", "updateRule": "cascade" } } @@ -3671,41 +4218,18 @@ "nullable": false, "mappedType": "text" }, - "reason": { - "name": "reason", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "enumItems": [ - "missing_item", - "wrong_item", - "production_failure", - "other" - ], - "mappedType": "enum" - }, - "quantity": { - "name": "quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "raw_quantity": { - "name": "raw_quantity", - "type": "jsonb", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "default": "1", + "mappedType": "integer" }, - "claim_id": { - "name": "claim_id", + "order_id": { + "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3713,27 +4237,26 @@ "nullable": false, "mappedType": "text" }, - "item_id": { - "name": "item_id", + "return_id": { + "name": "return_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "is_additional_item": { - "name": "is_additional_item", - "type": "boolean", + "exchange_id": { + "name": "exchange_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" + "nullable": true, + "mappedType": "text" }, - "note": { - "name": "note", + "claim_id": { + "name": "claim_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3741,14 +4264,14 @@ "nullable": true, "mappedType": "text" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + "shipping_method_id": { + "name": "shipping_method_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "json" + "nullable": false, + "mappedType": "text" }, "created_at": { "name": "created_at", @@ -3783,174 +4306,116 @@ "mappedType": "datetime" } }, - "name": "order_claim_item", + "name": "order_shipping", "schema": "public", "indexes": [ { - "keyName": "IDX_order_claim_item_claim_id", "columnNames": [ - "claim_id" + "shipping_method_id" ], "composite": false, + "keyName": "order_shipping_shipping_method_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_order_shipping_order_id", + "columnNames": [], + "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_claim_id\" ON \"order_claim_item\" (claim_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (order_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_claim_item_item_id", - "columnNames": [ - "item_id" - ], + "keyName": "IDX_order_shipping_return_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_item_id\" ON \"order_claim_item\" (item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (return_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_claim_item_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_shipping_exchange_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (exchange_id) WHERE deleted_at IS NULL" }, { - "keyName": "order_claim_item_pkey", - "columnNames": [ - "id" - ], + "keyName": "IDX_order_shipping_claim_id", + "columnNames": [], "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_claim_item_claim_id_foreign": { - "constraintName": "order_claim_item_claim_id_foreign", - "columnNames": [ - "claim_id" - ], - "localTableName": "public.order_claim_item", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_claim", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "order_claim_item_item_id_foreign": { - "constraintName": "order_claim_item_item_id_foreign", - "columnNames": [ - "item_id" - ], - "localTableName": "public.order_claim_item", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_line_item", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "text" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (claim_id) WHERE deleted_at IS NULL" }, - "claim_item_id": { - "name": "claim_item_id", - "type": "text", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_shipping_deleted_at", + "columnNames": [], + "composite": false, "primary": false, - "nullable": false, - "mappedType": "text" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NULL" }, - "url": { - "name": "url", - "type": "text", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_shipping_order_id", + "columnNames": [], + "composite": false, "primary": false, - "nullable": false, - "mappedType": "text" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (order_id) WHERE deleted_at IS NOT NULL" }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_shipping_return_id", + "columnNames": [], + "composite": false, "primary": false, - "nullable": true, - "mappedType": "json" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_shipping_exchange_id", + "columnNames": [], + "composite": false, "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_shipping_claim_id", + "columnNames": [], + "composite": false, "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_shipping_version", + "columnNames": [], + "composite": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "order_claim_item_image", - "schema": "public", - "indexes": [ + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_version\" ON \"order_shipping\" (version) WHERE deleted_at IS NOT NULL" + }, { - "keyName": "IDX_order_claim_item_image_claim_item_id", - "columnNames": [ - "claim_item_id" - ], + "keyName": "IDX_order_shipping_shipping_method_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_claim_item_id\" ON \"order_claim_item_image\" (claim_item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_shipping_method_id\" ON \"order_shipping\" (shipping_method_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_item_image_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_shipping_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_claim_item_image_pkey", + "keyName": "order_shipping_pkey", "columnNames": [ "id" ], @@ -3961,16 +4426,68 @@ ], "checks": [], "foreignKeys": { - "order_claim_item_image_claim_item_id_foreign": { - "constraintName": "order_claim_item_image_claim_item_id_foreign", + "order_shipping_order_id_foreign": { + "constraintName": "order_shipping_order_id_foreign", "columnNames": [ - "claim_item_id" + "order_id" ], - "localTableName": "public.order_claim_item_image", + "localTableName": "public.order_shipping", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_claim_item", + "referencedTableName": "public.order", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_shipping_return_id_foreign": { + "constraintName": "order_shipping_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_shipping_exchange_id_foreign": { + "constraintName": "order_shipping_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_shipping_claim_id_foreign": { + "constraintName": "order_shipping_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_shipping_shipping_method_id_foreign": { + "constraintName": "order_shipping_shipping_method_id_foreign", + "columnNames": [ + "shipping_method_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_shipping_method", "updateRule": "cascade" } } @@ -3986,153 +4503,42 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "return_id": { - "name": "return_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "claim_id": { - "name": "claim_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "exchange_id": { - "name": "exchange_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "version": { - "name": "version", - "type": "integer", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "change_type": { - "name": "change_type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "description": { - "name": "description", + "reason": { + "name": "reason", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'pending'", "enumItems": [ - "confirmed", - "declined", - "requested", - "pending", - "canceled" + "missing_item", + "wrong_item", + "production_failure", + "other" ], "mappedType": "enum" }, - "internal_note": { - "name": "internal_note", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "created_by": { - "name": "created_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "requested_at": { - "name": "requested_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "confirmed_by": { - "name": "confirmed_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamptz", + "quantity": { + "name": "quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "mappedType": "decimal" }, - "declined_by": { - "name": "declined_by", - "type": "text", + "is_additional_item": { + "name": "is_additional_item", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "false", + "mappedType": "boolean" }, - "declined_reason": { - "name": "declined_reason", + "note": { + "name": "note", "type": "text", "unsigned": false, "autoincrement": false, @@ -4149,34 +4555,32 @@ "nullable": true, "mappedType": "json" }, - "declined_at": { - "name": "declined_at", - "type": "timestamptz", + "claim_id": { + "name": "claim_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "mappedType": "text" }, - "canceled_by": { - "name": "canceled_by", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "mappedType": "json" }, "created_at": { "name": "created_at", @@ -4211,89 +4615,59 @@ "mappedType": "datetime" } }, - "name": "order_change", + "name": "order_claim_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_change_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (order_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_change_return_id", - "columnNames": [ - "return_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_return_id\" ON \"order_change\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_change_claim_id", - "columnNames": [ - "claim_id" - ], + "keyName": "IDX_order_claim_item_claim_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_claim_id\" ON \"order_change\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_claim_id\" ON \"order_claim_item\" (claim_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_change_exchange_id", - "columnNames": [ - "exchange_id" - ], + "keyName": "IDX_order_claim_item_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_exchange_id\" ON \"order_change\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_item_id\" ON \"order_claim_item\" (item_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_change_order_id_version", - "columnNames": [ - "version" - ], + "keyName": "IDX_order_claim_item_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_change_status", - "columnNames": [ - "status" - ], + "keyName": "IDX_order_claim_item_claim_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (status) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_claim_id\" ON \"order_claim_item\" (claim_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_claim_item_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_item_id\" ON \"order_claim_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_order_id_version", + "keyName": "IDX_order_claim_item_deleted_at", "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_change_pkey", + "keyName": "order_claim_item_pkey", "columnNames": [ "id" ], @@ -4304,56 +4678,29 @@ ], "checks": [], "foreignKeys": { - "order_change_order_id_foreign": { - "constraintName": "order_change_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_change", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "order_change_return_id_foreign": { - "constraintName": "order_change_return_id_foreign", - "columnNames": [ - "return_id" - ], - "localTableName": "public.order_change", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.return", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_change_claim_id_foreign": { - "constraintName": "order_change_claim_id_foreign", + "order_claim_item_claim_id_foreign": { + "constraintName": "order_claim_item_claim_id_foreign", "columnNames": [ "claim_id" ], - "localTableName": "public.order_change", + "localTableName": "public.order_claim_item", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order_claim", - "deleteRule": "set null", + "deleteRule": "cascade", "updateRule": "cascade" }, - "order_change_exchange_id_foreign": { - "constraintName": "order_change_exchange_id_foreign", + "order_claim_item_item_id_foreign": { + "constraintName": "order_claim_item_item_id_foreign", "columnNames": [ - "exchange_id" + "item_id" ], - "localTableName": "public.order_change", + "localTableName": "public.order_claim_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_exchange", - "deleteRule": "set null", + "referencedTableName": "public.order_line_item", "updateRule": "cascade" } } @@ -4369,89 +4716,17 @@ "nullable": false, "mappedType": "text" }, - "ordering": { - "name": "ordering", - "type": "integer", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "order_id": { - "name": "order_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "return_id": { - "name": "return_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "claim_id": { - "name": "claim_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "exchange_id": { - "name": "exchange_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "version": { - "name": "version", - "type": "integer", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "integer" - }, - "order_change_id": { - "name": "order_change_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "reference": { - "name": "reference", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "reference_id": { - "name": "reference_id", + "claim_item_id": { + "name": "claim_item_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "action": { - "name": "action", + "url": { + "name": "url", "type": "text", "unsigned": false, "autoincrement": false, @@ -4459,26 +4734,8 @@ "nullable": false, "mappedType": "text" }, - "details": { - "name": "details", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "amount": { - "name": "amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "decimal" - }, - "raw_amount": { - "name": "raw_amount", + "metadata": { + "name": "metadata", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -4486,25 +4743,6 @@ "nullable": true, "mappedType": "json" }, - "internal_note": { - "name": "internal_note", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "applied": { - "name": "applied", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -4538,81 +4776,43 @@ "mappedType": "datetime" } }, - "name": "order_change_action", - "schema": "public", - "indexes": [ - { - "keyName": "IDX_order_change_action_ordering", - "columnNames": [ - "ordering" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (ordering) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_change_action_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (order_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_change_action_return_id", - "columnNames": [ - "return_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_return_id\" ON \"order_change_action\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" - }, + "name": "order_claim_item_image", + "schema": "public", + "indexes": [ { - "keyName": "IDX_order_change_action_claim_id", - "columnNames": [ - "claim_id" - ], + "keyName": "IDX_order_claim_item_image_claim_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_claim_id\" ON \"order_change_action\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_claim_item_id\" ON \"order_claim_item_image\" (claim_item_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_change_action_exchange_id", - "columnNames": [ - "exchange_id" - ], + "keyName": "IDX_order_claim_item_image_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_exchange_id\" ON \"order_change_action\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_order_change_action_order_change_id", - "columnNames": [ - "order_change_id" - ], + "keyName": "IDX_order_claim_item_image_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_change_id\" ON \"order_change_action\" (order_change_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_claim_item_image_claim_item_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_claim_item_id\" ON \"order_claim_item_image\" (claim_item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_change_action_pkey", + "keyName": "order_claim_item_image_pkey", "columnNames": [ "id" ], @@ -4623,68 +4823,16 @@ ], "checks": [], "foreignKeys": { - "order_change_action_order_id_foreign": { - "constraintName": "order_change_action_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_change_action", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "order_change_action_return_id_foreign": { - "constraintName": "order_change_action_return_id_foreign", - "columnNames": [ - "return_id" - ], - "localTableName": "public.order_change_action", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.return", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_change_action_claim_id_foreign": { - "constraintName": "order_change_action_claim_id_foreign", - "columnNames": [ - "claim_id" - ], - "localTableName": "public.order_change_action", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_claim", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_change_action_exchange_id_foreign": { - "constraintName": "order_change_action_exchange_id_foreign", - "columnNames": [ - "exchange_id" - ], - "localTableName": "public.order_change_action", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_exchange", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_change_action_order_change_id_foreign": { - "constraintName": "order_change_action_order_change_id_foreign", + "order_claim_item_image_claim_item_id_foreign": { + "constraintName": "order_claim_item_image_claim_item_id_foreign", "columnNames": [ - "order_change_id" + "claim_item_id" ], - "localTableName": "public.order_change_action", + "localTableName": "public.order_claim_item_image", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_change", + "referencedTableName": "public.order_claim_item", "deleteRule": "cascade", "updateRule": "cascade" } @@ -4728,23 +4876,23 @@ "nullable": true, "mappedType": "text" }, - "parent_return_reason_id": { - "name": "parent_return_reason_id", - "type": "text", + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + "parent_return_reason_id": { + "name": "parent_return_reason_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, "created_at": { "name": "created_at", @@ -4783,35 +4931,45 @@ "schema": "public", "indexes": [ { - "keyName": "IDX_return_reason_value", - "columnNames": [ - "value" - ], + "keyName": "IDX_return_reason_parent_return_reason_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_value\" ON \"return_reason\" (value) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_parent_return_reason_id\" ON \"return_reason\" (parent_return_reason_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_return_reason_parent_return_reason_id", - "columnNames": [ - "parent_return_reason_id" - ], + "keyName": "IDX_return_reason_deleted_at", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_parent_return_reason_id\" ON \"return_reason\" (parent_return_reason_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (deleted_at) WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_reason_deleted_at", - "columnNames": [ - "deleted_at" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (deleted_at) WHERE deleted_at IS NOT NULL" }, + { + "keyName": "IDX_return_reason_value", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_value\" ON \"return_reason\" (value) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_return_reason_parent_return_reason_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_parent_return_reason_id\" ON \"return_reason\" (parent_return_reason_id) WHERE deleted_at IS NOT NULL" + }, { "keyName": "return_reason_pkey", "columnNames": [ @@ -4850,15 +5008,6 @@ "nullable": false, "mappedType": "text" }, - "reason_id": { - "name": "reason_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, "quantity": { "name": "quantity", "type": "numeric", @@ -4868,15 +5017,6 @@ "nullable": false, "mappedType": "decimal" }, - "raw_quantity": { - "name": "raw_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, "received_quantity": { "name": "received_quantity", "type": "numeric", @@ -4887,15 +5027,6 @@ "default": "0", "mappedType": "decimal" }, - "raw_received_quantity": { - "name": "raw_received_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, "damaged_quantity": { "name": "damaged_quantity", "type": "numeric", @@ -4906,15 +5037,33 @@ "default": "0", "mappedType": "decimal" }, - "raw_damaged_quantity": { - "name": "raw_damaged_quantity", + "note": { + "name": "note", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "json" }, + "reason_id": { + "name": "reason_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "return_id": { "name": "return_id", "type": "text", @@ -4933,22 +5082,31 @@ "nullable": false, "mappedType": "text" }, - "note": { - "name": "note", - "type": "text", + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "metadata": { - "name": "metadata", + "raw_received_quantity": { + "name": "raw_received_quantity", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, + "mappedType": "json" + }, + "raw_damaged_quantity": { + "name": "raw_damaged_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, "mappedType": "json" }, "created_at": { @@ -4989,29 +5147,55 @@ "indexes": [ { "keyName": "IDX_return_item_reason_id", - "columnNames": [ - "reason_id" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_reason_id\" ON \"return_item\" (reason_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_reason_id\" ON \"return_item\" (reason_id) WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_item_return_id", - "columnNames": [ - "return_id" - ], + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_return_id\" ON \"return_item\" (return_id) WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_return_item_item_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_item_id\" ON \"return_item\" (item_id) WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_return_item_deleted_at", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_deleted_at\" ON \"return_item\" (deleted_at) WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_return_item_return_id", + "columnNames": [], "composite": false, "primary": false, "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_return_id\" ON \"return_item\" (return_id) WHERE deleted_at IS NOT NULL" }, + { + "keyName": "IDX_return_item_reason_id", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_reason_id\" ON \"return_item\" (reason_id) WHERE deleted_at IS NOT NULL" + }, { "keyName": "IDX_return_item_item_id", - "columnNames": [ - "item_id" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, @@ -5019,9 +5203,7 @@ }, { "keyName": "IDX_return_item_deleted_at", - "columnNames": [ - "deleted_at" - ], + "columnNames": [], "composite": false, "primary": false, "unique": false, diff --git a/packages/modules/order/src/migrations/Migration20241129124827.ts b/packages/modules/order/src/migrations/Migration20241129124827.ts new file mode 100644 index 0000000000000..b9fd13eb94275 --- /dev/null +++ b/packages/modules/order/src/migrations/Migration20241129124827.ts @@ -0,0 +1,18 @@ +import { Migration } from "@mikro-orm/migrations" + +export class Migration20241129124827 extends Migration { + async up(): Promise { + this.addSql( + 'alter table if exists "order_address" add column if not exists "deleted_at" timestamptz null;' + ) + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_address_deleted_at" ON "order_address" (deleted_at) WHERE deleted_at IS NULL;' + ) + } + + async down(): Promise { + this.addSql(` + ALTER TABLE "order_address" DROP COLUMN if exists "deleted_at"; + `) + } +} diff --git a/packages/modules/order/src/models/address.ts b/packages/modules/order/src/models/address.ts index a4cbc3bdf46f0..94b4d7129ef1b 100644 --- a/packages/modules/order/src/models/address.ts +++ b/packages/modules/order/src/models/address.ts @@ -1,100 +1,27 @@ -import { DAL } from "@medusajs/framework/types" -import { - createPsqlIndexStatementHelper, - generateEntityId, - Searchable, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - OnInit, - OptionalProps, - PrimaryKey, - Property, -} from "@mikro-orm/core" - -type OptionalAddressProps = DAL.ModelDateColumns - -const CustomerIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_address", - columns: "customer_id", -}) - -@Entity({ tableName: "order_address" }) -export default class OrderAddress { - [OptionalProps]: OptionalAddressProps - - @PrimaryKey({ columnType: "text" }) - id!: string - - @Property({ columnType: "text", nullable: true }) - @CustomerIdIndex.MikroORMIndex() - customer_id: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - company: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - first_name: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - last_name: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - address_1: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - address_2: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - city: string | null = null - - @Property({ columnType: "text", nullable: true }) - country_code: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - province: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - postal_code: string | null = null - - @Searchable() - @Property({ columnType: "text", nullable: true }) - phone: string | null = null - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", +import { model } from "@medusajs/framework/utils" + +const _OrderAddress = model + .define("OrderAddress", { + id: model.id({ prefix: "ordaddr" }).primaryKey(), + customer_id: model.text().nullable(), + company: model.text().searchable().nullable(), + first_name: model.text().searchable().nullable(), + last_name: model.text().searchable().nullable(), + address_1: model.text().searchable().nullable(), + address_2: model.text().searchable().nullable(), + city: model.text().searchable().nullable(), + country_code: model.text().nullable(), + province: model.text().searchable().nullable(), + postal_code: model.text().searchable().nullable(), + phone: model.text().searchable().nullable(), + metadata: model.json().nullable(), }) - updated_at: Date - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordaddr") - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordaddr") - } -} + .indexes([ + { + name: "IDX_order_address_customer_id", + on: ["customer_id"], + unique: false, + }, + ]) + +export const OrderAddress = _OrderAddress diff --git a/packages/modules/order/src/models/adjustment-line.ts b/packages/modules/order/src/models/adjustment-line.ts deleted file mode 100644 index 567051ec5d80d..0000000000000 --- a/packages/modules/order/src/models/adjustment-line.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { BigNumber, MikroOrmBigNumberProperty } from "@medusajs/framework/utils" -import { OptionalProps, PrimaryKey, Property } from "@mikro-orm/core" - -type OptionalAdjustmentLineProps = DAL.ModelDateColumns - -/** - * As per the Mikro ORM docs, superclasses should use the abstract class definition - * Source: https://mikro-orm.io/docs/inheritance-mapping - */ -export default abstract class AdjustmentLine { - [OptionalProps]: OptionalAdjustmentLineProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @Property({ columnType: "text", nullable: true }) - description: string | null = null - - @Property({ - columnType: "text", - nullable: true, - }) - promotion_id: string | null = null - - @Property({ columnType: "text", nullable: true }) - code: string | null = null - - @MikroOrmBigNumberProperty() - amount: BigNumber | number - - @Property({ columnType: "jsonb" }) - raw_amount: BigNumberRawValue - - @Property({ columnType: "text", nullable: true }) - provider_id: string | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - deleted_at: Date | null = null -} diff --git a/packages/modules/order/src/models/claim-item-image.ts b/packages/modules/order/src/models/claim-item-image.ts index 3c6d1f3264cb2..152eca0128491 100644 --- a/packages/modules/order/src/models/claim-item-image.ts +++ b/packages/modules/order/src/models/claim-item-image.ts @@ -1,92 +1,31 @@ -import { DAL } from "@medusajs/framework/types" -import { - DALUtils, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - Filter, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import ClaimItem from "./claim-item" - -type OptionalClaimItemImageProps = DAL.ModelDateColumns - -const ClaimItemImageDeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim_item_image", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const ClaimItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim_item_image", - columns: ["claim_item_id"], - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_claim_item_image" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class OrderClaimItemImage { - [OptionalProps]?: OptionalClaimItemImageProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => ClaimItem, - mapToPk: true, - fieldName: "claim_item_id", - columnType: "text", - }) - @ClaimItemIdIndex.MikroORMIndex() - claim_item_id: string - - @ManyToOne(() => ClaimItem, { - persist: false, +import { model } from "@medusajs/framework/utils" +import { OrderClaimItem } from "./claim-item" + +const _OrderClaimItemImage = model + .define("OrderClaimItemImage", { + id: model.id({ prefix: "climg" }).primaryKey(), + claim_item: model.belongsTo<() => typeof OrderClaimItem>( + () => OrderClaimItem, + { + mappedBy: "images", + } + ), + url: model.text(), + metadata: model.json().nullable(), }) - item: Rel - - @Property({ columnType: "text" }) - url: string - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @ClaimItemImageDeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "climg") - this.claim_item_id ??= this.item?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "climg") - this.claim_item_id ??= this.item?.id - } -} + .indexes([ + { + name: "IDX_order_claim_item_image_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_claim_item_image_claim_item_id", + on: ["claim_item_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderClaimItemImage = _OrderClaimItemImage diff --git a/packages/modules/order/src/models/claim-item.ts b/packages/modules/order/src/models/claim-item.ts index fe90bc20f118e..8539d23567b17 100644 --- a/packages/modules/order/src/models/claim-item.ts +++ b/packages/modules/order/src/models/claim-item.ts @@ -1,135 +1,51 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - ClaimReason, - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Enum, - ManyToOne, - OnInit, - OneToMany, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import Claim from "./claim" -import OrderClaimItemImage from "./claim-item-image" -import OrderLineItem from "./line-item" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const tableName = "order_claim_item" -const ClaimIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "claim_id", - where: "deleted_at IS NOT NULL", -}) - -const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "item_id", - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName }) -export default class OrderClaimItem { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @OneToMany(() => OrderClaimItemImage, (ci) => ci.item, { - cascade: [Cascade.PERSIST, Cascade.REMOVE], +import { ClaimReason, model } from "@medusajs/framework/utils" +import { OrderClaim } from "./claim" +import { OrderClaimItemImage } from "./claim-item-image" +import { OrderLineItem } from "./line-item" + +const _OrderClaimItem = model + .define("OrderClaimItem", { + id: model.id({ prefix: "claitem" }).primaryKey(), + reason: model.enum(ClaimReason).nullable(), + quantity: model.bigNumber(), + is_additional_item: model.boolean().default(false), + note: model.text().nullable(), + metadata: model.json().nullable(), + claim: model.belongsTo<() => typeof OrderClaim>(() => OrderClaim, { + mappedBy: "additional_items", + }), + item: model.belongsTo<() => typeof OrderLineItem>(() => OrderLineItem, { + mappedBy: "claim_items", + }), + images: model.hasMany<() => typeof OrderClaimItemImage>( + () => OrderClaimItemImage, + { + mappedBy: "claim_item", + } + ), }) - images = new Collection>(this) - - @Enum({ items: () => ClaimReason, nullable: true }) - reason: Rel | null = null - - @MikroOrmBigNumberProperty() - quantity: Number | number - - @Property({ columnType: "jsonb" }) - raw_quantity: BigNumberRawValue - - @ManyToOne(() => Claim, { - columnType: "text", - fieldName: "claim_id", - mapToPk: true, - onDelete: "cascade", + .cascades({ + delete: ["images"], }) - @ClaimIdIndex.MikroORMIndex() - claim_id: string - - @ManyToOne(() => Claim, { - persist: false, - }) - claim: Rel - - @ManyToOne({ - entity: () => OrderLineItem, - fieldName: "item_id", - mapToPk: true, - columnType: "text", - }) - @ItemIdIndex.MikroORMIndex() - item_id: string - - @ManyToOne(() => OrderLineItem, { - persist: false, - }) - item: Rel - - @Property({ columnType: "boolean", default: false }) - is_additional_item: boolean = false - - @Property({ columnType: "text", nullable: true }) - note: string - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "claitem") - this.claim_id ??= this.claim?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "claitem") - this.claim_id ??= this.claim?.id - } -} + .indexes([ + { + name: "IDX_order_claim_item_claim_id", + on: ["claim_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_claim_item_item_id", + on: ["item_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_claim_item_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderClaimItem = _OrderClaimItem diff --git a/packages/modules/order/src/models/claim.ts b/packages/modules/order/src/models/claim.ts index 983993098156b..8d0552ca0806f 100644 --- a/packages/modules/order/src/models/claim.ts +++ b/packages/modules/order/src/models/claim.ts @@ -1,173 +1,84 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - BigNumber, - ClaimType, - DALUtils, - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Enum, - Filter, - ManyToOne, - OnInit, - OneToMany, - OneToOne, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import ClaimItem from "./claim-item" -import Order from "./order" -import OrderShipping from "./order-shipping-method" -import Return from "./return" -import OrderTransaction from "./transaction" - -type OptionalOrderClaimProps = DAL.ModelDateColumns - -const DisplayIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim", - columns: "display_id", - where: "deleted_at IS NOT NULL", -}) - -const OrderClaimDeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim", - columns: ["order_id"], - where: "deleted_at IS NOT NULL", -}) - -const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim", - columns: "return_id", - where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_claim" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class OrderClaim { - [OptionalProps]?: OptionalOrderClaimProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - mapToPk: true, - fieldName: "order_id", - columnType: "text", - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @OneToOne({ - entity: () => Return, - mappedBy: (ret) => ret.claim, - fieldName: "return_id", - nullable: true, - owner: true, - }) - return: Rel - - @Property({ columnType: "text", nullable: true }) - @ReturnIdIndex.MikroORMIndex() - return_id: string | null = null - - @Property({ - columnType: "integer", - }) - order_version: number - - @Property({ autoincrement: true, primary: false }) - @DisplayIdIndex.MikroORMIndex() - display_id: number - - @Enum({ items: () => ClaimType }) - type: Rel - - @Property({ columnType: "boolean", nullable: true }) - no_notification: boolean | null = null - - @MikroOrmBigNumberProperty({ - nullable: true, - }) - refund_amount: BigNumber | number - - @Property({ columnType: "jsonb", nullable: true }) - raw_refund_amount: BigNumberRawValue - - @OneToMany(() => ClaimItem, (item) => item.claim, { - cascade: [Cascade.PERSIST], - }) - additional_items = new Collection>(this) - - @OneToMany(() => ClaimItem, (item) => item.claim, { - cascade: [Cascade.PERSIST], +import { ClaimType, model } from "@medusajs/framework/utils" +import { OrderClaimItem } from "./claim-item" +import { Order } from "./order" +import { OrderShipping } from "./order-shipping-method" +import { Return } from "./return" +import { OrderTransaction } from "./transaction" + +const _OrderClaim = model + .define("OrderClaim", { + id: model.id({ prefix: "claim" }).primaryKey(), + order_version: model.number(), + display_id: model.autoincrement(), + type: model.enum(ClaimType), + no_notification: model.boolean().nullable(), + refund_amount: model.bigNumber().nullable(), + created_by: model.text().nullable(), + canceled_at: model.dateTime().nullable(), + metadata: model.json().nullable(), + order: model.hasOne<() => typeof Order>(() => Order, { + mappedBy: undefined, + foreignKey: true, + }), + return: model + .hasOne<() => typeof Return>(() => Return, { + mappedBy: undefined, + foreignKey: true, + }) + .nullable(), + additional_items: model.hasMany<() => typeof OrderClaimItem>( + () => OrderClaimItem, + { + mappedBy: "claim", + } + ), + claim_items: model.hasMany<() => typeof OrderClaimItem>( + () => OrderClaimItem, + { + mappedBy: "claim", + } + ), + shipping_methods: model.hasMany<() => typeof OrderShipping>( + () => OrderShipping, + { + mappedBy: "claim", + } + ), + transactions: model.hasMany<() => typeof OrderTransaction>( + () => OrderTransaction, + { + mappedBy: "claim", + } + ), }) - claim_items = new Collection>(this) - - @OneToMany(() => OrderShipping, (shippingMethod) => shippingMethod.claim, { - cascade: [Cascade.PERSIST], + .cascades({ + delete: ["additional_items", "claim_items", "transactions"], }) - shipping_methods = new Collection>(this) - - @OneToMany(() => OrderTransaction, (transaction) => transaction.claim, { - cascade: [Cascade.PERSIST], - }) - transactions = new Collection(this) - - @Property({ columnType: "text", nullable: true }) - created_by: string | null = null - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @OrderClaimDeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @Property({ columnType: "timestamptz", nullable: true }) - canceled_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "claim") - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "claim") - } -} + .indexes([ + { + name: "IDX_order_claim_display_id", + on: ["display_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_claim_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_claim_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_claim_return_id", + on: ["return_id"], + unique: false, + where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + ]) + +export const OrderClaim = _OrderClaim diff --git a/packages/modules/order/src/models/credit-line.ts b/packages/modules/order/src/models/credit-line.ts index e4e8952d9f35e..0a0c8f02d2b81 100644 --- a/packages/modules/order/src/models/credit-line.ts +++ b/packages/modules/order/src/models/credit-line.ts @@ -1,107 +1,31 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - BigNumber, - createPsqlIndexStatementHelper, - generateEntityId, - MikroOrmBigNumberProperty, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import Order from "./order" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const tableName = "order_credit_line" -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["order_id"], - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName }) -export default class OrderCreditLine { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - mapToPk: true, - fieldName: "order_id", - columnType: "text", - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @Property({ - columnType: "text", - nullable: true, - }) - reference: string | null = null - - @Property({ - columnType: "text", - nullable: true, - }) - reference_id: string | null = null - - @MikroOrmBigNumberProperty() - amount: BigNumber | number - - @Property({ columnType: "jsonb" }) - raw_amount: BigNumberRawValue - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", +import { model } from "@medusajs/framework/utils" +import { Order } from "./order" + +const OrderCreditLine_ = model + .define("OrderCreditLine", { + id: model.id({ prefix: "ordcl" }).primaryKey(), + order: model.belongsTo(() => Order, { + mappedBy: "credit_lines", + }), + reference: model.text().nullable(), + reference_id: model.text().nullable(), + amount: model.bigNumber(), + raw_amount: model.json(), + metadata: model.json().nullable(), }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordcl") - this.order_id ??= this.order?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordcl") - this.order_id ??= this.order?.id - } -} + .indexes([ + { + name: "IDX_order_credit_line_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_credit_line_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderCreditLine = OrderCreditLine_ diff --git a/packages/modules/order/src/models/exchange-item.ts b/packages/modules/order/src/models/exchange-item.ts index 9564d39b8440a..998aabad7a071 100644 --- a/packages/modules/order/src/models/exchange-item.ts +++ b/packages/modules/order/src/models/exchange-item.ts @@ -1,116 +1,39 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, -} from "@mikro-orm/core" -import Exchange from "./exchange" -import OrderLineItem from "./line-item" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const ExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_exchange_item", - columns: "exchange_id", - where: "deleted_at IS NOT NULL", -}) - -const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_exchange_item", - columns: "item_id", - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim_item_image", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_exchange_item" }) -export default class OrderExchangeItem { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @MikroOrmBigNumberProperty() - quantity: Number | number - - @Property({ columnType: "jsonb" }) - raw_quantity: BigNumberRawValue - - @ManyToOne(() => Exchange, { - columnType: "text", - fieldName: "exchange_id", - mapToPk: true, - onDelete: "cascade", - }) - @ExchangeIdIndex.MikroORMIndex() - exchange_id: string - - @ManyToOne(() => Exchange, { - persist: false, - }) - exchange: Exchange - - @ManyToOne({ - entity: () => OrderLineItem, - fieldName: "item_id", - mapToPk: true, - columnType: "text", - }) - @ItemIdIndex.MikroORMIndex() - item_id: string - - @ManyToOne(() => OrderLineItem, { - persist: false, - }) - item: OrderLineItem - - @Property({ columnType: "text", nullable: true }) - note: string - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", +import { model } from "@medusajs/framework/utils" +import { OrderExchange } from "./exchange" +import { OrderLineItem } from "./line-item" + +const _OrderExchangeItem = model + .define("OrderExchangeItem", { + id: model.id({ prefix: "oexcitem" }).primaryKey(), + quantity: model.bigNumber(), + note: model.text().nullable(), + metadata: model.json().nullable(), + exchange: model.belongsTo<() => typeof OrderExchange>(() => OrderExchange, { + mappedBy: "additional_items", + }), + item: model.belongsTo<() => typeof OrderLineItem>(() => OrderLineItem, { + mappedBy: "exchange_items", + }), }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "oexcitem") - this.exchange_id ??= this.exchange?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "oexcitem") - this.exchange_id ??= this.exchange?.id - } -} + .indexes([ + { + name: "IDX_order_exchange_item_exchange_id", + on: ["exchange_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_exchange_item_item_id", + on: ["item_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_exchange_item_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderExchangeItem = _OrderExchangeItem diff --git a/packages/modules/order/src/models/exchange.ts b/packages/modules/order/src/models/exchange.ts index 34fb61abd6947..deadbd439baea 100644 --- a/packages/modules/order/src/models/exchange.ts +++ b/packages/modules/order/src/models/exchange.ts @@ -1,165 +1,78 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - BigNumber, - DALUtils, - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Filter, - ManyToOne, - OnInit, - OneToMany, - OneToOne, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import { OrderExchangeItem, OrderTransaction } from "@models" -import Order from "./order" -import OrderShipping from "./order-shipping-method" -import Return from "./return" - -type OptionalOrderExchangeProps = DAL.ModelDateColumns - -const DisplayIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_exchange", - columns: "display_id", - where: "deleted_at IS NOT NULL", -}) - -const OrderExchangeDeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_exchange", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_exchange", - columns: ["order_id"], - where: "deleted_at IS NOT NULL", -}) - -const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_exchange", - columns: "return_id", - where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_exchange" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class OrderExchange { - [OptionalProps]?: OptionalOrderExchangeProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - mapToPk: true, - fieldName: "order_id", - columnType: "text", - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @OneToOne({ - entity: () => Return, - mappedBy: (ret) => ret.exchange, - fieldName: "return_id", - nullable: true, - owner: true, - }) - return: Rel - - @Property({ columnType: "text", nullable: true }) - @ReturnIdIndex.MikroORMIndex() - return_id: string | null = null - - @Property({ - columnType: "integer", - }) - order_version: number - - @Property({ autoincrement: true, primary: false }) - @DisplayIdIndex.MikroORMIndex() - display_id: number - - @Property({ columnType: "boolean", nullable: true }) - no_notification: boolean | null = null - - @MikroOrmBigNumberProperty({ - nullable: true, - }) - difference_due: BigNumber | number - - @Property({ columnType: "jsonb", nullable: true }) - raw_difference_due: BigNumberRawValue - - @Property({ columnType: "boolean", default: false }) - allow_backorder: boolean = false - - @OneToMany(() => OrderExchangeItem, (item) => item.exchange, { - cascade: [Cascade.PERSIST], - }) - additional_items = new Collection>(this) - - @OneToMany(() => OrderShipping, (shippingMethod) => shippingMethod.exchange, { - cascade: [Cascade.PERSIST], - }) - shipping_methods = new Collection>(this) - - @OneToMany(() => OrderTransaction, (transaction) => transaction.exchange, { - cascade: [Cascade.PERSIST], +import { model } from "@medusajs/framework/utils" +import { OrderExchangeItem } from "./exchange-item" +import { Order } from "./order" +import { OrderShipping } from "./order-shipping-method" +import { Return } from "./return" +import { OrderTransaction } from "./transaction" + +const _OrderExchange = model + .define("OrderExchange", { + id: model.id({ prefix: "oexc" }).primaryKey(), + order_version: model.number(), + display_id: model.autoincrement(), + no_notification: model.boolean().nullable(), + difference_due: model.bigNumber().nullable(), + allow_backorder: model.boolean().default(false), + created_by: model.text().nullable(), + metadata: model.json().nullable(), + canceled_at: model.dateTime().nullable(), + order: model.hasOne<() => typeof Order>(() => Order, { + mappedBy: undefined, + foreignKey: true, + }), + return: model + .hasOne<() => typeof Return>(() => Return, { + mappedBy: undefined, + foreignKey: true, + }) + .nullable(), + additional_items: model.hasMany<() => typeof OrderExchangeItem>( + () => OrderExchangeItem, + { + mappedBy: "exchange", + } + ), + shipping_methods: model.hasMany<() => typeof OrderShipping>( + () => OrderShipping, + { + mappedBy: "exchange", + } + ), + transactions: model.hasMany<() => typeof OrderTransaction>( + () => OrderTransaction, + { + mappedBy: "exchange", + } + ), }) - transactions = new Collection(this) - - @Property({ columnType: "text", nullable: true }) - created_by: string | null = null - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", + .cascades({ + delete: ["additional_items", "transactions"], }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @OrderExchangeDeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @Property({ columnType: "timestamptz", nullable: true }) - canceled_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "oexc") - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "oexc") - } -} + .indexes([ + { + name: "IDX_order_exchange_display_id", + on: ["display_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_exchange_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_exchange_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_exchange_return_id", + on: ["return_id"], + unique: false, + where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + ]) + +export const OrderExchange = _OrderExchange diff --git a/packages/modules/order/src/models/index.ts b/packages/modules/order/src/models/index.ts index 7a5b02030a92b..630f7afa3a5a1 100644 --- a/packages/modules/order/src/models/index.ts +++ b/packages/modules/order/src/models/index.ts @@ -1,23 +1,23 @@ -export { default as OrderAddress } from "./address" -export { default as OrderClaim } from "./claim" -export { default as OrderClaimItem } from "./claim-item" -export { default as OrderClaimItemImage } from "./claim-item-image" -export { default as OrderCreditLine } from "./credit-line" -export { default as OrderExchange } from "./exchange" -export { default as OrderExchangeItem } from "./exchange-item" -export { default as OrderLineItem } from "./line-item" -export { default as OrderLineItemAdjustment } from "./line-item-adjustment" -export { default as OrderLineItemTaxLine } from "./line-item-tax-line" -export { default as Order } from "./order" -export { default as OrderChange } from "./order-change" -export { default as OrderChangeAction } from "./order-change-action" -export { default as OrderItem } from "./order-item" -export { default as OrderShipping } from "./order-shipping-method" -export { default as OrderSummary } from "./order-summary" -export { default as Return } from "./return" -export { default as ReturnItem } from "./return-item" -export { default as ReturnReason } from "./return-reason" -export { default as OrderShippingMethod } from "./shipping-method" -export { default as OrderShippingMethodAdjustment } from "./shipping-method-adjustment" -export { default as OrderShippingMethodTaxLine } from "./shipping-method-tax-line" -export { default as OrderTransaction } from "./transaction" +export { OrderAddress } from "./address" +export { OrderClaim } from "./claim" +export { OrderClaimItem } from "./claim-item" +export { OrderClaimItemImage } from "./claim-item-image" +export { OrderCreditLine } from "./credit-line" +export { OrderExchange } from "./exchange" +export { OrderExchangeItem } from "./exchange-item" +export { OrderLineItem } from "./line-item" +export { OrderLineItemAdjustment } from "./line-item-adjustment" +export { OrderLineItemTaxLine } from "./line-item-tax-line" +export { Order } from "./order" +export { OrderChange } from "./order-change" +export { OrderChangeAction } from "./order-change-action" +export { OrderItem } from "./order-item" +export { OrderShipping } from "./order-shipping-method" +export { OrderSummary } from "./order-summary" +export { Return } from "./return" +export { ReturnItem } from "./return-item" +export { ReturnReason } from "./return-reason" +export { OrderShippingMethod } from "./shipping-method" +export { OrderShippingMethodAdjustment } from "./shipping-method-adjustment" +export { OrderShippingMethodTaxLine } from "./shipping-method-tax-line" +export { OrderTransaction } from "./transaction" diff --git a/packages/modules/order/src/models/line-item-adjustment.ts b/packages/modules/order/src/models/line-item-adjustment.ts index 3fe70618a574b..8808b9c193f22 100644 --- a/packages/modules/order/src/models/line-item-adjustment.ts +++ b/packages/modules/order/src/models/line-item-adjustment.ts @@ -1,42 +1,24 @@ -import { - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { BeforeCreate, Entity, ManyToOne, OnInit, Rel } from "@mikro-orm/core" -import AdjustmentLine from "./adjustment-line" -import OrderLineItem from "./line-item" +import { model } from "@medusajs/framework/utils" +import { OrderLineItem } from "./line-item" -const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_line_item_adjustment", - columns: "item_id", -}) - -@Entity({ tableName: "order_line_item_adjustment" }) -export default class OrderLineItemAdjustment extends AdjustmentLine { - @ManyToOne(() => OrderLineItem, { - persist: false, - }) - item: Rel - - @ManyToOne({ - entity: () => OrderLineItem, - columnType: "text", - fieldName: "item_id", - onDelete: "cascade", - mapToPk: true, +const _OrderLineItemAdjustment = model + .define("OrderLineItemAdjustment", { + id: model.id({ prefix: "ordliadj" }).primaryKey(), + description: model.text().nullable(), + promotion_id: model.text().nullable(), + code: model.text().nullable(), + amount: model.bigNumber(), + provider_id: model.text().nullable(), + item: model.belongsTo<() => typeof OrderLineItem>(() => OrderLineItem, { + mappedBy: "adjustments", + }), }) - @ItemIdIndex.MikroORMIndex() - item_id: string - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordliadj") - this.item_id ??= this.item?.id - } + .indexes([ + { + name: "IDX_order_order_line_item_adjustment_item_id", + on: ["item_id"], + unique: false, + }, + ]) - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordliadj") - this.item_id ??= this.item?.id - } -} +export const OrderLineItemAdjustment = _OrderLineItemAdjustment diff --git a/packages/modules/order/src/models/line-item-tax-line.ts b/packages/modules/order/src/models/line-item-tax-line.ts index 4770cb4532d82..89436072aa662 100644 --- a/packages/modules/order/src/models/line-item-tax-line.ts +++ b/packages/modules/order/src/models/line-item-tax-line.ts @@ -1,50 +1,24 @@ -import { - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Entity, - ManyToOne, - OnInit, - Rel, -} from "@mikro-orm/core" -import OrderLineItem from "./line-item" -import TaxLine from "./tax-line" +import { model } from "@medusajs/framework/utils" +import { OrderLineItem } from "./line-item" -const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_line_item_tax_line", - columns: "item_id", -}) - -@Entity({ tableName: "order_line_item_tax_line" }) -export default class OrderLineItemTaxLine extends TaxLine { - @ManyToOne(() => OrderLineItem, { - fieldName: "item_id", - persist: false, - }) - item: Rel - - @ManyToOne({ - entity: () => OrderLineItem, - columnType: "text", - fieldName: "item_id", - cascade: [Cascade.PERSIST, Cascade.REMOVE], - mapToPk: true, +const _OrderLineItemTaxLine = model + .define("OrderLineItemTaxLine", { + id: model.id({ prefix: "ordlitxl" }).primaryKey(), + description: model.text().nullable(), + tax_rate_id: model.text().nullable(), + code: model.text(), + rate: model.bigNumber(), + provider_id: model.text().nullable(), + item: model.belongsTo<() => typeof OrderLineItem>(() => OrderLineItem, { + mappedBy: "tax_lines", + }), }) - @ItemIdIndex.MikroORMIndex() - item_id: string - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordlitxl") - this.item_id ??= this.item?.id - } + .indexes([ + { + name: "IDX_order_line_item_tax_line_item_id", + on: ["item_id"], + unique: false, + }, + ]) - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordlitxl") - this.item_id ??= this.item?.id - } -} +export const OrderLineItemTaxLine = _OrderLineItemTaxLine diff --git a/packages/modules/order/src/models/line-item.ts b/packages/modules/order/src/models/line-item.ts index 401d00f5ffbb8..b1ac33bd25bf6 100644 --- a/packages/modules/order/src/models/line-item.ts +++ b/packages/modules/order/src/models/line-item.ts @@ -1,186 +1,74 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - BigNumber, - DALUtils, - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Filter, - OnInit, - OneToMany, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import OrderLineItemAdjustment from "./line-item-adjustment" -import OrderLineItemTaxLine from "./line-item-tax-line" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_line_item", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const ProductIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_line_item", - columns: "product_id", - where: "deleted_at IS NOT NULL", -}) - -const ProductTypeIdIndex = createPsqlIndexStatementHelper({ - name: "IDX_line_item_product_type_id", - tableName: "order_line_item", - columns: "product_type_id", - where: "deleted_at IS NOT NULL AND product_type_id IS NOT NULL", -}).MikroORMIndex - -const VariantIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_line_item", - columns: "variant_id", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_line_item" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class OrderLineItem { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @Property({ columnType: "text" }) - title: string - - @Property({ columnType: "text", nullable: true }) - subtitle: string | null = null - - @Property({ columnType: "text", nullable: true }) - thumbnail: string | null = null - - @Property({ - columnType: "text", - nullable: true, +import { model } from "@medusajs/framework/utils" +import { OrderLineItemAdjustment } from "./line-item-adjustment" +import { OrderLineItemTaxLine } from "./line-item-tax-line" + +const _OrderLineItem = model + .define("OrderLineItem", { + id: model.id({ prefix: "ordli" }).primaryKey(), + title: model.text(), + subtitle: model.text().nullable(), + thumbnail: model.text().nullable(), + variant_id: model.text().nullable(), + product_id: model.text().nullable(), + product_title: model.text().nullable(), + product_description: model.text().nullable(), + product_subtitle: model.text().nullable(), + product_type: model.text().nullable(), + product_type_id: model.text().nullable(), + product_collection: model.text().nullable(), + product_handle: model.text().nullable(), + variant_sku: model.text().nullable(), + variant_barcode: model.text().nullable(), + variant_title: model.text().nullable(), + variant_option_values: model.json().nullable(), + requires_shipping: model.boolean().default(true), + is_discountable: model.boolean().default(true), + is_tax_inclusive: model.boolean().default(false), + compare_at_unit_price: model.bigNumber().nullable(), + unit_price: model.bigNumber().nullable(), + is_custom_price: model.boolean().default(false), + metadata: model.json().nullable(), + tax_lines: model.hasMany<() => typeof OrderLineItemTaxLine>( + () => OrderLineItemTaxLine, + { + mappedBy: "item", + } + ), + adjustments: model.hasMany<() => typeof OrderLineItemAdjustment>( + () => OrderLineItemAdjustment, + { + mappedBy: "item", + } + ), }) - @VariantIdIndex.MikroORMIndex() - variant_id: string | null = null - - @Property({ - columnType: "text", - nullable: true, + .cascades({ + delete: ["tax_lines", "adjustments"], }) - @ProductIdIndex.MikroORMIndex() - product_id: string | null = null - - @Property({ columnType: "text", nullable: true }) - product_title: string | null = null - - @Property({ columnType: "text", nullable: true }) - product_description: string | null = null - - @Property({ columnType: "text", nullable: true }) - product_subtitle: string | null = null - - @Property({ columnType: "text", nullable: true }) - product_type: string | null = null - - @ProductTypeIdIndex() - @Property({ columnType: "text", nullable: true }) - product_type_id: string | null = null - - @Property({ columnType: "text", nullable: true }) - product_collection: string | null = null - - @Property({ columnType: "text", nullable: true }) - product_handle: string | null = null - - @Property({ columnType: "text", nullable: true }) - variant_sku: string | null = null - - @Property({ columnType: "text", nullable: true }) - variant_barcode: string | null = null - - @Property({ columnType: "text", nullable: true }) - variant_title: string | null = null - - @Property({ columnType: "jsonb", nullable: true }) - variant_option_values: Record | null = null - - @Property({ columnType: "boolean" }) - requires_shipping: boolean = true - - @Property({ columnType: "boolean" }) - is_discountable: boolean = true - - @Property({ columnType: "boolean" }) - is_tax_inclusive: boolean = false - - @MikroOrmBigNumberProperty({ - nullable: true, - }) - compare_at_unit_price?: BigNumber | number | null = null - - @Property({ columnType: "jsonb", nullable: true }) - raw_compare_at_unit_price: BigNumberRawValue | null = null - - @MikroOrmBigNumberProperty({ - nullable: true, - }) - unit_price: BigNumber | number - - @Property({ columnType: "jsonb" }) - raw_unit_price: BigNumberRawValue - - @Property({ columnType: "boolean", default: false }) - is_custom_price: boolean = false - - @OneToMany(() => OrderLineItemTaxLine, (taxLine) => taxLine.item, { - cascade: [Cascade.PERSIST, "soft-remove" as Cascade], - }) - tax_lines = new Collection>(this) - - @OneToMany(() => OrderLineItemAdjustment, (adjustment) => adjustment.item, { - cascade: [Cascade.PERSIST, "soft-remove" as Cascade], - }) - adjustments = new Collection>(this) - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordli") - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordli") - } -} + .indexes([ + { + name: "IDX_order_line_item_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_line_item_product_id", + on: ["product_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_line_item_product_type_id", + on: ["product_type_id"], + unique: false, + where: "deleted_at IS NOT NULL AND product_type_id IS NOT NULL", + }, + { + name: "IDX_order_line_item_variant_id", + on: ["variant_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderLineItem = _OrderLineItem diff --git a/packages/modules/order/src/models/order-change-action.ts b/packages/modules/order/src/models/order-change-action.ts index 70fb16a5e3125..95ad863441b55 100644 --- a/packages/modules/order/src/models/order-change-action.ts +++ b/packages/modules/order/src/models/order-change-action.ts @@ -1,251 +1,72 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - BigNumber, - DALUtils, - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - Filter, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import OrderClaim from "./claim" -import OrderExchange from "./exchange" -import Order from "./order" -import OrderChange from "./order-change" -import Return from "./return" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const OrderChangeIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change_action", - columns: "order_change_id", - where: "deleted_at IS NOT NULL", -}) - -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change_action", - columns: "order_id", - where: "deleted_at IS NOT NULL", -}) - -const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change_action", - columns: "return_id", - where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const OrderClaimIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change_action", - columns: "claim_id", - where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const OrderExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change_action", - columns: "exchange_id", - where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_change_action", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const ActionOrderingIndex = createPsqlIndexStatementHelper({ - tableName: "order_change_action", - columns: "ordering", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_change_action" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class OrderChangeAction { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @Property({ columnType: "integer", autoincrement: true }) - @ActionOrderingIndex.MikroORMIndex() - ordering: number - - @ManyToOne({ - entity: () => Order, - columnType: "text", - fieldName: "order_id", - onDelete: "cascade", - mapToPk: true, - nullable: true, - }) - @OrderIdIndex.MikroORMIndex() - order_id: string | null = null - - @ManyToOne(() => Order, { - persist: false, - nullable: true, - }) - order: Rel | null = null - - @ManyToOne({ - entity: () => Return, - mapToPk: true, - fieldName: "return_id", - columnType: "text", - nullable: true, - }) - @ReturnIdIndex.MikroORMIndex() - return_id: string | null = null - - @ManyToOne(() => Return, { - persist: false, - nullable: true, - }) - return: Return - - @ManyToOne({ - entity: () => OrderClaim, - mapToPk: true, - fieldName: "claim_id", - columnType: "text", - nullable: true, - }) - @OrderClaimIdIndex.MikroORMIndex() - claim_id: string | null = null - - @ManyToOne(() => OrderClaim, { - persist: false, - nullable: true, - }) - claim: OrderClaim - - @ManyToOne({ - entity: () => OrderExchange, - mapToPk: true, - fieldName: "exchange_id", - columnType: "text", - nullable: true, - }) - @OrderExchangeIdIndex.MikroORMIndex() - exchange_id: string | null = null - - @ManyToOne(() => OrderExchange, { - persist: false, - nullable: true, - }) - exchange: OrderExchange - - @Property({ columnType: "integer", nullable: true }) - version: number | null = null - - @ManyToOne({ - entity: () => OrderChange, - columnType: "text", - fieldName: "order_change_id", - onDelete: "cascade", - mapToPk: true, - nullable: true, - }) - @OrderChangeIdIndex.MikroORMIndex() - order_change_id: string | null - - @ManyToOne(() => OrderChange, { - persist: false, - nullable: true, - }) - order_change: Rel | null = null - - @Property({ - columnType: "text", - nullable: true, - }) - reference: string | null = null - - @Property({ - columnType: "text", - nullable: true, - }) - reference_id: string | null = null - - @Property({ columnType: "text" }) - action: string - - @Property({ columnType: "jsonb" }) - details: Record = {} - - @MikroOrmBigNumberProperty({ nullable: true }) - amount: BigNumber | number | null = null - - @Property({ columnType: "jsonb", nullable: true }) - raw_amount: BigNumberRawValue | null = null - - @Property({ - columnType: "text", - nullable: true, - }) - internal_note: string | null = null - - @Property({ - columnType: "boolean", - defaultRaw: "false", - }) - applied: boolean = false - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordchact") - this.order_id ??= this.order?.id ?? this.order_change?.order_id ?? null - this.claim_id ??= this.claim?.id ?? this.order_change?.claim_id ?? null - this.exchange_id ??= - this.exchange?.id ?? this.order_change?.exchange_id ?? null - this.order_change_id ??= this.order_change?.id ?? null - this.version ??= this.order_change?.version ?? null - - if (!this.claim_id && !this.exchange_id) { - this.return_id ??= this.return?.id ?? this.order_change?.return_id ?? null - } - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordchact") - this.order_id ??= this.order?.id ?? this.order_change?.order_id ?? null - this.claim_id ??= this.claim?.id ?? this.order_change?.claim_id ?? null - this.exchange_id ??= - this.exchange?.id ?? this.order_change?.exchange_id ?? null - this.order_change_id ??= this.order_change?.id ?? null - this.version ??= this.order_change?.version ?? null - - if (!this.claim_id && !this.exchange_id) { - this.return_id ??= this.return?.id ?? this.order_change?.return_id ?? null - } - } -} +import { model } from "@medusajs/framework/utils" + +import { OrderChange } from "./order-change" + +const _OrderChangeAction = model + .define("OrderChangeAction", { + id: model.id({ prefix: "ordchact" }).primaryKey(), + order_id: model.text(), + return_id: model.text().nullable(), + claim_id: model.text().nullable(), + exchange_id: model.text().nullable(), + ordering: model.autoincrement(), + version: model.number().nullable(), + reference: model.text().nullable(), + reference_id: model.text().nullable(), + action: model.text(), + details: model.json().default({}), + amount: model.bigNumber().nullable(), + internal_note: model.text().nullable(), + applied: model.boolean().default(false), + order_change: model + .belongsTo<() => typeof OrderChange>(() => OrderChange, { + mappedBy: "actions", + }) + .nullable(), + }) + .indexes([ + { + name: "IDX_order_change_action_order_change_id", + on: ["order_change_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_action_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_action_return_id", + on: ["return_id"], + unique: false, + where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_action_claim_id", + on: ["claim_id"], + unique: false, + where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_action_exchange_id", + on: ["exchange_id"], + unique: false, + where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_action_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_action_ordering", + on: ["ordering"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderChangeAction = _OrderChangeAction diff --git a/packages/modules/order/src/models/order-change.ts b/packages/modules/order/src/models/order-change.ts index efa172e7a4fef..f6d7683fe44ff 100644 --- a/packages/modules/order/src/models/order-change.ts +++ b/packages/modules/order/src/models/order-change.ts @@ -1,252 +1,85 @@ -import { DAL } from "@medusajs/framework/types" -import { - createPsqlIndexStatementHelper, - DALUtils, - generateEntityId, - OrderChangeStatus, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Enum, - Filter, - ManyToOne, - OneToMany, - OnInit, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import {} from "@types" -import OrderClaim from "./claim" -import OrderExchange from "./exchange" -import Order from "./order" -import OrderChangeAction from "./order-change-action" -import Return from "./return" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change", - columns: "order_id", - where: "deleted_at IS NOT NULL", -}) - -const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change", - columns: "return_id", - where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const OrderClaimIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change", - columns: "claim_id", - where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const OrderExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_change", - columns: "exchange_id", - where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const OrderChangeStatusIndex = createPsqlIndexStatementHelper({ - tableName: "order_change", - columns: "status", - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_change", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const VersionIndex = createPsqlIndexStatementHelper({ - tableName: "order_change", - columns: ["order_id", "version"], - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_change" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -@VersionIndex.MikroORMIndex() -export default class OrderChange { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - columnType: "text", - fieldName: "order_id", - onDelete: "cascade", - mapToPk: true, - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @ManyToOne({ - entity: () => Return, - mapToPk: true, - fieldName: "return_id", - columnType: "text", - nullable: true, - }) - @ReturnIdIndex.MikroORMIndex() - return_id: string | null = null - - @ManyToOne(() => Return, { - persist: false, - nullable: true, - }) - return: Rel - - @ManyToOne({ - entity: () => OrderClaim, - mapToPk: true, - fieldName: "claim_id", - columnType: "text", - nullable: true, - }) - @OrderClaimIdIndex.MikroORMIndex() - claim_id: string | null = null - - @ManyToOne(() => OrderClaim, { - persist: false, - nullable: true, - }) - claim: OrderClaim - - @ManyToOne({ - entity: () => OrderExchange, - mapToPk: true, - fieldName: "exchange_id", - columnType: "text", - nullable: true, - }) - @OrderExchangeIdIndex.MikroORMIndex() - exchange_id: string | null = null - - @ManyToOne(() => OrderExchange, { - persist: false, - nullable: true, - }) - exchange: OrderExchange - - @Property({ columnType: "integer" }) - @VersionIndex.MikroORMIndex() - version: number - - @Property({ columnType: "text", nullable: true }) - change_type: string | null = null - - @OneToMany(() => OrderChangeAction, (action) => action.order_change, { - cascade: [Cascade.PERSIST, "soft-remove" as Cascade], - }) - actions = new Collection>(this) - - @Property({ - columnType: "text", - nullable: true, - }) - description: string | null = null - - @Enum({ items: () => OrderChangeStatus, default: OrderChangeStatus.PENDING }) - @OrderChangeStatusIndex.MikroORMIndex() - status: OrderChangeStatus = OrderChangeStatus.PENDING - - @Property({ columnType: "text", nullable: true }) - internal_note: string | null = null - - @Property({ columnType: "text", nullable: true }) - created_by: string // customer, user, third party, etc. - - @Property({ columnType: "text", nullable: true }) - requested_by: string | null = null // customer or user ID - - @Property({ - columnType: "timestamptz", - nullable: true, - }) - requested_at: Date | null = null - - @Property({ columnType: "text", nullable: true }) - confirmed_by: string | null = null // customer or user ID - - @Property({ - columnType: "timestamptz", - nullable: true, - }) - confirmed_at: Date | null = null - - @Property({ columnType: "text", nullable: true }) - declined_by: string | null = null // customer or user ID - - @Property({ columnType: "text", nullable: true }) - declined_reason: string | null = null - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - columnType: "timestamptz", - nullable: true, - }) - declined_at?: Date - - @Property({ columnType: "text", nullable: true }) - canceled_by: string | null = null - - @Property({ - columnType: "timestamptz", - nullable: true, - }) - canceled_at?: Date | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordch") - this.order_id ??= this.order?.id - this.return_id ??= this.return?.id - this.claim_id ??= this.claim?.id - this.exchange_id ??= this.exchange?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordch") - this.order_id ??= this.order?.id - this.return_id ??= this.return?.id - this.claim_id ??= this.claim?.id - this.exchange_id ??= this.exchange?.id - } -} +import { model, OrderChangeStatus } from "@medusajs/framework/utils" +import { Order } from "./order" +import { OrderChangeAction } from "./order-change-action" + +const _OrderChange = model + .define("OrderChange", { + id: model.id({ prefix: "ordch" }).primaryKey(), + return_id: model.text().nullable(), + claim_id: model.text().nullable(), + exchange_id: model.text().nullable(), + version: model.number(), + change_type: model.text().nullable(), + description: model.text().nullable(), + status: model + .enum(OrderChangeStatus) + .default(OrderChangeStatus.PENDING) + .nullable(), + internal_note: model.text().nullable(), + created_by: model.text().nullable(), + requested_by: model.text().nullable(), + requested_at: model.dateTime().nullable(), + confirmed_by: model.text().nullable(), + confirmed_at: model.dateTime().nullable(), + declined_by: model.text().nullable(), + declined_reason: model.text().nullable(), + metadata: model.json().nullable(), + declined_at: model.dateTime().nullable(), + canceled_by: model.text().nullable(), + canceled_at: model.dateTime().nullable(), + order: model.belongsTo<() => typeof Order>(() => Order, { + mappedBy: "changes", + }), + actions: model.hasMany<() => typeof OrderChangeAction>( + () => OrderChangeAction + ), + }) + .cascades({ + delete: ["actions"], + }) + .indexes([ + { + name: "IDX_order_change_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_return_id", + on: ["return_id"], + unique: false, + where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_claim_id", + on: ["claim_id"], + unique: false, + where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_exchange_id", + on: ["exchange_id"], + unique: false, + where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_status", + on: ["status"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_change_version", + on: ["order_id", "version"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderChange = _OrderChange diff --git a/packages/modules/order/src/models/order-item.ts b/packages/modules/order/src/models/order-item.ts index 4844274d1edf2..07c340c765f64 100644 --- a/packages/modules/order/src/models/order-item.ts +++ b/packages/modules/order/src/models/order-item.ts @@ -1,184 +1,56 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - BigNumber, - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import OrderLineItem from "./line-item" -import Order from "./order" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const tableName = "order_item" -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["order_id"], - where: "deleted_at IS NOT NULL", -}) - -const OrderVersionIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["version"], - where: "deleted_at IS NOT NULL", -}) - -const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["item_id"], - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName }) -export default class OrderItem { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - mapToPk: true, - fieldName: "order_id", - columnType: "text", - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @Property({ columnType: "integer" }) - @OrderVersionIndex.MikroORMIndex() - version: number - - @ManyToOne({ - entity: () => OrderLineItem, - fieldName: "item_id", - mapToPk: true, - columnType: "text", - }) - @ItemIdIndex.MikroORMIndex() - item_id: string - - @ManyToOne(() => OrderLineItem, { - persist: false, +import { model } from "@medusajs/framework/utils" + +import { OrderLineItem } from "./line-item" +import { Order } from "./order" + +const _OrderItem = model + .define("OrderItem", { + id: model.id({ prefix: "orditem" }).primaryKey(), + version: model.number().default(1), + unit_price: model.bigNumber().nullable(), + compare_at_unit_price: model.bigNumber().nullable(), + quantity: model.bigNumber(), + fulfilled_quantity: model.bigNumber().default(0), + delivered_quantity: model.bigNumber().default(0), + shipped_quantity: model.bigNumber().default(0), + return_requested_quantity: model.bigNumber().default(0), + return_received_quantity: model.bigNumber().default(0), + return_dismissed_quantity: model.bigNumber().default(0), + written_off_quantity: model.bigNumber().default(0), + metadata: model.json().nullable(), + order: model.belongsTo<() => typeof Order>(() => Order, { + mappedBy: "items", + }), + item: model.hasOne<() => typeof OrderLineItem>(() => OrderLineItem, { + mappedBy: undefined, + foreignKey: true, + }), }) - item: Rel - - @MikroOrmBigNumberProperty({ nullable: true }) - unit_price: BigNumber | number | null = null - - @Property({ columnType: "jsonb", nullable: true }) - raw_unit_price: BigNumberRawValue | null = null - - @MikroOrmBigNumberProperty({ nullable: true }) - compare_at_unit_price: BigNumber | number | null = null - - @Property({ columnType: "jsonb", nullable: true }) - raw_compare_at_unit_price: BigNumberRawValue | null = null - - @MikroOrmBigNumberProperty() - quantity: BigNumber | number - - @Property({ columnType: "jsonb" }) - raw_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - fulfilled_quantity: BigNumber | number = 0 - - @Property({ columnType: "jsonb" }) - raw_fulfilled_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - delivered_quantity: BigNumber | number = 0 - - @Property({ columnType: "jsonb" }) - raw_delivered_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - shipped_quantity: BigNumber | number = 0 - - @Property({ columnType: "jsonb" }) - raw_shipped_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - return_requested_quantity: BigNumber | number = 0 - - @Property({ columnType: "jsonb" }) - raw_return_requested_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - return_received_quantity: BigNumber | number = 0 - - @Property({ columnType: "jsonb" }) - raw_return_received_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - return_dismissed_quantity: BigNumber | number = 0 - - @Property({ columnType: "jsonb" }) - raw_return_dismissed_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - written_off_quantity: BigNumber | number = 0 - - @Property({ columnType: "jsonb" }) - raw_written_off_quantity: BigNumberRawValue - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "orditem") - this.order_id ??= this.order?.id - this.item_id ??= this.item?.id - this.version ??= this.order?.version - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "orditem") - this.order_id ??= this.order?.id - this.item_id ??= this.item?.id - this.version ??= this.order?.version - } -} + .indexes([ + { + name: "IDX_order_item_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_item_version", + on: ["version"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_item_item_id", + on: ["item_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_item_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderItem = _OrderItem diff --git a/packages/modules/order/src/models/order-shipping-method.ts b/packages/modules/order/src/models/order-shipping-method.ts index 98d85cb9cfaa5..1889c0dbab209 100644 --- a/packages/modules/order/src/models/order-shipping-method.ts +++ b/packages/modules/order/src/models/order-shipping-method.ts @@ -1,194 +1,83 @@ -import { DAL } from "@medusajs/framework/types" -import { - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import Claim from "./claim" -import Exchange from "./exchange" -import Order from "./order" -import Return from "./return" -import OrderShippingMethod from "./shipping-method" - -type OptionalShippingMethodProps = DAL.ModelDateColumns - -const tableName = "order_shipping" -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["order_id"], - where: "deleted_at IS NOT NULL", -}) - -const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "return_id", - where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const ExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["exchange_id"], - where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const ClaimIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["claim_id"], - where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const OrderVersionIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["version"], - where: "deleted_at IS NOT NULL", -}) - -const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["shipping_method_id"], - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName }) -export default class OrderShipping { - [OptionalProps]?: OptionalShippingMethodProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - mapToPk: true, - fieldName: "order_id", - columnType: "text", - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @ManyToOne({ - entity: () => Return, - mapToPk: true, - fieldName: "return_id", - columnType: "text", - nullable: true, - }) - @ReturnIdIndex.MikroORMIndex() - return_id: string | null = null - - @ManyToOne(() => Return, { - persist: false, - nullable: true, - }) - return: Rel - - @ManyToOne({ - entity: () => Exchange, - mapToPk: true, - fieldName: "exchange_id", - columnType: "text", - nullable: true, +import { model } from "@medusajs/framework/utils" +import { OrderClaim } from "./claim" +import { OrderExchange } from "./exchange" +import { Order } from "./order" +import { Return } from "./return" +import { OrderShippingMethod } from "./shipping-method" + +const _OrderShipping = model + .define("OrderShipping", { + id: model.id({ prefix: "ordspmv" }).primaryKey(), + version: model.number().default(1), + order: model.belongsTo<() => typeof Order>(() => Order, { + mappedBy: "shipping_methods", + }), + return: model + .belongsTo<() => typeof Return>(() => Return, { + mappedBy: "shipping_methods", + }) + .nullable(), + exchange: model + .belongsTo<() => typeof OrderExchange>(() => OrderExchange, { + mappedBy: "shipping_methods", + }) + .nullable(), + claim: model + .belongsTo<() => typeof OrderClaim>(() => OrderClaim, { + mappedBy: "shipping_methods", + }) + .nullable(), + shipping_method: model.hasOne<() => typeof OrderShippingMethod>( + () => OrderShippingMethod, + { + mappedBy: undefined, + foreignKey: true, + } + ), }) - @ExchangeIdIndex.MikroORMIndex() - exchange_id: string | null - - @ManyToOne(() => Exchange, { - persist: false, - nullable: true, - }) - exchange: Rel - - @ManyToOne({ - entity: () => Claim, - mapToPk: true, - fieldName: "claim_id", - columnType: "text", - nullable: true, - }) - @ClaimIdIndex.MikroORMIndex() - claim_id: string | null - - @ManyToOne(() => Claim, { - persist: false, - nullable: true, - }) - claim: Rel - - @Property({ columnType: "integer" }) - @OrderVersionIndex.MikroORMIndex() - version: number - - @ManyToOne({ - entity: () => OrderShippingMethod, - fieldName: "shipping_method_id", - mapToPk: true, - columnType: "text", - }) - @ItemIdIndex.MikroORMIndex() - shipping_method_id: string - - @ManyToOne(() => OrderShippingMethod, { - persist: false, - }) - shipping_method: Rel - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordspmv") - this.order_id ??= this.order?.id - this.return_id ??= this.return?.id - this.claim_id ??= this.claim?.id - this.exchange_id ??= this.exchange?.id - this.shipping_method_id ??= this.shipping_method?.id - this.version ??= this.order?.version - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordspmv") - this.order_id ??= this.order?.id - this.return_id ??= this.return?.id - this.claim_id ??= this.claim?.id - this.exchange_id ??= this.exchange?.id - this.shipping_method_id ??= this.shipping_method?.id - this.version ??= this.order?.version - } -} + .indexes([ + { + name: "IDX_order_shipping_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_shipping_return_id", + on: ["return_id"], + unique: false, + where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_shipping_exchange_id", + on: ["exchange_id"], + unique: false, + where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_shipping_claim_id", + on: ["claim_id"], + unique: false, + where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_shipping_version", + on: ["version"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_shipping_shipping_method_id", + on: ["shipping_method_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_shipping_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderShipping = _OrderShipping diff --git a/packages/modules/order/src/models/order-summary.ts b/packages/modules/order/src/models/order-summary.ts index dd843b9d7f2bc..d1da43a456db3 100644 --- a/packages/modules/order/src/models/order-summary.ts +++ b/packages/modules/order/src/models/order-summary.ts @@ -1,112 +1,33 @@ -import { - BigNumber, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - ManyToOne, - OnInit, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import Order from "./order" - -type OrderSummaryTotals = { - total: BigNumber - subtotal: BigNumber - total_tax: BigNumber - - ordered_total: BigNumber - fulfilled_total: BigNumber - returned_total: BigNumber - return_request_total: BigNumber - write_off_total: BigNumber - projected_total: BigNumber - - net_total: BigNumber - net_subtotal: BigNumber - net_total_tax: BigNumber - - balance: BigNumber - - paid_total: BigNumber - refunded_total: BigNumber -} - -const tableName = "order_summary" - -const OrderIdVersionIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["order_id", "version"], - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName }) -@OrderIdVersionIndex.MikroORMIndex() -export default class OrderSummary { - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - columnType: "text", - fieldName: "order_id", - mapToPk: true, - onDelete: "cascade", - }) - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @Property({ - columnType: "integer", - defaultRaw: "1", - }) - version: number = 1 - - @Property({ columnType: "jsonb" }) - totals: OrderSummaryTotals | null = {} as OrderSummaryTotals - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordsum") - this.order_id ??= this.order?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordsum") - this.order_id ??= this.order?.id - } -} +import { model } from "@medusajs/framework/utils" +import { Order } from "./order" + +const _OrderSummary = model + .define( + { + tableName: "order_summary", + }, + { + id: model.id({ prefix: "ordsum" }).primaryKey(), + version: model.number().default(1), + totals: model.json(), + order: model.belongsTo<() => typeof Order>(() => Order, { + mappedBy: "summary", + }), + } + ) + .indexes([ + { + name: "IDX_order_summary_order_id_version", + on: ["order_id", "version"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_summary_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderSummary = _OrderSummary diff --git a/packages/modules/order/src/models/order.ts b/packages/modules/order/src/models/order.ts index 69af343f9f92a..584c01762b344 100644 --- a/packages/modules/order/src/models/order.ts +++ b/packages/modules/order/src/models/order.ts @@ -1,230 +1,116 @@ -import { DAL } from "@medusajs/framework/types" -import { - OrderStatus, - Searchable, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Enum, - ManyToOne, - OnInit, - OneToMany, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import OrderAddress from "./address" -import OrderCreditLine from "./credit-line" -import OrderItem from "./order-item" -import OrderShipping from "./order-shipping-method" -import OrderSummary from "./order-summary" -import OrderTransaction from "./transaction" - -type OptionalOrderProps = - | "shipping_address" - | "billing_address" - | DAL.ModelDateColumns - -const DisplayIdIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "display_id", - where: "deleted_at IS NOT NULL", -}) - -const RegionIdIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "region_id", - where: "deleted_at IS NOT NULL", -}) - -const CustomerIdIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "customer_id", - where: "deleted_at IS NOT NULL", -}) - -const SalesChannelIdIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "customer_id", - where: "deleted_at IS NOT NULL", -}) - -const OrderDeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const CurrencyCodeIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "currency_code", - where: "deleted_at IS NOT NULL", -}) - -const ShippingAddressIdIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "shipping_address_id", - where: "deleted_at IS NOT NULL", -}) - -const BillingAddressIdIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "billing_address_id", - where: "deleted_at IS NOT NULL", -}) - -const IsDraftOrderIndex = createPsqlIndexStatementHelper({ - tableName: "order", - columns: "is_draft_order", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order" }) -export default class Order { - [OptionalProps]?: OptionalOrderProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @Searchable() - @Property({ autoincrement: true, primary: false }) - @DisplayIdIndex.MikroORMIndex() - display_id: number - - @Property({ - columnType: "text", - nullable: true, - }) - @RegionIdIndex.MikroORMIndex() - region_id: string | null = null - - @Property({ - columnType: "text", - nullable: true, - }) - @CustomerIdIndex.MikroORMIndex() - customer_id: string | null = null - - @Property({ - columnType: "integer", - defaultRaw: "1", - }) - version: number = 1 - - @Property({ - columnType: "text", - nullable: true, - }) - @SalesChannelIdIndex.MikroORMIndex() - sales_channel_id: string | null = null - - @Enum({ items: () => OrderStatus, default: OrderStatus.PENDING }) - status: OrderStatus - - @Property({ - columnType: "boolean", - }) - @IsDraftOrderIndex.MikroORMIndex() - is_draft_order: boolean = false - - @Searchable() - @Property({ columnType: "text", nullable: true }) - email: string | null = null - - @Property({ columnType: "text" }) - @CurrencyCodeIndex.MikroORMIndex() - currency_code: string - - @Property({ columnType: "text", nullable: true }) - @ShippingAddressIdIndex.MikroORMIndex() - shipping_address_id?: string | null - - @ManyToOne({ - entity: () => OrderAddress, - fieldName: "shipping_address_id", - nullable: true, - cascade: [Cascade.PERSIST], +import { model, OrderStatus } from "@medusajs/framework/utils" +import { OrderAddress } from "./address" +import { OrderCreditLine } from "./credit-line" +import { OrderItem } from "./order-item" +import { OrderShipping } from "./order-shipping-method" +import { OrderSummary } from "./order-summary" +import { OrderTransaction } from "./transaction" +import { Return } from "@models" + +const _Order = model + .define("Order", { + id: model.id({ prefix: "order" }).primaryKey(), + display_id: model.autoincrement(), + region_id: model.text().nullable(), + customer_id: model.text().nullable(), + version: model.number().default(1), + sales_channel_id: model.text().nullable(), + status: model.enum(OrderStatus).default(OrderStatus.PENDING), + is_draft_order: model.boolean().default(false), + email: model.text().searchable().nullable(), + currency_code: model.text(), + no_notification: model.boolean().nullable(), + metadata: model.json().nullable(), + canceled_at: model.dateTime().nullable(), + shipping_address: model + .hasOne(() => OrderAddress, { + mappedBy: undefined, + foreignKey: true, + }) + .nullable(), + billing_address: model + .hasOne(() => OrderAddress, { + mappedBy: undefined, + foreignKey: true, + }) + .nullable(), + summary: model.hasMany(() => OrderSummary, { + mappedBy: "order", + }), + items: model.hasMany(() => OrderItem, { + mappedBy: "order", + }), + shipping_methods: model.hasMany(() => OrderShipping, { + mappedBy: "order", + }), + transactions: model.hasMany(() => OrderTransaction, { + mappedBy: "order", + }), + credit_lines: model.hasMany(() => OrderCreditLine, { + mappedBy: "order", + }), + returns: model.hasMany(() => Return, { + mappedBy: "order", + }), }) - shipping_address?: Rel | null - - @Property({ columnType: "text", nullable: true }) - @BillingAddressIdIndex.MikroORMIndex() - billing_address_id?: string | null - - @ManyToOne({ - entity: () => OrderAddress, - fieldName: "billing_address_id", - nullable: true, - cascade: [Cascade.PERSIST], - }) - billing_address?: Rel | null - - @Property({ columnType: "boolean", nullable: true }) - no_notification: boolean | null = null - - @OneToMany(() => OrderSummary, (summary) => summary.order, { - cascade: [Cascade.PERSIST], - }) - summary = new Collection>(this) - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @OneToMany(() => OrderItem, (itemDetail) => itemDetail.order, { - cascade: [Cascade.PERSIST], - }) - items = new Collection>(this) - - @OneToMany(() => OrderCreditLine, (creditLine) => creditLine.order, { - cascade: [Cascade.PERSIST], + .cascades({ + delete: ["summary", "items", "shipping_methods", "transactions"], }) - credit_lines = new Collection>(this) - - @OneToMany(() => OrderShipping, (shippingMethod) => shippingMethod.order, { - cascade: [Cascade.PERSIST], - }) - shipping_methods = new Collection>(this) - - @OneToMany(() => OrderTransaction, (transaction) => transaction.order, { - cascade: [Cascade.PERSIST], - }) - transactions = new Collection>(this) - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @OrderDeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @Property({ columnType: "timestamptz", nullable: true }) - canceled_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "order") - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "order") - } -} + .indexes([ + { + name: "IDX_order_display_id", + on: ["display_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_region_id", + on: ["region_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_customer_id", + on: ["customer_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_sales_channel_id", + on: ["sales_channel_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_currency_code", + on: ["currency_code"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_shipping_address_id", + on: ["shipping_address_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_billing_address_id", + on: ["billing_address_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_is_draft_order", + on: ["is_draft_order"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const Order = _Order diff --git a/packages/modules/order/src/models/return-item.ts b/packages/modules/order/src/models/return-item.ts index a0e78dd9d6b64..ca597903c7a8a 100644 --- a/packages/modules/order/src/models/return-item.ts +++ b/packages/modules/order/src/models/return-item.ts @@ -1,150 +1,58 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, -} from "@mikro-orm/core" -import OrderLineItem from "./line-item" -import Return from "./return" -import ReturnReason from "./return-reason" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const tableName = "return_item" -const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "return_id", - where: "deleted_at IS NOT NULL", -}) - -const ReturnReasonIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "reason_id", - where: "deleted_at IS NOT NULL", -}) - -const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "item_id", - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName }) -export default class ReturnItem { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne(() => ReturnReason, { - columnType: "text", - fieldName: "reason_id", - mapToPk: true, - nullable: true, - }) - @ReturnReasonIdIndex.MikroORMIndex() - reason_id: string | null = null - - @ManyToOne(() => ReturnReason, { - persist: false, - }) - reason: ReturnReason - - @MikroOrmBigNumberProperty() - quantity: Number | number - - @Property({ columnType: "jsonb" }) - raw_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - received_quantity: Number | number = 0 - - @Property({ columnType: "jsonb" }) - raw_received_quantity: BigNumberRawValue - - @MikroOrmBigNumberProperty() - damaged_quantity: Number | number = 0 - - @Property({ columnType: "jsonb" }) - raw_damaged_quantity: BigNumberRawValue - - @ManyToOne(() => Return, { - columnType: "text", - fieldName: "return_id", - mapToPk: true, - onDelete: "cascade", - }) - @ReturnIdIndex.MikroORMIndex() - return_id: string - - @ManyToOne(() => Return, { - persist: false, - }) - return: Return - - @ManyToOne({ - entity: () => OrderLineItem, - fieldName: "item_id", - mapToPk: true, - columnType: "text", - }) - @ItemIdIndex.MikroORMIndex() - item_id: string - - @ManyToOne(() => OrderLineItem, { - persist: false, - }) - item: OrderLineItem - - @Property({ columnType: "text", nullable: true }) - note: string - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "retitem") - this.return_id ??= this.return?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "retitem") - this.return_id ??= this.return?.id - } -} +import { model } from "@medusajs/framework/utils" +import { OrderLineItem } from "./line-item" +import { Return } from "./return" +import { ReturnReason } from "./return-reason" + +const _ReturnItem = model + .define( + { + tableName: "return_item", + }, + { + id: model.id({ prefix: "retitem" }).primaryKey(), + quantity: model.bigNumber(), + received_quantity: model.bigNumber().default(0), + damaged_quantity: model.bigNumber().default(0), + note: model.text().nullable(), + metadata: model.json().nullable(), + reason: model + .belongsTo<() => typeof ReturnReason>(() => ReturnReason, { + mappedBy: "return_items", + }) + .nullable(), + return: model.belongsTo<() => typeof Return>(() => Return, { + mappedBy: "items", + }), + item: model.belongsTo<() => typeof OrderLineItem>(() => OrderLineItem, { + mappedBy: "return_items", + }), + } + ) + .indexes([ + { + name: "IDX_return_item_return_id", + on: ["return_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_item_reason_id", + on: ["reason_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_item_item_id", + on: ["item_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_item_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const ReturnItem = _ReturnItem diff --git a/packages/modules/order/src/models/return-reason.ts b/packages/modules/order/src/models/return-reason.ts index 9bd52a28a04aa..d774b4b6dc8a8 100644 --- a/packages/modules/order/src/models/return-reason.ts +++ b/packages/modules/order/src/models/return-reason.ts @@ -1,111 +1,43 @@ -import { DAL } from "@medusajs/framework/types" -import { - DALUtils, - Searchable, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Entity, - Filter, - ManyToOne, - OnInit, - OneToMany, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "return_reason", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const ValueIndex = createPsqlIndexStatementHelper({ - tableName: "return_reason", - columns: "value", - where: "deleted_at IS NOT NULL", -}) - -const ParentIndex = createPsqlIndexStatementHelper({ - tableName: "return_reason", - columns: "parent_return_reason_id", - where: "deleted_at IS NOT NULL", -}) - -type OptionalOrderProps = "parent_return_reason" | DAL.ModelDateColumns - -@Entity({ tableName: "return_reason" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class ReturnReason { - [OptionalProps]?: OptionalOrderProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @Searchable() - @Property({ columnType: "text" }) - @ValueIndex.MikroORMIndex() - value: string - - @Searchable() - @Property({ columnType: "text" }) - label: string - - @Property({ columnType: "text", nullable: true }) - description: string | null = null - - @Property({ columnType: "text", nullable: true }) - @ParentIndex.MikroORMIndex() - parent_return_reason_id?: string | null - - @ManyToOne({ - entity: () => ReturnReason, - fieldName: "parent_return_reason_id", - nullable: true, - cascade: [Cascade.PERSIST], +import { model } from "@medusajs/framework/utils" + +const _ReturnReason = model + .define("ReturnReason", { + id: model.id({ prefix: "rr" }).primaryKey(), + value: model.text().searchable(), + label: model.text().searchable(), + description: model.text().nullable(), + metadata: model.json().nullable(), + parent_return_reason: model + .belongsTo<() => typeof _ReturnReason>(() => _ReturnReason, { + mappedBy: "return_reason_children", + }) + .nullable(), + return_reason_children: model.hasMany<() => typeof _ReturnReason>( + () => _ReturnReason, + { + mappedBy: "parent_return_reason", + } + ), }) - parent_return_reason?: Rel | null - @OneToMany( - () => ReturnReason, - (return_reason) => return_reason.parent_return_reason, - { cascade: [Cascade.PERSIST] } - ) - return_reason_children: Rel[] - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "rr") - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "rr") - } -} + .indexes([ + { + name: "IDX_return_reason_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_reason_value", + on: ["value"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_reason_parent_return_reason_id", + on: ["parent_return_reason_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const ReturnReason = _ReturnReason diff --git a/packages/modules/order/src/models/return.ts b/packages/modules/order/src/models/return.ts index 65bfaf42012a4..c09acf01de5d3 100644 --- a/packages/modules/order/src/models/return.ts +++ b/packages/modules/order/src/models/return.ts @@ -1,192 +1,90 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" -import { - BigNumber, - DALUtils, - MikroOrmBigNumberProperty, - ReturnStatus, - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Enum, - Filter, - ManyToOne, - OnInit, - OneToMany, - OneToOne, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import { OrderTransaction, ReturnItem } from "@models" -import Claim from "./claim" -import Exchange from "./exchange" -import Order from "./order" -import OrderShipping from "./order-shipping-method" - -type OptionalReturnProps = DAL.ModelDateColumns - -const DisplayIdIndex = createPsqlIndexStatementHelper({ - tableName: "return", - columns: "display_id", - where: "deleted_at IS NOT NULL", -}) - -const ReturnDeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "return", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "return", - columns: ["order_id"], - where: "deleted_at IS NOT NULL", -}) - -const ExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName: "return", - columns: ["exchange_id"], - where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const ClaimIdIndex = createPsqlIndexStatementHelper({ - tableName: "return", - columns: ["claim_id"], - where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "return" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class Return { - [OptionalProps]?: OptionalReturnProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - mapToPk: true, - fieldName: "order_id", - columnType: "text", - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, +import { model, ReturnStatus } from "@medusajs/framework/utils" +import { OrderClaim } from "./claim" +import { OrderExchange } from "./exchange" +import { Order } from "./order" +import { OrderShipping } from "./order-shipping-method" +import { ReturnItem } from "./return-item" +import { OrderTransaction } from "./transaction" + +const _Return = model + .define("Return", { + id: model.id({ prefix: "return" }).primaryKey(), + order_version: model.number(), + display_id: model.autoincrement(), + status: model.enum(ReturnStatus).default(ReturnStatus.OPEN), + location_id: model.text().nullable(), + no_notification: model.boolean().nullable(), + refund_amount: model.bigNumber().nullable(), + created_by: model.text().nullable(), + metadata: model.json().nullable(), + requested_at: model.dateTime().nullable(), + received_at: model.dateTime().nullable(), + canceled_at: model.dateTime().nullable(), + order: model.belongsTo<() => typeof Order>(() => Order, { + mappedBy: "returns", + }), + exchange: model + .hasOne<() => typeof OrderExchange>(() => OrderExchange, { + mappedBy: undefined, + foreignKey: true, + }) + .nullable(), + claim: model + .hasOne<() => typeof OrderClaim>(() => OrderClaim, { + mappedBy: undefined, + foreignKey: true, + }) + .nullable(), + items: model.hasMany<() => typeof ReturnItem>(() => ReturnItem, { + mappedBy: "return", + }), + shipping_methods: model.hasMany<() => typeof OrderShipping>( + () => OrderShipping, + { + mappedBy: "return", + } + ), + transactions: model.hasMany<() => typeof OrderTransaction>( + () => OrderTransaction, + { + mappedBy: "return", + } + ), }) - order: Rel - - @OneToOne({ - entity: () => Exchange, - fieldName: "exchange_id", - nullable: true, - }) - exchange: Rel - - @Property({ columnType: "text", nullable: true }) - @ExchangeIdIndex.MikroORMIndex() - exchange_id: string | null = null - - @OneToOne({ - entity: () => Claim, - fieldName: "claim_id", - nullable: true, + .cascades({ + delete: ["items", "shipping_methods", "transactions"], }) - claim: Rel - - @Property({ columnType: "text", nullable: true }) - @ClaimIdIndex.MikroORMIndex() - claim_id: string | null = null - - @Property({ - columnType: "integer", - }) - order_version: number - - @Property({ autoincrement: true, primary: false }) - @DisplayIdIndex.MikroORMIndex() - display_id: number - - @Enum({ items: () => ReturnStatus, default: ReturnStatus.OPEN }) - status: ReturnStatus = ReturnStatus.OPEN - - @Property({ columnType: "text", nullable: true }) - location_id: string | null = null - - @Property({ columnType: "boolean", nullable: true }) - no_notification: boolean | null = null - - @MikroOrmBigNumberProperty({ - nullable: true, - }) - refund_amount: BigNumber | number - - @Property({ columnType: "jsonb", nullable: true }) - raw_refund_amount: BigNumberRawValue - - @OneToMany(() => ReturnItem, (itemDetail) => itemDetail.return, { - cascade: [Cascade.PERSIST], - }) - items = new Collection>(this) - - @OneToMany(() => OrderShipping, (shippingMethod) => shippingMethod.return, { - cascade: [Cascade.PERSIST], - }) - shipping_methods = new Collection(this) - - @OneToMany(() => OrderTransaction, (transaction) => transaction.return, { - cascade: [Cascade.PERSIST], - }) - transactions = new Collection(this) - - @Property({ columnType: "text", nullable: true }) - created_by: string | null = null - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @ReturnDeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @Property({ columnType: "timestamptz", nullable: true }) - requested_at: Date | null = null - - @Property({ columnType: "timestamptz", nullable: true }) - received_at: Date | null = null - - @Property({ columnType: "timestamptz", nullable: true }) - canceled_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "return") - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "return") - } -} + .indexes([ + { + name: "IDX_return_display_id", + on: ["display_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_return_exchange_id", + on: ["exchange_id"], + unique: false, + where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_return_claim_id", + on: ["claim_id"], + unique: false, + where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + ]) + +export const Return = _Return diff --git a/packages/modules/order/src/models/shipping-method-adjustment.ts b/packages/modules/order/src/models/shipping-method-adjustment.ts index 525869435598e..e9d923b1dd923 100644 --- a/packages/modules/order/src/models/shipping-method-adjustment.ts +++ b/packages/modules/order/src/models/shipping-method-adjustment.ts @@ -1,42 +1,32 @@ -import { - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { BeforeCreate, Entity, ManyToOne, OnInit, Rel } from "@mikro-orm/core" -import AdjustmentLine from "./adjustment-line" -import OrderShippingMethod from "./shipping-method" +import { model } from "@medusajs/framework/utils" +import { OrderShippingMethod } from "./shipping-method" -const ShippingMethodIdIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping_method_adjustment", - columns: "shipping_method_id", -}) +const _OrderShippingMethodAdjustment = model + .define( + { + tableName: "order_shipping_method_adjustment", + }, + { + id: model.id({ prefix: "ordsmadj" }).primaryKey(), + description: model.text().nullable(), + promotion_id: model.text().nullable(), + code: model.text().nullable(), + amount: model.bigNumber(), + provider_id: model.text().nullable(), + shipping_method: model.belongsTo<() => typeof OrderShippingMethod>( + () => OrderShippingMethod, + { + mappedBy: "adjustments", + } + ), + } + ) + .indexes([ + { + name: "IDX_order_shipping_method_adjustment_shipping_method_id", + on: ["shipping_method_id"], + unique: false, + }, + ]) -@Entity({ tableName: "order_shipping_method_adjustment" }) -export default class OrderShippingMethodAdjustment extends AdjustmentLine { - @ManyToOne(() => OrderShippingMethod, { - persist: false, - }) - shipping_method: Rel - - @ManyToOne({ - entity: () => OrderShippingMethod, - columnType: "text", - fieldName: "shipping_method_id", - mapToPk: true, - onDelete: "cascade", - }) - @ShippingMethodIdIdIndex.MikroORMIndex() - shipping_method_id: string - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordsmadj") - this.shipping_method_id ??= this.shipping_method?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordsmadj") - this.shipping_method_id ??= this.shipping_method?.id - } -} +export const OrderShippingMethodAdjustment = _OrderShippingMethodAdjustment diff --git a/packages/modules/order/src/models/shipping-method-tax-line.ts b/packages/modules/order/src/models/shipping-method-tax-line.ts index 1afba00809bdb..362300f5114a9 100644 --- a/packages/modules/order/src/models/shipping-method-tax-line.ts +++ b/packages/modules/order/src/models/shipping-method-tax-line.ts @@ -1,42 +1,32 @@ -import { - createPsqlIndexStatementHelper, - generateEntityId, -} from "@medusajs/framework/utils" -import { BeforeCreate, Entity, ManyToOne, OnInit, Rel } from "@mikro-orm/core" -import OrderShippingMethod from "./shipping-method" -import TaxLine from "./tax-line" +import { model } from "@medusajs/framework/utils" +import { OrderShippingMethod } from "./shipping-method" -const ShippingMethodIdIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping_method_tax_line", - columns: "shipping_method_id", -}) +const _OrderShippingMethodTaxLine = model + .define( + { + tableName: "order_shipping_method_tax_line", + }, + { + id: model.id({ prefix: "ordsmtxl" }).primaryKey(), + description: model.text().nullable(), + tax_rate_id: model.text().nullable(), + code: model.text(), + rate: model.bigNumber(), + provider_id: model.text().nullable(), + shipping_method: model.belongsTo<() => typeof OrderShippingMethod>( + () => OrderShippingMethod, + { + mappedBy: "tax_lines", + } + ), + } + ) + .indexes([ + { + name: "IDX_order_shipping_method_tax_line_shipping_method_id", + on: ["shipping_method_id"], + unique: false, + }, + ]) -@Entity({ tableName: "order_shipping_method_tax_line" }) -export default class OrderShippingMethodTaxLine extends TaxLine { - @ManyToOne(() => OrderShippingMethod, { - persist: false, - }) - shipping_method: Rel - - @ManyToOne({ - entity: () => OrderShippingMethod, - fieldName: "shipping_method_id", - columnType: "text", - mapToPk: true, - onDelete: "cascade", - }) - @ShippingMethodIdIdIndex.MikroORMIndex() - shipping_method_id: string - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordsmtxl") - this.shipping_method_id ??= this.shipping_method?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordsmtxl") - this.shipping_method_id ??= this.shipping_method?.id - } -} +export const OrderShippingMethodTaxLine = _OrderShippingMethodTaxLine diff --git a/packages/modules/order/src/models/shipping-method.ts b/packages/modules/order/src/models/shipping-method.ts index 8c9207bbbb1fa..aa5db60719fa5 100644 --- a/packages/modules/order/src/models/shipping-method.ts +++ b/packages/modules/order/src/models/shipping-method.ts @@ -1,118 +1,40 @@ -import { BigNumberRawValue } from "@medusajs/framework/types" -import { - BigNumber, - createPsqlIndexStatementHelper, - DALUtils, - generateEntityId, - MikroOrmBigNumberProperty, -} from "@medusajs/framework/utils" -import { - BeforeCreate, - Cascade, - Collection, - Entity, - Filter, - OneToMany, - OnInit, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import OrderShippingMethodAdjustment from "./shipping-method-adjustment" -import OrderShippingMethodTaxLine from "./shipping-method-tax-line" - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping_method", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const ShippingOptionIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping_method", - columns: "shipping_option_id", - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName: "order_shipping_method" }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -export default class OrderShippingMethod { - @PrimaryKey({ columnType: "text" }) - id: string - - @Property({ columnType: "text" }) - name: string - - @Property({ columnType: "jsonb", nullable: true }) - description: string | null = null - - @MikroOrmBigNumberProperty() - amount: BigNumber | number - - @Property({ columnType: "jsonb" }) - raw_amount: BigNumberRawValue - - @Property({ columnType: "boolean" }) - is_tax_inclusive: boolean = false - - @Property({ columnType: "boolean", default: false }) - is_custom_amount: boolean = false - - @Property({ - columnType: "text", - nullable: true, +import { model } from "@medusajs/framework/utils" +import { OrderShippingMethodAdjustment } from "./shipping-method-adjustment" +import { OrderShippingMethodTaxLine } from "./shipping-method-tax-line" + +const _OrderShippingMethod = model + .define("OrderShippingMethod", { + id: model.id({ prefix: "ordsm" }).primaryKey(), + name: model.text(), + description: model.json().nullable(), + amount: model.bigNumber(), + is_tax_inclusive: model.boolean().default(false), + is_custom_amount: model.boolean().default(false), + shipping_option_id: model.text().nullable(), + data: model.json().nullable(), + metadata: model.json().nullable(), + tax_lines: model.hasMany<() => typeof OrderShippingMethodTaxLine>( + () => OrderShippingMethodTaxLine, + { + mappedBy: "shipping_method", + } + ), + adjustments: model.hasMany<() => typeof OrderShippingMethodAdjustment>( + () => OrderShippingMethodAdjustment, + { + mappedBy: "shipping_method", + } + ), }) - @ShippingOptionIdIndex.MikroORMIndex() - shipping_option_id: string | null = null - - @Property({ columnType: "jsonb", nullable: true }) - data: Record | null = null - - @Property({ columnType: "jsonb", nullable: true }) - metadata: Record | null = null - - @OneToMany( - () => OrderShippingMethodTaxLine, - (taxLine) => taxLine.shipping_method, - { - cascade: [Cascade.PERSIST, "soft-remove" as Cascade], - } - ) - tax_lines = new Collection>(this) - - @OneToMany( - () => OrderShippingMethodAdjustment, - (adjustment) => adjustment.shipping_method, - { - cascade: [Cascade.PERSIST, "soft-remove" as Cascade], - } - ) - adjustments = new Collection>(this) - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", + .cascades({ + delete: ["tax_lines", "adjustments"], }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null + .indexes([ + { + name: "IDX_order_shipping_method_shipping_option_id", + on: ["shipping_option_id"], + unique: false, + }, + ]) - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordsm") - } - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordsm") - } -} +export const OrderShippingMethod = _OrderShippingMethod diff --git a/packages/modules/order/src/models/tax-line.ts b/packages/modules/order/src/models/tax-line.ts deleted file mode 100644 index 2be617fda95d1..0000000000000 --- a/packages/modules/order/src/models/tax-line.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { BigNumberRawValue } from "@medusajs/framework/types" -import { BigNumber, MikroOrmBigNumberProperty } from "@medusajs/framework/utils" -import { PrimaryKey, Property } from "@mikro-orm/core" - -/** - * As per the Mikro ORM docs, superclasses should use the abstract class definition - * Source: https://mikro-orm.io/docs/inheritance-mapping - */ -export default abstract class TaxLine { - @PrimaryKey({ columnType: "text" }) - id: string - - @Property({ columnType: "text", nullable: true }) - description?: string | null - - @Property({ - columnType: "text", - nullable: true, - }) - tax_rate_id?: string | null - - @Property({ columnType: "text" }) - code: string - - @MikroOrmBigNumberProperty() - rate: BigNumber | number - - @Property({ columnType: "jsonb" }) - raw_rate: BigNumberRawValue - - @Property({ columnType: "text", nullable: true }) - provider_id?: string | null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - deleted_at: Date | null = null -} diff --git a/packages/modules/order/src/models/transaction.ts b/packages/modules/order/src/models/transaction.ts index 42ca89608c469..bd712353ece16 100644 --- a/packages/modules/order/src/models/transaction.ts +++ b/packages/modules/order/src/models/transaction.ts @@ -1,214 +1,92 @@ -import { BigNumberRawValue, DAL } from "@medusajs/framework/types" import { - BigNumber, - DALUtils, - MikroOrmBigNumberProperty, - createPsqlIndexStatementHelper, - generateEntityId, + DmlEntity, + DMLEntitySchemaBuilder, + model, } from "@medusajs/framework/utils" -import { - BeforeCreate, - Entity, - Filter, - ManyToOne, - OnInit, - OptionalProps, - PrimaryKey, - Property, - Rel, -} from "@mikro-orm/core" -import Claim from "./claim" -import Exchange from "./exchange" -import Order from "./order" -import Return from "./return" - -type OptionalLineItemProps = DAL.ModelDateColumns - -const tableName = "order_transaction" - -const ReferenceIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "reference_id", - where: "deleted_at IS NOT NULL", -}) - -const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "order_id", - where: "deleted_at IS NOT NULL", -}) - -const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "return_id", - where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const ExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["exchange_id"], - where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const ClaimIdIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["claim_id"], - where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", -}) - -const CurrencyCodeIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "currency_code", - where: "deleted_at IS NOT NULL", -}) - -const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", -}) - -const OrderIdVersionIndex = createPsqlIndexStatementHelper({ - tableName, - columns: ["order_id", "version"], - where: "deleted_at IS NOT NULL", -}) - -@Entity({ tableName }) -@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) -@OrderIdVersionIndex.MikroORMIndex() -export default class OrderTransaction { - [OptionalProps]?: OptionalLineItemProps - - @PrimaryKey({ columnType: "text" }) - id: string - - @ManyToOne({ - entity: () => Order, - columnType: "text", - fieldName: "order_id", - onDelete: "cascade", - mapToPk: true, - }) - @OrderIdIndex.MikroORMIndex() - order_id: string - - @ManyToOne(() => Order, { - persist: false, - }) - order: Rel - - @ManyToOne({ - entity: () => Return, - mapToPk: true, - fieldName: "return_id", - columnType: "text", - nullable: true, - }) - @ReturnIdIndex.MikroORMIndex() - return_id: string | null = null - - @ManyToOne(() => Return, { - persist: false, - nullable: true, - }) - return: Rel - - @ManyToOne({ - entity: () => Exchange, - mapToPk: true, - fieldName: "exchange_id", - columnType: "text", - nullable: true, +import { OrderClaim } from "./claim" +import { OrderExchange } from "./exchange" +import { Order } from "./order" +import { Return } from "./return" + +const _OrderTransaction = model + .define("OrderTransaction", { + id: model.id({ prefix: "ordtrx" }).primaryKey(), + version: model.number().default(1), + amount: model.bigNumber(), + currency_code: model.text(), + reference: model.text().nullable(), + reference_id: model.text().nullable(), + order: model.belongsTo<() => typeof Order>(() => Order, { + mappedBy: "transactions", + }), + return: model + .belongsTo<() => typeof Return>(() => Return, { + mappedBy: "transactions", + }) + .nullable(), + exchange: model + .belongsTo<() => typeof OrderExchange>(() => OrderExchange, { + mappedBy: "transactions", + }) + .nullable(), + claim: model + .belongsTo<() => typeof OrderClaim>(() => OrderClaim, { + mappedBy: "transactions", + }) + .nullable(), }) - @ExchangeIdIndex.MikroORMIndex() - exchange_id: string | null - - @ManyToOne(() => Exchange, { - persist: false, - nullable: true, - }) - exchange: Rel - - @ManyToOne({ - entity: () => Claim, - mapToPk: true, - fieldName: "claim_id", - columnType: "text", - nullable: true, - }) - @ClaimIdIndex.MikroORMIndex() - claim_id: string | null - - @ManyToOne(() => Claim, { - persist: false, - nullable: true, - }) - claim: Rel - - @Property({ - columnType: "integer", - defaultRaw: "1", - }) - version: number = 1 - - @MikroOrmBigNumberProperty() - amount: BigNumber | number - - @Property({ columnType: "jsonb" }) - raw_amount: BigNumberRawValue - - @Property({ columnType: "text" }) - @CurrencyCodeIndex.MikroORMIndex() - currency_code: string - - @Property({ - columnType: "text", - nullable: true, - }) - reference: string | null = null - - @Property({ - columnType: "text", - nullable: true, - }) - @ReferenceIdIndex.MikroORMIndex() - reference_id: string | null = null - - @Property({ - onCreate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - created_at: Date - - @Property({ - onCreate: () => new Date(), - onUpdate: () => new Date(), - columnType: "timestamptz", - defaultRaw: "now()", - }) - updated_at: Date - - @Property({ columnType: "timestamptz", nullable: true }) - @DeletedAtIndex.MikroORMIndex() - deleted_at: Date | null = null - - @BeforeCreate() - onCreate() { - this.id = generateEntityId(this.id, "ordtrx") - this.order_id ??= this.order?.id - this.return_id ??= this.return?.id - this.claim_id ??= this.claim?.id - this.exchange_id ??= this.exchange?.id - } - - @OnInit() - onInit() { - this.id = generateEntityId(this.id, "ordtrx") - this.order_id ??= this.order?.id - this.return_id ??= this.return?.id - this.claim_id ??= this.claim?.id - this.exchange_id ??= this.exchange?.id - } -} + .indexes([ + { + name: "IDX_order_transaction_reference_id", + on: ["reference_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_transaction_order_id", + on: ["order_id"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_transaction_return_id", + on: ["return_id"], + unique: false, + where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_transaction_exchange_id", + on: ["exchange_id"], + unique: false, + where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_transaction_claim_id", + on: ["claim_id"], + unique: false, + where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", + }, + { + name: "IDX_order_transaction_currency_code", + on: ["currency_code"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_transaction_deleted_at", + on: ["deleted_at"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + { + name: "IDX_order_transaction_order_id_version", + on: ["order_id", "version"], + unique: false, + where: "deleted_at IS NOT NULL", + }, + ]) + +export const OrderTransaction = _OrderTransaction as DmlEntity< + DMLEntitySchemaBuilder<(typeof _OrderTransaction)["schema"]>, + "OrderTransaction" +> diff --git a/packages/modules/order/src/services/actions/create-claim.ts b/packages/modules/order/src/services/actions/create-claim.ts index 6782806e6cb9d..25a00e90e4e5c 100644 --- a/packages/modules/order/src/services/actions/create-claim.ts +++ b/packages/modules/order/src/services/actions/create-claim.ts @@ -11,11 +11,12 @@ import { getShippingMethodsTotals, isString, promiseAll, + toMikroORMEntity, } from "@medusajs/framework/utils" import { OrderClaim, OrderClaimItem, Return, ReturnItem } from "@models" function createClaimAndReturnEntities(em, data, order) { - const claimReference = em.create(OrderClaim, { + const claimReference = em.create(toMikroORMEntity(OrderClaim), { order_id: data.order_id, order_version: order.version, type: data.type as ClaimType, @@ -25,16 +26,16 @@ function createClaimAndReturnEntities(em, data, order) { const returnReference = data.type === ClaimType.REPLACE - ? em.create(Return, { + ? em.create(toMikroORMEntity(Return), { order_id: data.order_id, order_version: order.version, status: ReturnStatus.REQUESTED, - claim_id: claimReference.id, + claim: claimReference.id, refund_amount: (data.refund_amount as unknown) ?? null, }) : undefined - claimReference.return_id = returnReference?.id + claimReference.return = returnReference?.id return { claimReference, returnReference } } @@ -51,7 +52,7 @@ function createReturnItem(em, item, claimReference, returnReference, actions) { }, }) - return em.create(ReturnItem, { + return em.create(toMikroORMEntity(ReturnItem), { item_id: item.id, return_id: returnReference.id, quantity: item.quantity, @@ -67,7 +68,7 @@ function createClaimAndReturnItems( returnReference, actions ) { - const returnItems: ReturnItem[] = [] + const returnItems: (typeof ReturnItem)[] = [] const claimItems = data.claim_items?.map((item) => { actions.push({ action: ChangeActionType.WRITE_OFF_ITEM, @@ -86,7 +87,7 @@ function createClaimAndReturnItems( : undefined ) - return em.create(OrderClaimItem, { + return em.create(toMikroORMEntity(OrderClaimItem), { item_id: item.id, reason: item.reason, quantity: item.quantity, @@ -108,8 +109,8 @@ async function processAdditionalItems( sharedContext ) { const itemsToAdd: any[] = [] - const additionalNewItems: OrderClaimItem[] = [] - const additionalItems: OrderClaimItem[] = [] + const additionalNewItems: any[] = [] + const additionalItems: any[] = [] data.additional_items?.forEach((item) => { const hasItem = item.id ? order.items.find((o) => o.item.id === item.id) @@ -131,7 +132,7 @@ async function processAdditionalItems( }) additionalItems.push( - em.create(OrderClaimItem, { + em.create(toMikroORMEntity(OrderClaimItem), { item_id: item.id, quantity: item.quantity, note: item.note, @@ -143,7 +144,7 @@ async function processAdditionalItems( itemsToAdd.push(item) additionalNewItems.push( - em.create(OrderClaimItem, { + em.create(toMikroORMEntity(OrderClaimItem), { quantity: item.quantity, unit_price: item.unit_price, note: item.note, diff --git a/packages/modules/order/src/services/actions/create-exchange.ts b/packages/modules/order/src/services/actions/create-exchange.ts index 97c95c103e5c5..389a52e4a353c 100644 --- a/packages/modules/order/src/services/actions/create-exchange.ts +++ b/packages/modules/order/src/services/actions/create-exchange.ts @@ -10,11 +10,12 @@ import { getShippingMethodsTotals, isString, promiseAll, + toMikroORMEntity, } from "@medusajs/framework/utils" import { OrderExchange, OrderExchangeItem, Return, ReturnItem } from "@models" function createExchangeAndReturnEntities(em, data, order) { - const exchangeReference = em.create(OrderExchange, { + const exchangeReference = em.create(toMikroORMEntity(OrderExchange), { order_id: data.order_id, order_version: order.version, no_notification: data.no_notification, @@ -22,7 +23,7 @@ function createExchangeAndReturnEntities(em, data, order) { difference_due: data.difference_due, }) - const returnReference = em.create(Return, { + const returnReference = em.create(toMikroORMEntity(Return), { order_id: data.order_id, order_version: order.version, status: ReturnStatus.REQUESTED, @@ -30,7 +31,7 @@ function createExchangeAndReturnEntities(em, data, order) { refund_amount: (data.refund_amount as unknown) ?? null, }) - exchangeReference.return_id = returnReference.id + exchangeReference.return = returnReference return { exchangeReference, returnReference } } @@ -54,7 +55,7 @@ function createReturnItems( }, }) - return em.create(ReturnItem, { + return em.create(toMikroORMEntity(ReturnItem), { item_id: item.id, return_id: returnReference.id, reason: item.reason, @@ -75,8 +76,8 @@ async function processAdditionalItems( sharedContext ) { const itemsToAdd: any[] = [] - const additionalNewItems: OrderExchangeItem[] = [] - const additionalItems: OrderExchangeItem[] = [] + const additionalNewItems: any[] = [] + const additionalItems: any[] = [] data.additional_items?.forEach((item) => { const hasItem = item.id ? order.items.find((o) => o.item.id === item.id) @@ -98,7 +99,7 @@ async function processAdditionalItems( }) additionalItems.push( - em.create(OrderExchangeItem, { + em.create(toMikroORMEntity(OrderExchangeItem), { item_id: item.id, quantity: item.quantity, note: item.note, @@ -110,7 +111,7 @@ async function processAdditionalItems( itemsToAdd.push(item) additionalNewItems.push( - em.create(OrderExchangeItem, { + em.create(toMikroORMEntity(OrderExchangeItem), { quantity: item.quantity, unit_price: item.unit_price, note: item.note, @@ -313,6 +314,5 @@ export async function createExchange( this.createOrderExchanges([exchangeReference], sharedContext), this.confirmOrderChange(change[0].id, sharedContext), ]) - return exchangeReference } diff --git a/packages/modules/order/src/services/actions/create-return.ts b/packages/modules/order/src/services/actions/create-return.ts index ceedb5776fc8a..400093ceb5166 100644 --- a/packages/modules/order/src/services/actions/create-return.ts +++ b/packages/modules/order/src/services/actions/create-return.ts @@ -11,11 +11,12 @@ import { isDefined, isString, promiseAll, + toMikroORMEntity, } from "@medusajs/framework/utils" import { Return, ReturnItem } from "@models" function createReturnReference(em, data, order) { - return em.create(Return, { + return em.create(toMikroORMEntity(Return), { order_id: data.order_id, order_version: order.version, status: ReturnStatus.REQUESTED, @@ -39,7 +40,7 @@ function createReturnItems(em, data, returnRef, actions) { }, }) - return em.create(ReturnItem, { + return em.create(toMikroORMEntity(ReturnItem), { reason_id: item.reason_id, return_id: returnRef.id, item_id: item.id, diff --git a/packages/modules/order/src/services/actions/receive-return.ts b/packages/modules/order/src/services/actions/receive-return.ts index 142adde8d0cb1..f5cf8cd6b2a2b 100644 --- a/packages/modules/order/src/services/actions/receive-return.ts +++ b/packages/modules/order/src/services/actions/receive-return.ts @@ -85,7 +85,7 @@ export async function receiveReturn( data.return_id, { select: ["id", "order_id"], - relations: ["items"], + relations: ["items", "items.item"], }, sharedContext ) diff --git a/packages/modules/order/src/services/order-module-service.ts b/packages/modules/order/src/services/order-module-service.ts index e27a20fdb6f4d..b1b084d465bdf 100644 --- a/packages/modules/order/src/services/order-module-service.ts +++ b/packages/modules/order/src/services/order-module-service.ts @@ -4,6 +4,7 @@ import { DAL, FilterableOrderReturnReasonProps, FindConfig, + InferEntityType, InternalModuleDeclaration, IOrderModuleService, ModuleJoinerConfig, @@ -37,8 +38,10 @@ import { OrderChangeStatus, OrderStatus, promiseAll, + toMikroORMEntity, transformPropertiesToBigNumber, } from "@medusajs/framework/utils" +import { BeforeCreate, OnInit, rel } from "@mikro-orm/core" import { Order, OrderAddress, @@ -136,32 +139,56 @@ const generateMethodForModels = { OrderCreditLine, } +{ + const MikroORMEntity = toMikroORMEntity(OrderChangeAction) + MikroORMEntity.prototype["onInit_OrderChangeAction"] = function () { + this.version ??= this.order_change?.version ?? null + + this.order_id ??= this.order_change?.order_id ?? null + this.claim_id ??= this.order_change?.claim_id ?? null + this.exchange_id ??= this.order_change?.exchange_id ?? null + + if (!this.claim_id && !this.exchange_id) { + this.return_id = this.return?.id ?? this.order_change?.return_id ?? null + } + } + OnInit()(MikroORMEntity.prototype, "onInit_OrderChangeAction") + BeforeCreate()(MikroORMEntity.prototype, "onInit_OrderChangeAction") +} +{ + const MikroORMEntity = toMikroORMEntity(OrderShipping) + MikroORMEntity.prototype["onInit_OrderShipping"] = function () { + this.version ??= this.order?.version ?? null + + this.order ??= rel(toMikroORMEntity(Order), this.order?.id ?? null) + this.return ??= rel(toMikroORMEntity(Return), this.return?.id ?? null) + this.claim ??= rel(toMikroORMEntity(OrderClaim), this.claim?.id ?? null) + this.exchange ??= rel( + toMikroORMEntity(OrderExchange), + this.exchange?.id ?? null + ) + this.shipping_method ??= rel( + toMikroORMEntity(OrderShippingMethod), + this.shipping_method?.id ?? null + ) + } + OnInit()(MikroORMEntity.prototype, "onInit_OrderShipping") + BeforeCreate()(MikroORMEntity.prototype, "onInit_OrderShipping") +} +{ + const MikroORMEntity = toMikroORMEntity(OrderItem) + MikroORMEntity.prototype["onInit_OrderItem"] = function () { + this.version ??= this.order?.version ?? null + + this.order ??= rel(toMikroORMEntity(Order), this.order?.id ?? null) + this.item ??= rel(toMikroORMEntity(OrderLineItem), this.item?.id ?? null) + } + OnInit()(MikroORMEntity.prototype, "onInit_OrderItem") + BeforeCreate()(MikroORMEntity.prototype, "onInit_OrderItem") +} + // TODO: rm template args here, keep it for later to not collide with carlos work at least as little as possible -export default class OrderModuleService< - TOrder extends Order = Order, - TAddress extends OrderAddress = OrderAddress, - TLineItem extends OrderLineItem = OrderLineItem, - TLineItemAdjustment extends OrderLineItemAdjustment = OrderLineItemAdjustment, - TLineItemTaxLine extends OrderLineItemTaxLine = OrderLineItemTaxLine, - TOrderShippingMethodAdjustment extends OrderShippingMethodAdjustment = OrderShippingMethodAdjustment, - TOrderShippingMethodTaxLine extends OrderShippingMethodTaxLine = OrderShippingMethodTaxLine, - TOrderShippingMethod extends OrderShippingMethod = OrderShippingMethod, - TOrderTransaction extends OrderTransaction = OrderTransaction, - TOrderChange extends OrderChange = OrderChange, - TOrderChangeAction extends OrderChangeAction = OrderChangeAction, - TOrderItem extends OrderItem = OrderItem, - TOrderSummary extends OrderSummary = OrderSummary, - TOrderShipping extends OrderShipping = OrderShipping, - TReturnReason extends ReturnReason = ReturnReason, - TReturn extends Return = Return, - TReturnItem extends ReturnItem = ReturnItem, - TClaim extends OrderClaim = OrderClaim, - TClaimItem extends OrderClaimItem = OrderClaimItem, - TClaimItemImage extends OrderClaimItemImage = OrderClaimItemImage, - TExchange extends OrderExchange = OrderExchange, - TExchangeItem extends OrderExchangeItem = OrderExchangeItem, - TCreditLine extends OrderCreditLine = OrderCreditLine - > +export default class OrderModuleService extends ModulesSdkUtils.MedusaService<{ Order: { dto: OrderTypes.OrderDTO } OrderAddress: { dto: OrderTypes.OrderAddressDTO } @@ -195,27 +222,69 @@ export default class OrderModuleService< { protected baseRepository_: DAL.RepositoryService protected orderService_: OrderService - protected orderAddressService_: ModulesSdkTypes.IMedusaInternalService - protected orderLineItemService_: ModulesSdkTypes.IMedusaInternalService - protected orderShippingMethodAdjustmentService_: ModulesSdkTypes.IMedusaInternalService - protected orderShippingMethodService_: ModulesSdkTypes.IMedusaInternalService - protected orderLineItemAdjustmentService_: ModulesSdkTypes.IMedusaInternalService - protected orderLineItemTaxLineService_: ModulesSdkTypes.IMedusaInternalService - protected orderShippingMethodTaxLineService_: ModulesSdkTypes.IMedusaInternalService - protected orderTransactionService_: ModulesSdkTypes.IMedusaInternalService - protected orderChangeService_: ModulesSdkTypes.IMedusaInternalService - protected orderChangeActionService_: ModulesSdkTypes.IMedusaInternalService - protected orderItemService_: ModulesSdkTypes.IMedusaInternalService - protected orderSummaryService_: ModulesSdkTypes.IMedusaInternalService - protected orderShippingService_: ModulesSdkTypes.IMedusaInternalService - protected returnReasonService_: ModulesSdkTypes.IMedusaInternalService - protected returnService_: ModulesSdkTypes.IMedusaInternalService - protected returnItemService_: ModulesSdkTypes.IMedusaInternalService - protected orderClaimService_: ModulesSdkTypes.IMedusaInternalService - protected orderClaimItemService_: ModulesSdkTypes.IMedusaInternalService - protected orderClaimItemImageService_: ModulesSdkTypes.IMedusaInternalService - protected orderExchangeService_: ModulesSdkTypes.IMedusaInternalService - protected orderExchangeItemService_: ModulesSdkTypes.IMedusaInternalService + protected orderAddressService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderLineItemService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderShippingMethodAdjustmentService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderShippingMethodService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderLineItemAdjustmentService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderLineItemTaxLineService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderShippingMethodTaxLineService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderTransactionService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderChangeService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderChangeActionService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderItemService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderSummaryService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderShippingService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected returnReasonService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected returnService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected returnItemService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderClaimService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderClaimItemService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderClaimItemImageService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderExchangeService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > + protected orderExchangeItemService_: ModulesSdkTypes.IMedusaInternalService< + InferEntityType + > constructor( { @@ -640,9 +709,11 @@ export default class OrderModuleService< data: OrderTypes.CreateOrderDTO[], @MedusaContext() sharedContext: Context = {} ) { + await this.createOrderAddresses_(data, sharedContext) + const lineItemsToCreate: CreateOrderLineItemDTO[] = [] - const createdOrders: Order[] = [] + const createdOrders: InferEntityType[] = [] for (const { items, shipping_methods, ...order } of data) { const ord = order as any @@ -693,6 +764,52 @@ export default class OrderModuleService< return createdOrders } + @InjectTransactionManager() + protected async createOrderAddresses_( + input: OrderTypes.CreateOrderDTO[], + @MedusaContext() sharedContext: Context = {} + ) { + const allAddresses: { + data: any + type: "billing" | "shipping" + source: OrderTypes.CreateOrderDTO + }[] = [] + + input.forEach((inputData) => { + if (inputData.billing_address) { + allAddresses.push({ + data: inputData.billing_address, + type: "billing", + source: inputData, + }) + } + + if (inputData.shipping_address) { + allAddresses.push({ + data: inputData.shipping_address, + type: "shipping", + source: inputData, + }) + } + }) + + const createdAddresses = allAddresses.length + ? await this.orderAddressService_.create( + allAddresses.map((a) => a.data), + sharedContext + ) + : [] + + createdAddresses.forEach((createdAddress, index) => { + const { type, source } = allAddresses[index] + if (type === "billing") { + source.billing_address_id = createdAddress.id + } else if (type === "shipping") { + source.shipping_address_id = createdAddress.id + } + }) + } + // @ts-expect-error async updateOrders( data: OrderTypes.UpdateOrderDTO[] @@ -794,7 +911,7 @@ export default class OrderModuleService< | OrderTypes.CreateOrderLineItemDTO, @MedusaContext() sharedContext: Context = {} ): Promise { - let items: OrderLineItem[] = [] + let items: InferEntityType[] = [] if (isString(orderIdOrData)) { items = await this.createOrderLineItems_( orderIdOrData, @@ -840,7 +957,7 @@ export default class OrderModuleService< orderId: string, items: OrderTypes.CreateOrderLineItemDTO[], @MedusaContext() sharedContext: Context = {} - ): Promise { + ): Promise[]> { const order = await this.retrieveOrder( orderId, { select: ["id", "version"] }, @@ -862,7 +979,7 @@ export default class OrderModuleService< protected async createOrderLineItemsBulk_( data: CreateOrderLineItemDTO[], @MedusaContext() sharedContext: Context = {} - ): Promise { + ): Promise[]> { const orderItemToCreate: CreateOrderItemDTO[] = [] const lineItems = await this.orderLineItemService_.create( @@ -917,7 +1034,7 @@ export default class OrderModuleService< | Partial, @MedusaContext() sharedContext: Context = {} ): Promise { - let items: OrderLineItem[] = [] + let items: InferEntityType[] = [] if (isString(lineItemIdOrDataOrSelector)) { const item = await this.updateOrderLineItem_( lineItemIdOrDataOrSelector, @@ -960,7 +1077,7 @@ export default class OrderModuleService< lineItemId: string, data: Partial, @MedusaContext() sharedContext: Context = {} - ): Promise { + ): Promise> { const [item] = await this.orderLineItemService_.update( [{ id: lineItemId, ...data }], sharedContext @@ -985,7 +1102,7 @@ export default class OrderModuleService< protected async updateOrderLineItemsWithSelector_( updates: OrderTypes.UpdateOrderLineItemWithSelectorDTO[], @MedusaContext() sharedContext: Context = {} - ): Promise { + ): Promise[]> { let toUpdate: UpdateOrderLineItemDTO[] = [] const detailsToUpdate: UpdateOrderItemWithSelectorDTO[] = [] for (const { selector, data } of updates) { @@ -1039,7 +1156,7 @@ export default class OrderModuleService< | Partial, @MedusaContext() sharedContext: Context = {} ): Promise { - let items: OrderItem[] = [] + let items: InferEntityType[] = [] if (isString(orderItemIdOrDataOrSelector)) { const item = await this.updateOrderItem_( orderItemIdOrDataOrSelector, @@ -1079,7 +1196,7 @@ export default class OrderModuleService< orderItemId: string, data: Partial, @MedusaContext() sharedContext: Context = {} - ): Promise { + ): Promise> { const [detail] = await this.orderItemService_.update( [{ id: orderItemId, ...data }], sharedContext @@ -1092,7 +1209,7 @@ export default class OrderModuleService< protected async updateOrderItemWithSelector_( updates: OrderTypes.UpdateOrderItemWithSelectorDTO[], @MedusaContext() sharedContext: Context = {} - ): Promise { + ): Promise[]> { let toUpdate: UpdateOrderItemDTO[] = [] for (const { selector, data } of updates) { const details = await this.listOrderItems( @@ -1136,7 +1253,7 @@ export default class OrderModuleService< ): Promise< OrderTypes.OrderShippingMethodDTO[] | OrderTypes.OrderShippingMethodDTO > { - let methods: OrderShippingMethod[] + let methods: InferEntityType[] if (isString(orderIdOrData)) { methods = await this.createOrderShippingMethods_( orderIdOrData, @@ -1186,7 +1303,7 @@ export default class OrderModuleService< orderId: string, data: CreateOrderShippingMethodDTO[], @MedusaContext() sharedContext: Context = {} - ): Promise { + ): Promise[]> { const order = await this.retrieveOrder( orderId, { select: ["id", "version"] }, @@ -1215,13 +1332,10 @@ export default class OrderModuleService< version: number }[], @MedusaContext() sharedContext: Context = {} - ): Promise { - const sm = await this.orderShippingService_.create( - data as unknown as CreateOrderShippingMethodDTO[], - sharedContext - ) + ): Promise[]> { + const sm = await this.orderShippingService_.create(data, sharedContext) - return sm.map((s) => s.shipping_method) + return sm.map((s) => s.shipping_method) as any } @InjectManager() @@ -1298,7 +1412,7 @@ export default class OrderModuleService< adjustments?: OrderTypes.CreateOrderLineItemAdjustmentDTO[], @MedusaContext() sharedContext: Context = {} ): Promise { - let addedAdjustments: OrderLineItemAdjustment[] = [] + let addedAdjustments: InferEntityType[] = [] if (isString(orderIdOrData)) { const order = await this.retrieveOrder( orderIdOrData, @@ -1471,7 +1585,9 @@ export default class OrderModuleService< | OrderTypes.OrderShippingMethodAdjustmentDTO[] | OrderTypes.OrderShippingMethodAdjustmentDTO > { - let addedAdjustments: OrderShippingMethodAdjustment[] = [] + let addedAdjustments: InferEntityType< + typeof OrderShippingMethodAdjustment + >[] = [] if (isString(orderIdOrData)) { const order = await this.retrieveOrder( orderIdOrData, @@ -1551,7 +1667,7 @@ export default class OrderModuleService< ): Promise< OrderTypes.OrderLineItemTaxLineDTO[] | OrderTypes.OrderLineItemTaxLineDTO > { - let addedTaxLines: OrderLineItemTaxLine[] + let addedTaxLines: InferEntityType[] if (isString(orderIdOrData)) { const lines = Array.isArray(taxLines) ? taxLines : [taxLines] @@ -1663,7 +1779,7 @@ export default class OrderModuleService< | OrderTypes.OrderShippingMethodTaxLineDTO[] | OrderTypes.OrderShippingMethodTaxLineDTO > { - let addedTaxLines: OrderShippingMethodTaxLine[] + let addedTaxLines: InferEntityType[] if (isString(orderIdOrData)) { const lines = Array.isArray(taxLines) ? taxLines : [taxLines] @@ -1905,7 +2021,7 @@ export default class OrderModuleService< protected async createOrderChange_( data: CreateOrderChangeDTO | CreateOrderChangeDTO[], @MedusaContext() sharedContext?: Context - ): Promise { + ): Promise[]> { const dataArr = Array.isArray(data) ? data : [data] const orderIds: string[] = [] const dataMap: Record = {} @@ -1955,7 +2071,7 @@ export default class OrderModuleService< return { ...dataMap[order.id], - version: order.version + 1, + version: order.version! + 1, } as any }) @@ -2002,7 +2118,9 @@ export default class OrderModuleService< quantity: item.detail?.quantity ?? item.quantity, unit_price: item.detail?.unit_price || item.unit_price, compare_at_unit_price: - item.detail?.compare_at_unit_price || item.compare_at_unit_price, + item.detail?.compare_at_unit_price || + item.compare_at_unit_price || + null, } } } @@ -2032,6 +2150,7 @@ export default class OrderModuleService< const actions = item.actions delete item.actions + //@ts-ignore const newItem = itemsToUpsert.find((d) => d.item_id === item.id)! const unitPrice = newItem?.unit_price ?? item.unit_price const compareAtUnitPrice = @@ -2042,7 +2161,7 @@ export default class OrderModuleService< actions, quantity: newItem.quantity, unit_price: unitPrice, - compare_at_unit_price: compareAtUnitPrice, + compare_at_unit_price: compareAtUnitPrice || null, detail: { ...newItem, ...item, @@ -2284,9 +2403,9 @@ export default class OrderModuleService< applied: true, }, ], - })) as CreateOrderChangeDTO[], + })), sharedContext - )) as OrderTypes.OrderChangeDTO[] + )) as unknown as OrderTypes.OrderChangeDTO[] return Array.isArray(data) ? changes : changes[0] } @@ -2338,7 +2457,7 @@ export default class OrderModuleService< ) return await this.applyOrderChanges_( - changes as ApplyOrderChangeDTO[], + changes as unknown as ApplyOrderChangeDTO[], sharedContext ) } @@ -2745,6 +2864,7 @@ export default class OrderModuleService< data: OrderTypes.CreateOrderChangeActionDTO[], sharedContext?: Context ): Promise + @InjectTransactionManager() async addOrderAction( data: @@ -2786,7 +2906,8 @@ export default class OrderModuleService< const actions = (await this.orderChangeActionService_.create( dataArr, sharedContext - )) as OrderTypes.OrderChangeActionDTO[] + )) as unknown as OrderTypes.OrderChangeActionDTO[] + return Array.isArray(data) ? actions : actions[0] } @@ -2836,10 +2957,10 @@ export default class OrderModuleService< "items.detail", "shipping_methods", ], - } - // sharedContext - // TODO: investigate issue while using sharedContext in receive return action + }, + sharedContext ) + orders = formatOrder(orders, { entity: Order, }) as OrderDTO[] @@ -2922,10 +3043,10 @@ export default class OrderModuleService< } } - const created = await this.orderTransactionService_.create( + const created = (await this.orderTransactionService_.create( data, sharedContext - ) + )) as (InferEntityType & { order_id: string })[] await this.updateOrderPaidRefundableAmount_(created, false, sharedContext) @@ -3281,6 +3402,7 @@ export default class OrderModuleService< return await this.retrieveReturn(ret.id, { relations: [ "items", + "items.item", "shipping_methods", "shipping_methods.tax_lines", "shipping_methods.adjustments", @@ -3390,7 +3512,7 @@ export default class OrderModuleService< ): Promise { const ret = await this.createExchange_(data, sharedContext) - const claim = await this.retrieveOrderExchange( + const exchange = await this.retrieveOrderExchange( ret.id, { relations: [ @@ -3408,7 +3530,7 @@ export default class OrderModuleService< ) return await this.baseRepository_.serialize( - claim, + exchange, { populate: true, } diff --git a/packages/modules/order/src/services/order-service.ts b/packages/modules/order/src/services/order-service.ts index 2254d0373b925..515a1157597e9 100644 --- a/packages/modules/order/src/services/order-service.ts +++ b/packages/modules/order/src/services/order-service.ts @@ -2,6 +2,7 @@ import { Context, DAL, FindConfig, + InferEntityType, OrderTypes, RepositoryService, } from "@medusajs/framework/types" @@ -19,9 +20,11 @@ type InjectedDependencies = { export default class OrderService extends ModulesSdkUtils.MedusaInternalService< InjectedDependencies, - Order + InferEntityType >(Order) { - protected readonly orderRepository_: RepositoryService + protected readonly orderRepository_: RepositoryService< + InferEntityType + > constructor(container: InjectedDependencies) { // @ts-ignore @@ -35,10 +38,10 @@ export default class OrderService extends ModulesSdkUtils.MedusaInternalService< version: number, config: FindConfig = {}, @MedusaContext() sharedContext: Context = {} - ): Promise { - const queryConfig = ModulesSdkUtils.buildQuery( + ): Promise { + const queryConfig = ModulesSdkUtils.buildQuery( { id, items: { version } }, - { ...config, take: 1 } + { ...config, take: 1 } as any ) const [result] = await this.orderRepository_.find( queryConfig, diff --git a/packages/modules/order/src/utils/apply-order-changes.ts b/packages/modules/order/src/utils/apply-order-changes.ts index 4d095d84b28d3..f5a2b5a302dc2 100644 --- a/packages/modules/order/src/utils/apply-order-changes.ts +++ b/packages/modules/order/src/utils/apply-order-changes.ts @@ -1,4 +1,7 @@ -import { OrderChangeActionDTO } from "@medusajs/framework/types" +import { + InferEntityType, + OrderChangeActionDTO, +} from "@medusajs/framework/types" import { ChangeActionType, MathBN, @@ -22,8 +25,9 @@ export function applyChangesToOrder( addActionReferenceToObject?: boolean } ) { - const itemsToUpsert: OrderItem[] = [] - const shippingMethodsToUpsert: OrderShippingMethod[] = [] + const itemsToUpsert: InferEntityType[] = [] + const shippingMethodsToUpsert: InferEntityType[] = + [] const summariesToUpsert: any[] = [] const orderToUpdate: any[] = [] @@ -69,7 +73,7 @@ export function applyChangesToOrder( const orderItem = isExistingItem ? (item.detail as any) : item const itemId = isExistingItem ? orderItem.item_id : item.id - itemsToUpsert.push({ + const itemToUpsert = { id: orderItem.version === version ? orderItem.id : undefined, item_id: itemId, order_id: order.id, @@ -86,7 +90,9 @@ export function applyChangesToOrder( return_dismissed_quantity: orderItem.return_dismissed_quantity ?? 0, written_off_quantity: orderItem.written_off_quantity ?? 0, metadata: orderItem.metadata, - } as OrderItem) + } as any + + itemsToUpsert.push(itemToUpsert) } const orderSummary = order.summary as any diff --git a/packages/modules/order/src/utils/base-repository-find.ts b/packages/modules/order/src/utils/base-repository-find.ts index 7055f57659940..ec514ae78e249 100644 --- a/packages/modules/order/src/utils/base-repository-find.ts +++ b/packages/modules/order/src/utils/base-repository-find.ts @@ -1,4 +1,5 @@ import { Constructor, Context, DAL } from "@medusajs/framework/types" +import { toMikroORMEntity } from "@medusajs/framework/utils" import { LoadStrategy } from "@mikro-orm/core" import { Order, OrderClaim } from "@models" import { mapRepositoryToOrderModel } from "." @@ -15,7 +16,6 @@ export function setFindMethods(klass: Constructor, entity: any) { const findOptions_ = { ...options } as any findOptions_.options ??= {} findOptions_.where ??= {} - findOptions_.populate ??= [] if (!("strategy" in findOptions_.options)) { if (findOptions_.options.limit != null || findOptions_.options.offset) { @@ -29,12 +29,13 @@ export function setFindMethods(klass: Constructor, entity: any) { } } - const isRelatedEntity = entity !== Order + const isRelatedEntity = entity.name !== Order.name + const config = mapRepositoryToOrderModel(findOptions_, isRelatedEntity) config.options ??= {} config.options.populate ??= [] - const strategy = config.options.strategy ?? LoadStrategy.JOINED + const strategy = findOptions_.options.strategy ?? LoadStrategy.JOINED let orderAlias = "o0" if (isRelatedEntity) { if (entity === OrderClaim) { @@ -65,7 +66,7 @@ export function setFindMethods(klass: Constructor, entity: any) { if (strategy === LoadStrategy.SELECT_IN) { const sql = manager - .qb(Order, "_sub0") + .qb(toMikroORMEntity(Order), "_sub0") .select("version") .where({ id: knex.raw(`"${orderAlias}"."order_id"`) }) .getKnexQuery() @@ -74,46 +75,18 @@ export function setFindMethods(klass: Constructor, entity: any) { defaultVersion = knex.raw(`(${sql})`) } - const version = config.where.version ?? defaultVersion + const version = config.where?.version ?? defaultVersion delete config.where?.version - config.options.populateWhere ??= {} - const popWhere = config.options.populateWhere - - if (isRelatedEntity) { - popWhere.order ??= {} - - popWhere.shipping_methods ??= {} - popWhere.shipping_methods.deleted_at ??= null - - popWhere.shipping_methods.shipping_method ??= {} - popWhere.shipping_methods.shipping_method.deleted_at ??= null - } - - const orderWhere = isRelatedEntity ? popWhere.order : popWhere - - orderWhere.summary ??= {} - orderWhere.summary.version = version - - orderWhere.items ??= {} - orderWhere.items.version = version - orderWhere.items.deleted_at ??= null - - orderWhere.shipping_methods ??= {} - orderWhere.shipping_methods.version = version - orderWhere.shipping_methods.deleted_at ??= null - - orderWhere.shipping_methods.shipping_method ??= {} - orderWhere.shipping_methods.shipping_method.deleted_at ??= null + configurePopulateWhere(config, isRelatedEntity, version) if (!config.options.orderBy) { config.options.orderBy = { id: "ASC" } } config.where ??= {} - config.where.deleted_at ??= null - return await manager.find(entity, config.where, config.options) + return await manager.find(this.entity, config.where, config.options) } klass.prototype.findAndCount = async function findAndCount( @@ -134,7 +107,8 @@ export function setFindMethods(klass: Constructor, entity: any) { }) } - const isRelatedEntity = entity !== Order + const isRelatedEntity = entity.name !== Order.name + const config = mapRepositoryToOrderModel(findOptions_, isRelatedEntity) let orderAlias = "o0" @@ -148,7 +122,6 @@ export function setFindMethods(klass: Constructor, entity: any) { } } - // first relation is always order if the entity is not Order const index = config.options.populate.findIndex((p) => p === "order") if (index > -1) { config.options.populate.splice(index, 1) @@ -161,43 +134,107 @@ export function setFindMethods(klass: Constructor, entity: any) { let defaultVersion = knex.raw(`"${orderAlias}"."version"`) const strategy = config.options.strategy ?? LoadStrategy.JOINED if (strategy === LoadStrategy.SELECT_IN) { - const sql = manager - .qb(Order, "_sub0") - .select("version") - .where({ id: knex.raw(`"${orderAlias}"."order_id"`) }) - .getKnexQuery() - .toString() - - defaultVersion = knex.raw(`(${sql})`) + defaultVersion = getVersionSubQuery(manager, orderAlias) } const version = config.where.version ?? defaultVersion delete config.where.version - config.options.populateWhere ??= {} - const popWhere = config.options.populateWhere + configurePopulateWhere( + config, + isRelatedEntity, + version, + strategy === LoadStrategy.SELECT_IN, + manager + ) - if (isRelatedEntity) { - popWhere.order ??= {} + if (!config.options.orderBy) { + config.options.orderBy = { id: "ASC" } } - const orderWhere = isRelatedEntity ? popWhere.order : popWhere + return await manager.findAndCount(this.entity, config.where, config.options) + } +} - orderWhere.summary ??= {} - orderWhere.summary.version = version +function getVersionSubQuery(manager, alias, field = "order_id") { + const knex = manager.getKnex() + const sql = manager + .qb(toMikroORMEntity(Order), "_sub0") + .select("version") + .where({ id: knex.raw(`"${alias}"."${field}"`) }) + .getKnexQuery() + .toString() - orderWhere.items ??= {} - orderWhere.items.version = version - orderWhere.items.deleted_at ??= null + return knex.raw(`(${sql})`) +} - popWhere.shipping_methods ??= {} - popWhere.shipping_methods.version = version - popWhere.shipping_methods.deleted_at ??= null +function configurePopulateWhere( + config: any, + isRelatedEntity: boolean, + version: any, + isSelectIn = false, + manager? +) { + const requestedPopulate = config.options?.populate ?? [] + const hasRelation = (relation: string) => + requestedPopulate.some( + (p) => p === relation || p.startsWith(`${relation}.`) + ) + + config.options.populateWhere ??= {} + const popWhere = config.options.populateWhere + + // isSelectIn && isRelatedEntity - Order is always the FROM clause (field o0.id) + if (isRelatedEntity) { + popWhere.order ??= {} + + const popWhereOrder = popWhere.order + + popWhereOrder.version = isSelectIn + ? getVersionSubQuery(manager, "o0", "id") + : version + + // related entity shipping method + if (hasRelation("shipping_methods")) { + popWhere.shipping_methods ??= {} + popWhere.shipping_methods.version = isSelectIn + ? getVersionSubQuery(manager, "s0") + : version + } - if (!config.options.orderBy) { - config.options.orderBy = { id: "ASC" } + if (hasRelation("items") || hasRelation("order.items")) { + popWhereOrder.items ??= {} + popWhereOrder.items.version = isSelectIn + ? getVersionSubQuery(manager, "o0", "id") + : version } - return await manager.findAndCount(entity, config.where, config.options) + if (hasRelation("shipping_methods")) { + popWhereOrder.shipping_methods ??= {} + popWhereOrder.shipping_methods.version = isSelectIn + ? getVersionSubQuery(manager, "o0", "id") + : version + } + + return + } + + if (isSelectIn) { + version = getVersionSubQuery(manager, "o0") + } + + if (hasRelation("summary")) { + popWhere.summary ??= {} + popWhere.summary.version = version + } + + if (hasRelation("items") || hasRelation("order.items")) { + popWhere.items ??= {} + popWhere.items.version = version + } + + if (hasRelation("shipping_methods")) { + popWhere.shipping_methods ??= {} + popWhere.shipping_methods.version = version } } diff --git a/packages/modules/order/src/utils/transform-order.ts b/packages/modules/order/src/utils/transform-order.ts index 2a65c5a764d6a..59dbba90b3744 100644 --- a/packages/modules/order/src/utils/transform-order.ts +++ b/packages/modules/order/src/utils/transform-order.ts @@ -4,6 +4,7 @@ import { deduplicate, isDefined, isObject, + toMikroORMEntity, } from "@medusajs/framework/utils" // Reshape the order object to match the OrderDTO @@ -20,8 +21,9 @@ export function formatOrder( orders.map((order) => { let mainOrder = order + const entity = options?.entity ? toMikroORMEntity(options.entity) : null - const isRelatedEntity = options?.entity?.name !== "Order" + const isRelatedEntity = entity?.name !== "Order" // If the entity is a related entity, the original order is located in the order property if (isRelatedEntity) { diff --git a/packages/modules/payment/package.json b/packages/modules/payment/package.json index be20bdfdca687..b50602ecd6c84 100644 --- a/packages/modules/payment/package.json +++ b/packages/modules/payment/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/pricing/package.json b/packages/modules/pricing/package.json index ae167f16d61b9..6bb7c2fc81866 100644 --- a/packages/modules/pricing/package.json +++ b/packages/modules/pricing/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/product/integration-tests/__tests__/product.ts b/packages/modules/product/integration-tests/__tests__/product.ts index f6116af5e5f48..0a6f1547a34e0 100644 --- a/packages/modules/product/integration-tests/__tests__/product.ts +++ b/packages/modules/product/integration-tests/__tests__/product.ts @@ -13,10 +13,10 @@ import { ProductDTO, } from "@medusajs/framework/types" import { + kebabCase, Module, Modules, ProductStatus, - kebabCase, toMikroORMEntity, } from "@medusajs/framework/utils" import { moduleIntegrationTestRunner } from "@medusajs/test-utils" @@ -577,7 +577,7 @@ moduleIntegrationTestRunner({ }) it("should filter by collection relation and scope fields", async () => { - const products = await service.list( + const products = await moduleService.listProducts( { id: workingProduct.id, collection_id: workingCollection.id, @@ -593,10 +593,8 @@ moduleIntegrationTestRunner({ } ) - const serialized = JSON.parse(JSON.stringify(products)) - - expect(serialized.length).toEqual(1) - expect(serialized).toEqual([ + expect(products.length).toEqual(1) + expect(products).toEqual([ { id: workingProduct.id, title: workingProduct.title, @@ -612,7 +610,7 @@ moduleIntegrationTestRunner({ }) it("should filter by collection when multiple collection ids are passed", async () => { - const products = await service.list( + const products = await moduleService.listProducts( { collection_id: [workingCollection.id, workingCollectionTwo.id], }, @@ -627,10 +625,8 @@ moduleIntegrationTestRunner({ } ) - const serialized = JSON.parse(JSON.stringify(products)) - - expect(serialized.length).toEqual(2) - expect(serialized).toEqual([ + expect(products.length).toEqual(2) + expect(products).toEqual([ { id: workingProduct.id, title: workingProduct.title, diff --git a/packages/modules/product/package.json b/packages/modules/product/package.json index 4563c4414ac86..a685c52b6b95c 100644 --- a/packages/modules/product/package.json +++ b/packages/modules/product/package.json @@ -29,19 +29,19 @@ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "test:integration": "jest --forceExit", + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "faker": "^5.5.3", @@ -52,9 +52,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/product/src/models/product.ts b/packages/modules/product/src/models/product.ts index f56c5d27c6213..3ad4129ed2bc3 100644 --- a/packages/modules/product/src/models/product.ts +++ b/packages/modules/product/src/models/product.ts @@ -1,12 +1,12 @@ import { model, ProductUtils } from "@medusajs/framework/utils" -import ProductTag from "./product-tag" -import ProductType from "./product-type" +import ProductCategory from "./product-category" +import ProductCollection from "./product-collection" import ProductImage from "./product-image" import ProductOption from "./product-option" +import ProductTag from "./product-tag" +import ProductType from "./product-type" import ProductVariant from "./product-variant" -import ProductCategory from "./product-category" -import ProductCollection from "./product-collection" const Product = model .define("Product", { diff --git a/packages/modules/product/src/repositories/product-category.ts b/packages/modules/product/src/repositories/product-category.ts index e6f1429ff7d29..f395d806d0dd5 100644 --- a/packages/modules/product/src/repositories/product-category.ts +++ b/packages/modules/product/src/repositories/product-category.ts @@ -527,7 +527,10 @@ export class ProductCategoryRepository extends DALUtils.MikroOrmBaseTreeReposito const newMpath = `${newBaseMpath}.${category.id}` category.mpath = newMpath for (let child of category.category_children) { - child = manager.getReference(ProductCategory.name, child.id) + child = manager.getReference( + ProductCategory.name, + child.id + ) as any manager.assign( child, categoryDataChildrenMap.get(child.id) ?? {} diff --git a/packages/modules/product/src/services/product-category.ts b/packages/modules/product/src/services/product-category.ts index b97033b75b83e..df27f4a4bbfbd 100644 --- a/packages/modules/product/src/services/product-category.ts +++ b/packages/modules/product/src/services/product-category.ts @@ -6,7 +6,7 @@ import { ProductTypes, } from "@medusajs/framework/types" import { - FreeTextSearchFilterKey, + FreeTextSearchFilterKeyPrefix, InjectManager, InjectTransactionManager, isDefined, @@ -87,7 +87,7 @@ export default class ProductCategoryService { // Apply free text search filter if (isDefined(filters?.q)) { config.filters ??= {} - config.filters[FreeTextSearchFilterKey] = { + config.filters[FreeTextSearchFilterKeyPrefix + ProductCategory.name] = { value: filters.q, fromEntity: ProductCategory.name, } @@ -121,7 +121,7 @@ export default class ProductCategoryService { // Apply free text search filter if (isDefined(filters?.q)) { config.filters ??= {} - config.filters[FreeTextSearchFilterKey] = { + config.filters[FreeTextSearchFilterKeyPrefix + ProductCategory.name] = { value: filters.q, fromEntity: ProductCategory.name, } diff --git a/packages/modules/promotion/integration-tests/__fixtures__/campaigns/index.ts b/packages/modules/promotion/integration-tests/__fixtures__/campaigns/index.ts index f7e9298e9ef82..ad483cd1fc5ab 100644 --- a/packages/modules/promotion/integration-tests/__fixtures__/campaigns/index.ts +++ b/packages/modules/promotion/integration-tests/__fixtures__/campaigns/index.ts @@ -1,15 +1,35 @@ import { CreateCampaignDTO } from "@medusajs/framework/types" +import { toMikroORMEntity } from "@medusajs/framework/utils" import { SqlEntityManager } from "@mikro-orm/postgresql" import { Campaign } from "@models" import { defaultCampaignsData } from "./data" -import { toMikroORMEntity } from "@medusajs/framework/utils" export * from "./data" +const TODAY = new Date() export async function createCampaigns( manager: SqlEntityManager, - campaignsData: CreateCampaignDTO[] = defaultCampaignsData + campaignsData?: CreateCampaignDTO[] ): Promise { + if (!campaignsData) { + const cp = JSON.parse(JSON.stringify(defaultCampaignsData)) + + const starts_at = new Date(TODAY) + starts_at.setDate(starts_at.getDate() - 1) + starts_at.setMonth(starts_at.getMonth() - 1) + + const ends_at = new Date(TODAY) + ends_at.setDate(ends_at.getDate() - 1) + ends_at.setMonth(ends_at.getMonth() - 1) + ends_at.setFullYear(ends_at.getFullYear() + 1) + + for (const data of cp) { + data.starts_at = starts_at + data.ends_at = ends_at + } + + campaignsData = cp + } const campaigns: Campaign[] = [] for (let campaignData of campaignsData) { diff --git a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/compute-actions.spec.ts b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/compute-actions.spec.ts index b920fd674e8f9..68fd15fab5cf9 100644 --- a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/compute-actions.spec.ts +++ b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/compute-actions.spec.ts @@ -18,15 +18,6 @@ moduleIntegrationTestRunner({ service, }: SuiteOptions) => { describe("Promotion Service: computeActions", () => { - beforeAll(() => { - jest.useFakeTimers() - jest.setSystemTime(new Date("02/02/2023")) - }) - - afterAll(() => { - jest.useRealTimers() - }) - beforeEach(async () => { await createCampaigns(MikroOrmWrapper.forkManager()) }) diff --git a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/promotion.spec.ts b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/promotion.spec.ts index 60ab7830dcb7c..763cab0cdbc4c 100644 --- a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/promotion.spec.ts +++ b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/promotion.spec.ts @@ -24,15 +24,6 @@ moduleIntegrationTestRunner({ service, }: SuiteOptions) => { describe("Promotion Service", () => { - beforeAll(() => { - jest.useFakeTimers() - jest.setSystemTime(new Date("02/02/2023")) - }) - - afterAll(() => { - jest.useRealTimers() - }) - beforeEach(async () => { await createCampaigns(MikroOrmWrapper.forkManager()) }) @@ -865,7 +856,6 @@ moduleIntegrationTestRunner({ code: "PROMOTION_1", application_method: { id: expect.any(String), - promotion_id: expect.any(String), type: "fixed", }, }, diff --git a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/register-usage.spec.ts b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/register-usage.spec.ts index 278a97986fe1a..a475706d55fde 100644 --- a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/register-usage.spec.ts +++ b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/register-usage.spec.ts @@ -13,15 +13,6 @@ moduleIntegrationTestRunner({ service, }: SuiteOptions) => { describe("Promotion Service: campaign usage", () => { - beforeAll(() => { - jest.useFakeTimers() - jest.setSystemTime(new Date("02/02/2023")) - }) - - afterAll(() => { - jest.useRealTimers() - }) - beforeEach(async () => { await createCampaigns(MikroOrmWrapper.forkManager()) }) diff --git a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/revert-usage.spec.ts b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/revert-usage.spec.ts index abd5f86777ad2..f848d302975e0 100644 --- a/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/revert-usage.spec.ts +++ b/packages/modules/promotion/integration-tests/__tests__/services/promotion-module/revert-usage.spec.ts @@ -13,15 +13,6 @@ moduleIntegrationTestRunner({ service, }: SuiteOptions) => { describe("Promotion Service: campaign usage", () => { - beforeAll(() => { - jest.useFakeTimers() - jest.setSystemTime(new Date("02/02/2023")) - }) - - afterAll(() => { - jest.useRealTimers() - }) - beforeEach(async () => { await createCampaigns(MikroOrmWrapper.forkManager()) }) diff --git a/packages/modules/promotion/package.json b/packages/modules/promotion/package.json index 888f8c1ac256f..73c66fa2ddbf2 100644 --- a/packages/modules/promotion/package.json +++ b/packages/modules/promotion/package.json @@ -29,19 +29,19 @@ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --passWithNoTests --bail --forceExit -- src", - "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "test:integration": "jest --forceExit ", + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/providers/locking-postgres/package.json b/packages/modules/providers/locking-postgres/package.json index b2ed6456aeeba..832912d525cd8 100644 --- a/packages/modules/providers/locking-postgres/package.json +++ b/packages/modules/providers/locking-postgres/package.json @@ -21,10 +21,10 @@ "license": "MIT", "devDependencies": { "@medusajs/framework": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -41,10 +41,10 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests src", "test:integration": "jest --runInBand --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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "keywords": [ "medusa-providers", diff --git a/packages/modules/region/package.json b/packages/modules/region/package.json index 8fa2d9469b993..e8ce812a10c27 100644 --- a/packages/modules/region/package.json +++ b/packages/modules/region/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --passWithNoTests --bail --forceExit -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/sales-channel/package.json b/packages/modules/sales-channel/package.json index a72e02744e9ba..ee700783550e1 100644 --- a/packages/modules/sales-channel/package.json +++ b/packages/modules/sales-channel/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/stock-location/package.json b/packages/modules/stock-location/package.json index 5d45213d1f2c9..f41b6ba97d77d 100644 --- a/packages/modules/stock-location/package.json +++ b/packages/modules/stock-location/package.json @@ -25,10 +25,10 @@ "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -38,9 +38,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" }, "scripts": { @@ -50,9 +50,9 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --runInBand --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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial -n InitialSetupMigration", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" } } diff --git a/packages/modules/store/package.json b/packages/modules/store/package.json index 50e5a2fa2eff6..ccc05c7edc779 100644 --- a/packages/modules/store/package.json +++ b/packages/modules/store/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/tax/package.json b/packages/modules/tax/package.json index 0fae7c74a6ed9..24d342a0deed2 100644 --- a/packages/modules/tax/package.json +++ b/packages/modules/tax/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.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", - "migration:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -51,9 +51,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/user/package.json b/packages/modules/user/package.json index 34ad48ef7ed0a..7eeaac28a669d 100644 --- a/packages/modules/user/package.json +++ b/packages/modules/user/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --passWithNoTests --bail --forceExit -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -54,9 +54,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/workflow-engine-inmemory/integration-tests/__tests__/index.spec.ts b/packages/modules/workflow-engine-inmemory/integration-tests/__tests__/index.spec.ts index 765d64facacbe..e2fa4d527a92d 100644 --- a/packages/modules/workflow-engine-inmemory/integration-tests/__tests__/index.spec.ts +++ b/packages/modules/workflow-engine-inmemory/integration-tests/__tests__/index.spec.ts @@ -12,9 +12,9 @@ import { Modules, TransactionHandlerType, } from "@medusajs/framework/utils" +import { moduleIntegrationTestRunner } from "@medusajs/test-utils" import { WorkflowsModuleService } from "@services" import { asFunction } from "awilix" -import { moduleIntegrationTestRunner } from "@medusajs/test-utils" import { setTimeout as setTimeoutPromise } from "timers/promises" import "../__fixtures__" import { @@ -332,15 +332,11 @@ moduleIntegrationTestRunner({ describe("Scheduled workflows", () => { beforeEach(() => { - jest.clearAllMocks() - }) - - beforeAll(() => { jest.useFakeTimers() - jest.spyOn(global, "setTimeout") + jest.clearAllMocks() }) - afterAll(() => { + afterEach(() => { jest.useRealTimers() }) @@ -348,11 +344,9 @@ moduleIntegrationTestRunner({ const spy = createScheduled("standard") await jest.runOnlyPendingTimersAsync() - expect(setTimeout).toHaveBeenCalledTimes(2) expect(spy).toHaveBeenCalledTimes(1) await jest.runOnlyPendingTimersAsync() - expect(setTimeout).toHaveBeenCalledTimes(3) expect(spy).toHaveBeenCalledTimes(2) }) diff --git a/packages/modules/workflow-engine-inmemory/package.json b/packages/modules/workflow-engine-inmemory/package.json index 6eb5063e55d22..ca05b4113718a 100644 --- a/packages/modules/workflow-engine-inmemory/package.json +++ b/packages/modules/workflow-engine-inmemory/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src", "test:integration": "jest --silent --forceExit -- integration-tests/**/__tests__/**/*.ts", - "migration:initial": " MIKRO_ORM_CLI=./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:up": " MIKRO_ORM_CLI=./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" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -55,9 +55,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/packages/modules/workflow-engine-redis/package.json b/packages/modules/workflow-engine-redis/package.json index ef986a26cc157..bf01e6094c6a8 100644 --- a/packages/modules/workflow-engine-redis/package.json +++ b/packages/modules/workflow-engine-redis/package.json @@ -30,18 +30,18 @@ "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src", "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:create": " MIKRO_ORM_CLI=./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", - "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" + "migration:initial": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial", + "migration:create": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create", + "migration:up": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up", + "orm:cache:clear": " MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear" }, "devDependencies": { "@medusajs/framework": "^2.3.1", "@medusajs/test-utils": "^2.3.1", - "@mikro-orm/cli": "5.9.7", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/cli": "6.4.3", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "@swc/core": "^1.7.28", "@swc/jest": "^0.2.36", "jest": "^29.7.0", @@ -56,9 +56,9 @@ }, "peerDependencies": { "@medusajs/framework": "^2.0.0", - "@mikro-orm/core": "5.9.7", - "@mikro-orm/migrations": "5.9.7", - "@mikro-orm/postgresql": "5.9.7", + "@mikro-orm/core": "6.4.3", + "@mikro-orm/migrations": "6.4.3", + "@mikro-orm/postgresql": "6.4.3", "awilix": "^8.0.1" } } diff --git a/www/utils/generated/oas-output/schemas/AdminShippingOptionRule.ts b/www/utils/generated/oas-output/schemas/AdminShippingOptionRule.ts index 230d367b3e173..a65354d80a6e6 100644 --- a/www/utils/generated/oas-output/schemas/AdminShippingOptionRule.ts +++ b/www/utils/generated/oas-output/schemas/AdminShippingOptionRule.ts @@ -49,6 +49,5 @@ * format: date-time * title: deleted_at * description: The date the shipping option rule was deleted. - * -*/ - + * + */ diff --git a/yarn.lock b/yarn.lock index dc9310976eff6..3ce0be63b6ddd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5324,7 +5324,7 @@ __metadata: dependencies: "@medusajs/framework": ^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/jest": ^0.2.36 jest: ^29.7.0 @@ -5333,9 +5333,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5395,10 +5395,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5407,9 +5407,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5452,10 +5452,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5464,9 +5464,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5477,10 +5477,10 @@ __metadata: dependencies: "@medusajs/telemetry": ^2.3.1 "@medusajs/utils": 2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 "@types/express": ^4.17.17 @@ -5511,10 +5511,10 @@ __metadata: winston: ^3.8.2 yargs: ^15.3.1 peerDependencies: - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 pg: ^8.13.0 bin: @@ -5527,10 +5527,10 @@ __metadata: resolution: "@medusajs/core-flows@workspace:packages/core/core-flows" dependencies: "@medusajs/framework": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 awilix: ^8.0.1 @@ -5552,10 +5552,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5564,9 +5564,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5577,10 +5577,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5589,9 +5589,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5727,10 +5727,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5755,10 +5755,10 @@ __metadata: "@medusajs/types": ^2.3.1 "@medusajs/utils": ^2.3.1 "@medusajs/workflows-sdk": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@opentelemetry/api": ^1.9.0 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 @@ -5787,11 +5787,11 @@ __metadata: zod: 3.22.4 peerDependencies: "@medusajs/cli": ^2.0.0 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 ioredis: ^5.4.1 pg: ^8.13.0 @@ -5829,10 +5829,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5841,14 +5841,14 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft -"@medusajs/icons@2.3.1, @medusajs/icons@^2.2.0, @medusajs/icons@workspace:packages/design-system/icons": +"@medusajs/icons@2.3.1, @medusajs/icons@^2.3.0, @medusajs/icons@workspace:packages/design-system/icons": version: 0.0.0-use.local resolution: "@medusajs/icons@workspace:packages/design-system/icons" dependencies: @@ -5888,11 +5888,11 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5901,10 +5901,10 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5915,10 +5915,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -5927,9 +5927,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5954,9 +5954,9 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 cross-env: ^5.2.1 @@ -5966,9 +5966,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -5978,10 +5978,10 @@ __metadata: resolution: "@medusajs/locking-postgres@workspace:packages/modules/providers/locking-postgres" dependencies: "@medusajs/framework": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6014,10 +6014,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6026,9 +6026,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6146,10 +6146,10 @@ __metadata: zod: 3.22.4 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 yalc: 1.0.0-pre.53 peerDependenciesMeta: @@ -6165,10 +6165,10 @@ __metadata: "@medusajs/orchestration": ^2.3.1 "@medusajs/types": ^2.3.1 "@medusajs/utils": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 awilix: ^8.0.1 @@ -6178,10 +6178,10 @@ __metadata: rimraf: ^5.0.1 typescript: ^5.6.2 peerDependencies: - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 express: ^4.21.0 pg: ^8.13.0 @@ -6225,10 +6225,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6237,9 +6237,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6259,10 +6259,10 @@ __metadata: dependencies: "@medusajs/types": ^2.3.1 "@medusajs/utils": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 awilix: ^8.0.1 @@ -6271,10 +6271,10 @@ __metadata: rimraf: ^5.0.1 typescript: ^5.6.2 peerDependencies: - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 express: ^4.21.0 pg: ^8.13.0 @@ -6287,10 +6287,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6299,9 +6299,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6329,10 +6329,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6341,9 +6341,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6354,10 +6354,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6366,9 +6366,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6379,10 +6379,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 faker: ^5.5.3 @@ -6392,9 +6392,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6405,10 +6405,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6417,9 +6417,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6430,10 +6430,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6442,9 +6442,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6455,10 +6455,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6467,9 +6467,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6480,10 +6480,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6492,9 +6492,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6505,10 +6505,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6517,9 +6517,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6530,10 +6530,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6542,9 +6542,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6576,10 +6576,10 @@ __metadata: resolution: "@medusajs/test-utils@workspace:packages/medusa-test-utils" dependencies: "@medusajs/framework": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@types/express": ^4.17.17 awilix: ^8.0.1 axios: ^0.21.4 @@ -6594,7 +6594,7 @@ __metadata: peerDependencies: "@medusajs/framework": ^2.0.0 "@medusajs/medusa": ^2.0.0 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 peerDependenciesMeta: "@medusajs/medusa": @@ -6671,7 +6671,7 @@ __metadata: resolution: "@medusajs/ui@workspace:packages/design-system/ui" dependencies: "@faker-js/faker": ^9.2.0 - "@medusajs/icons": ^2.2.0 + "@medusajs/icons": ^2.3.0 "@medusajs/ui-preset": ^2.2.0 "@radix-ui/react-accordion": 1.2.0 "@radix-ui/react-alert-dialog": 1.1.1 @@ -6746,10 +6746,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 jest: ^29.7.0 @@ -6759,9 +6759,9 @@ __metadata: typescript: ^5.6.2 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6775,10 +6775,10 @@ __metadata: "@graphql-tools/merge": ^9.0.7 "@graphql-tools/schema": ^10.0.6 "@medusajs/types": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 "@types/express": ^4.17.21 @@ -6800,10 +6800,10 @@ __metadata: typescript: ^5.6.2 ulid: ^2.3.0 peerDependencies: - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 express: ^4.21.0 pg: ^8.13.0 @@ -6816,10 +6816,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 cron-parser: ^4.9.0 @@ -6830,9 +6830,9 @@ __metadata: ulid: ^2.3.0 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6843,10 +6843,10 @@ __metadata: dependencies: "@medusajs/framework": ^2.3.1 "@medusajs/test-utils": ^2.3.1 - "@mikro-orm/cli": 5.9.7 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/cli": 6.4.3 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 bullmq: 5.13.0 @@ -6858,9 +6858,9 @@ __metadata: ulid: ^2.3.0 peerDependencies: "@medusajs/framework": ^2.0.0 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 languageName: unknown linkType: soft @@ -6873,10 +6873,10 @@ __metadata: "@medusajs/orchestration": ^2.3.1 "@medusajs/types": ^2.3.1 "@medusajs/utils": ^2.3.1 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 "@swc/core": ^1.7.28 "@swc/jest": ^0.2.36 awilix: ^8.0.1 @@ -6886,183 +6886,96 @@ __metadata: typescript: ^5.6.2 ulid: ^2.3.0 peerDependencies: - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - "@mikro-orm/migrations": 5.9.7 - "@mikro-orm/postgresql": 5.9.7 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + "@mikro-orm/migrations": 6.4.3 + "@mikro-orm/postgresql": 6.4.3 awilix: ^8.0.1 express: ^4.21.0 pg: ^8.13.0 languageName: unknown linkType: soft -"@mikro-orm/cli@npm:5.9.7": - version: 5.9.7 - resolution: "@mikro-orm/cli@npm:5.9.7" +"@mikro-orm/cli@npm:6.4.3": + version: 6.4.3 + resolution: "@mikro-orm/cli@npm:6.4.3" dependencies: "@jercle/yargonaut": 1.1.5 - "@mikro-orm/core": 5.9.7 - "@mikro-orm/knex": 5.9.7 - fs-extra: 11.1.1 + "@mikro-orm/core": 6.4.3 + "@mikro-orm/knex": 6.4.3 + fs-extra: 11.2.0 tsconfig-paths: 4.2.0 yargs: 17.7.2 - peerDependencies: - "@mikro-orm/better-sqlite": ^5.0.0 - "@mikro-orm/entity-generator": ^5.0.0 - "@mikro-orm/mariadb": ^5.0.0 - "@mikro-orm/migrations": ^5.0.0 - "@mikro-orm/migrations-mongodb": ^5.0.0 - "@mikro-orm/mongodb": ^5.0.0 - "@mikro-orm/mysql": ^5.0.0 - "@mikro-orm/postgresql": ^5.0.0 - "@mikro-orm/seeder": ^5.0.0 - "@mikro-orm/sqlite": ^5.0.0 - peerDependenciesMeta: - "@mikro-orm/better-sqlite": - optional: true - "@mikro-orm/entity-generator": - optional: true - "@mikro-orm/mariadb": - optional: true - "@mikro-orm/migrations": - optional: true - "@mikro-orm/migrations-mongodb": - optional: true - "@mikro-orm/mongodb": - optional: true - "@mikro-orm/mysql": - optional: true - "@mikro-orm/postgresql": - optional: true - "@mikro-orm/seeder": - optional: true - "@mikro-orm/sqlite": - optional: true bin: - mikro-orm: cli.js - mikro-orm-esm: esm.js - checksum: 2b0f430485ff4e25a0ee53d776a30832d8b53c83db8f70d2d5305039c042384714e9525169e9bfd897f1c9936242aaf80aaf9e9f917c8894517343cc14f56987 + mikro-orm: ./cli + mikro-orm-esm: ./esm + checksum: de49d269d942fad5b3bde9cc4d21d0252a38543e00e70335024c98c1dfbc12fb30ff6271215b998d5a3c56f0c5cc5bab30c0109cda76b47f8b64d81f312c8698 languageName: node linkType: hard -"@mikro-orm/core@npm:5.9.7": - version: 5.9.7 - resolution: "@mikro-orm/core@npm:5.9.7" +"@mikro-orm/core@npm:6.4.3": + version: 6.4.3 + resolution: "@mikro-orm/core@npm:6.4.3" dependencies: - acorn-loose: 8.3.0 - acorn-walk: 8.2.0 - dotenv: 16.3.1 - fs-extra: 11.1.1 + dataloader: 2.2.3 + dotenv: 16.4.7 + esprima: 4.0.1 + fs-extra: 11.2.0 globby: 11.1.0 - mikro-orm: 5.9.7 - reflect-metadata: 0.1.13 - peerDependencies: - "@mikro-orm/better-sqlite": ^5.0.0 - "@mikro-orm/entity-generator": ^5.0.0 - "@mikro-orm/mariadb": ^5.0.0 - "@mikro-orm/migrations": ^5.0.0 - "@mikro-orm/migrations-mongodb": ^5.0.0 - "@mikro-orm/mongodb": ^5.0.0 - "@mikro-orm/mysql": ^5.0.0 - "@mikro-orm/postgresql": ^5.0.0 - "@mikro-orm/seeder": ^5.0.0 - "@mikro-orm/sqlite": ^5.0.0 - peerDependenciesMeta: - "@mikro-orm/better-sqlite": - optional: true - "@mikro-orm/entity-generator": - optional: true - "@mikro-orm/mariadb": - optional: true - "@mikro-orm/migrations": - optional: true - "@mikro-orm/migrations-mongodb": - optional: true - "@mikro-orm/mongodb": - optional: true - "@mikro-orm/mysql": - optional: true - "@mikro-orm/postgresql": - optional: true - "@mikro-orm/seeder": - optional: true - "@mikro-orm/sqlite": - optional: true - checksum: f58ad6b717571b6c9d4f880a886a34f7de51e7d299c93be5ac9b0733c41fdd22278eae14ca5a1e1e7efb045bc36caa83b639745fc0be7b5a696e49b13bdbbd03 + mikro-orm: 6.4.3 + reflect-metadata: 0.2.2 + checksum: d056eb9323a10f940e101a8a95454dcb2c4fa3429517e1a14a1b706869f53e92c2d2d2c9dfe330c02afbef101612787b1184db255ac5d74df5b0df0059928dd2 languageName: node linkType: hard -"@mikro-orm/knex@npm:5.9.7": - version: 5.9.7 - resolution: "@mikro-orm/knex@npm:5.9.7" +"@mikro-orm/knex@npm:6.4.3": + version: 6.4.3 + resolution: "@mikro-orm/knex@npm:6.4.3" dependencies: - fs-extra: 11.1.1 - knex: 2.5.1 + fs-extra: 11.2.0 + knex: 3.1.0 sqlstring: 2.3.3 peerDependencies: - "@mikro-orm/core": ^5.0.0 - "@mikro-orm/entity-generator": ^5.0.0 - "@mikro-orm/migrations": ^5.0.0 + "@mikro-orm/core": ^6.0.0 better-sqlite3: "*" - mssql: "*" - mysql: "*" - mysql2: "*" - pg: "*" - sqlite3: "*" + libsql: "*" + mariadb: "*" peerDependenciesMeta: - "@mikro-orm/entity-generator": - optional: true - "@mikro-orm/migrations": - optional: true better-sqlite3: optional: true - mssql: - optional: true - mysql: - optional: true - mysql2: - optional: true - pg: + libsql: optional: true - sqlite3: + mariadb: optional: true - checksum: 2cce6ef6907d0785e84a9c801980e58ddd3539dbd3dd0b0ced1e3ccddcbc5dfb704816abb97ae7d9c608d6b30d842dd1f59a6ea97ca1d854ebd55df303070500 + checksum: 08dabcf1ea99d6a976892b4973e5de3f4b53e7ed0d3a1e3dcec20dd9349ba5a3ed153bbb96173990cd12367b3744df17f27bb3de751624207592e5d2f6e8637d languageName: node linkType: hard -"@mikro-orm/migrations@npm:5.9.7": - version: 5.9.7 - resolution: "@mikro-orm/migrations@npm:5.9.7" +"@mikro-orm/migrations@npm:6.4.3": + version: 6.4.3 + resolution: "@mikro-orm/migrations@npm:6.4.3" dependencies: - "@mikro-orm/knex": 5.9.7 - fs-extra: 11.1.1 - knex: 2.5.1 - umzug: 3.3.1 + "@mikro-orm/knex": 6.4.3 + fs-extra: 11.2.0 + umzug: 3.8.2 peerDependencies: - "@mikro-orm/core": ^5.0.0 - checksum: 3b1c3e449d2aee7ed7f03153e17e2772423115b895836e4ece40c9b318849d8de9cce1ad9fa545a8ef54fa7fe5ab474c3444e2c598ebc9f3e070fe382882862a + "@mikro-orm/core": ^6.0.0 + checksum: 04e7e2405a3d0d94213f2bf40c34988e190f8f0df5ff4565ef23c750680b198f293247418ee60c0605edfcbca119177f2e87dc01d3e6abfc15ec7c4dc976324a languageName: node linkType: hard -"@mikro-orm/postgresql@npm:5.9.7": - version: 5.9.7 - resolution: "@mikro-orm/postgresql@npm:5.9.7" +"@mikro-orm/postgresql@npm:6.4.3": + version: 6.4.3 + resolution: "@mikro-orm/postgresql@npm:6.4.3" dependencies: - "@mikro-orm/knex": 5.9.7 - pg: 8.11.3 + "@mikro-orm/knex": 6.4.3 + pg: 8.13.1 + postgres-array: 3.0.2 + postgres-date: 2.1.0 + postgres-interval: 4.0.2 peerDependencies: - "@mikro-orm/core": ^5.0.0 - "@mikro-orm/entity-generator": ^5.0.0 - "@mikro-orm/migrations": ^5.0.0 - "@mikro-orm/seeder": ^5.0.0 - peerDependenciesMeta: - "@mikro-orm/entity-generator": - optional: true - "@mikro-orm/migrations": - optional: true - "@mikro-orm/seeder": - optional: true - checksum: 9380c0a5795fe6c25448a5c302877043a0239d25e087a0dec4ebca63e8f06a6af9435953a55141ac8317cb14e2b141df4c10c4615be1a1deecc5cce7127bf42c + "@mikro-orm/core": ^6.0.0 + checksum: c0068dbd8f81d646de1171e9933e1385cd24faedb8a4347b9ab2c24e9bfa19a56cc5a6245aaf84fc8a19b355d02a7f1c160400483aa12411e3487e82b854e12c languageName: node linkType: hard @@ -14845,22 +14758,6 @@ __metadata: languageName: node linkType: hard -"acorn-loose@npm:8.3.0": - version: 8.3.0 - resolution: "acorn-loose@npm:8.3.0" - dependencies: - acorn: ^8.5.0 - checksum: 970f790a584a2f1703a04711cdc588f424fd7bc2fb37ad8e0b9d6ceaf9c8c6a77f9ce102ce5250259fc96aedbdf346546ed1b496299bc13ed4d1b6fdb2d92f61 - languageName: node - linkType: hard - -"acorn-walk@npm:8.2.0": - version: 8.2.0 - resolution: "acorn-walk@npm:8.2.0" - checksum: dbe92f5b2452c93e960c5594e666dd1fae141b965ff2cb4a1e1d0381e3e4db4274c5ce4ffa3d681a86ca2a8d4e29d5efc0670a08e23fd2800051ea387df56ca2 - languageName: node - linkType: hard - "acorn-walk@npm:^6.0.1": version: 6.2.0 resolution: "acorn-walk@npm:6.2.0" @@ -14900,7 +14797,7 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.10.0, acorn@npm:^8.11.3, acorn@npm:^8.4.1, acorn@npm:^8.5.0, acorn@npm:^8.8.2, acorn@npm:^8.9.0": +"acorn@npm:^8.10.0, acorn@npm:^8.11.3, acorn@npm:^8.4.1, acorn@npm:^8.8.2, acorn@npm:^8.9.0": version: 8.11.3 resolution: "acorn@npm:8.11.3" bin: @@ -15966,6 +15863,15 @@ __metadata: languageName: node linkType: hard +"braces@npm:^3.0.3": + version: 3.0.3 + resolution: "braces@npm:3.0.3" + dependencies: + fill-range: ^7.1.1 + checksum: 7c6dfd30c338d2997ba77500539227b9d1f85e388a5f43220865201e407e076783d0881f2d297b9f80951b4c957fcf0b51c1d2d24227631643c3f7c284b0aa04 + languageName: node + linkType: hard + "breakword@npm:^1.0.5": version: 1.0.6 resolution: "breakword@npm:1.0.6" @@ -17954,6 +17860,13 @@ __metadata: languageName: node linkType: hard +"dataloader@npm:2.2.3": + version: 2.2.3 + resolution: "dataloader@npm:2.2.3" + checksum: 9b9a056fbc863ca86da87d59e053e871e263b4966aa4d55e40d61a65e96815fae5530ca220629064ca5f8e3000c0c4ec93292e170c38ff393fb34256b4d7c1aa + languageName: node + linkType: hard + "dataloader@npm:^1.4.0": version: 1.4.0 resolution: "dataloader@npm:1.4.0" @@ -18554,10 +18467,10 @@ __metadata: languageName: node linkType: hard -"dotenv@npm:16.3.1": - version: 16.3.1 - resolution: "dotenv@npm:16.3.1" - checksum: b95ff1bbe624ead85a3cd70dbd827e8e06d5f05f716f2d0cbc476532d54c7c9469c3bc4dd93ea519f6ad711cb522c00ac9a62b6eb340d5affae8008facc3fbd7 +"dotenv@npm:16.4.7": + version: 16.4.7 + resolution: "dotenv@npm:16.4.7" + checksum: be9f597e36a8daf834452daa1f4cc30e5375a5968f98f46d89b16b983c567398a330580c88395069a77473943c06b877d1ca25b4afafcdd6d4adb549e8293462 languageName: node linkType: hard @@ -19852,7 +19765,7 @@ __metadata: languageName: node linkType: hard -"esprima@npm:^4.0.0, esprima@npm:^4.0.1, esprima@npm:~4.0.0": +"esprima@npm:4.0.1, esprima@npm:^4.0.0, esprima@npm:^4.0.1, esprima@npm:~4.0.0": version: 4.0.1 resolution: "esprima@npm:4.0.1" bin: @@ -20317,6 +20230,19 @@ __metadata: languageName: node linkType: hard +"fast-glob@npm:^3.3.2": + version: 3.3.3 + resolution: "fast-glob@npm:3.3.3" + dependencies: + "@nodelib/fs.stat": ^2.0.2 + "@nodelib/fs.walk": ^1.2.3 + glob-parent: ^5.1.2 + merge2: ^1.3.0 + micromatch: ^4.0.8 + checksum: f6aaa141d0d3384cf73cbcdfc52f475ed293f6d5b65bfc5def368b09163a9f7e5ec2b3014d80f733c405f58e470ee0cc451c2937685045cddcdeaa24199c43fe + languageName: node + linkType: hard + "fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0, fast-json-stable-stringify@npm:^2.1.0": version: 2.1.0 resolution: "fast-json-stable-stringify@npm:2.1.0" @@ -20504,6 +20430,15 @@ __metadata: languageName: node linkType: hard +"fill-range@npm:^7.1.1": + version: 7.1.1 + resolution: "fill-range@npm:7.1.1" + dependencies: + to-regex-range: ^5.0.1 + checksum: b75b691bbe065472f38824f694c2f7449d7f5004aa950426a2c28f0306c60db9b880c0b0e4ed819997ffb882d1da02cfcfc819bddc94d71627f5269682edf018 + languageName: node + linkType: hard + "finalhandler@npm:1.2.0": version: 1.2.0 resolution: "finalhandler@npm:1.2.0" @@ -20777,6 +20712,17 @@ __metadata: languageName: node linkType: hard +"fs-extra@npm:11.2.0, fs-extra@npm:^11.1.0, fs-extra@npm:^11.2.0": + version: 11.2.0 + resolution: "fs-extra@npm:11.2.0" + dependencies: + graceful-fs: ^4.2.0 + jsonfile: ^6.0.1 + universalify: ^2.0.0 + checksum: d77a9a9efe60532d2e790e938c81a02c1b24904ef7a3efb3990b835514465ba720e99a6ea56fd5e2db53b4695319b644d76d5a0e9988a2beef80aa7b1da63398 + languageName: node + linkType: hard + "fs-extra@npm:8.1.0, fs-extra@npm:^8.0.1, fs-extra@npm:^8.1, fs-extra@npm:^8.1.0": version: 8.1.0 resolution: "fs-extra@npm:8.1.0" @@ -20799,17 +20745,6 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:^11.1.0, fs-extra@npm:^11.2.0": - version: 11.2.0 - resolution: "fs-extra@npm:11.2.0" - dependencies: - graceful-fs: ^4.2.0 - jsonfile: ^6.0.1 - universalify: ^2.0.0 - checksum: d77a9a9efe60532d2e790e938c81a02c1b24904ef7a3efb3990b835514465ba720e99a6ea56fd5e2db53b4695319b644d76d5a0e9988a2beef80aa7b1da63398 - languageName: node - linkType: hard - "fs-extra@npm:^7.0.1, fs-extra@npm:~7.0.1": version: 7.0.1 resolution: "fs-extra@npm:7.0.1" @@ -21134,7 +21069,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^8.0.3, glob@npm:^8.1.0": +"glob@npm:^8.1.0": version: 8.1.0 resolution: "glob@npm:8.1.0" dependencies: @@ -23868,9 +23803,9 @@ __metadata: languageName: node linkType: hard -"knex@npm:2.5.1": - version: 2.5.1 - resolution: "knex@npm:2.5.1" +"knex@npm:3.1.0": + version: 3.1.0 + resolution: "knex@npm:3.1.0" dependencies: colorette: 2.0.19 commander: ^10.0.0 @@ -23881,7 +23816,7 @@ __metadata: getopts: 2.3.0 interpret: ^2.2.0 lodash: ^4.17.21 - pg-connection-string: 2.6.1 + pg-connection-string: 2.6.2 rechoir: ^0.8.0 resolve-from: ^5.0.0 tarn: ^3.0.2 @@ -23903,7 +23838,7 @@ __metadata: optional: true bin: knex: bin/cli.js - checksum: 33580641feaa93074bdc10e78f06382e5017d46a3cd22821c09057e7da303c35772add39a110fffe685c2f438a78751a0eb6f50aad1c4bdb032e8ec9b7879b69 + checksum: d8a1f99fad143c6057e94759b2ae700ae661a0b0b2385f643011962ef501dcc7b32cfdb5bda66ef81283ca56f13630f47691c579ce66ad0e8128e209533c3785 languageName: node linkType: hard @@ -24949,10 +24884,20 @@ __metadata: languageName: node linkType: hard -"mikro-orm@npm:5.9.7": - version: 5.9.7 - resolution: "mikro-orm@npm:5.9.7" - checksum: 01eb2b71e5f830c064749779d30ed1772e28420cfedeafbbbce8599714eae308af467014001e0404d7ba43de9f1f979a05fd6b267a89c8f7e1e8ec6013fb5120 +"micromatch@npm:^4.0.8": + version: 4.0.8 + resolution: "micromatch@npm:4.0.8" + dependencies: + braces: ^3.0.3 + picomatch: ^2.3.1 + checksum: 166fa6eb926b9553f32ef81f5f531d27b4ce7da60e5baf8c021d043b27a388fb95e46a8038d5045877881e673f8134122b59624d5cecbd16eb50a42e7a6b5ca8 + languageName: node + linkType: hard + +"mikro-orm@npm:6.4.3": + version: 6.4.3 + resolution: "mikro-orm@npm:6.4.3" + checksum: 6d489b7ba8ee9e97545bf035c0d1571e5e00baba4653c24713f4f4703311461f10d467d42f230674049282add6340fc9f33f3e3034827f86d89b5d62b3cc0180 languageName: node linkType: hard @@ -26755,10 +26700,10 @@ __metadata: languageName: node linkType: hard -"pg-connection-string@npm:2.6.1": - version: 2.6.1 - resolution: "pg-connection-string@npm:2.6.1" - checksum: e5a71a2da143b8dc17143a9db7737679b210643771aa678d3bc60c7bc70da11bbb8e2d531be91c8c4eddd6ac6046307811e793f5850b9ba595a11785c948a417 +"pg-connection-string@npm:2.6.2": + version: 2.6.2 + resolution: "pg-connection-string@npm:2.6.2" + checksum: e8fdea74fcc8bdc3d7c5c6eadd9425fdba7e67fb7fe836f9c0cecad94c8984e435256657d1d8ce0483d1fedef667e7a57e32449a63cb805cb0289fc34b62da35 languageName: node linkType: hard @@ -27514,6 +27459,13 @@ __metadata: languageName: node linkType: hard +"postgres-array@npm:3.0.2, postgres-array@npm:~3.0.1": + version: 3.0.2 + resolution: "postgres-array@npm:3.0.2" + checksum: 644aa071f67a66a59f641f8e623887d2b915bc102a32643e2aa8b54c11acd343c5ad97831ea444dd37bd4b921ba35add4aa2cb0c6b76700a8252c2324aeba5b4 + languageName: node + linkType: hard + "postgres-array@npm:~2.0.0": version: 2.0.0 resolution: "postgres-array@npm:2.0.0" @@ -27521,13 +27473,6 @@ __metadata: languageName: node linkType: hard -"postgres-array@npm:~3.0.1": - version: 3.0.2 - resolution: "postgres-array@npm:3.0.2" - checksum: 644aa071f67a66a59f641f8e623887d2b915bc102a32643e2aa8b54c11acd343c5ad97831ea444dd37bd4b921ba35add4aa2cb0c6b76700a8252c2324aeba5b4 - languageName: node - linkType: hard - "postgres-bytea@npm:~1.0.0": version: 1.0.0 resolution: "postgres-bytea@npm:1.0.0" @@ -27544,6 +27489,13 @@ __metadata: languageName: node linkType: hard +"postgres-date@npm:2.1.0, postgres-date@npm:~2.1.0": + version: 2.1.0 + resolution: "postgres-date@npm:2.1.0" + checksum: 00a7472c10788f6b0d08d24108bf1eb80858de1bd6317740198a564918ea4a69b80c98148167b92ae688abd606483020d0de0dd3a36f3ea9a3e26bbeef3464f4 + languageName: node + linkType: hard + "postgres-date@npm:~1.0.4": version: 1.0.7 resolution: "postgres-date@npm:1.0.7" @@ -27551,10 +27503,10 @@ __metadata: languageName: node linkType: hard -"postgres-date@npm:~2.1.0": - version: 2.1.0 - resolution: "postgres-date@npm:2.1.0" - checksum: 00a7472c10788f6b0d08d24108bf1eb80858de1bd6317740198a564918ea4a69b80c98148167b92ae688abd606483020d0de0dd3a36f3ea9a3e26bbeef3464f4 +"postgres-interval@npm:4.0.2": + version: 4.0.2 + resolution: "postgres-interval@npm:4.0.2" + checksum: 46d0766b11ac91ba3e4816c73a04e4e0c13ddf9efb9797982fdc405019a40b85e8b4a36448bd90e1ac1e8f0ca9b2ff22820e65e103368bc6fd9fa6a3b4268fd4 languageName: node linkType: hard @@ -28703,10 +28655,10 @@ __metadata: languageName: node linkType: hard -"reflect-metadata@npm:0.1.13": - version: 0.1.13 - resolution: "reflect-metadata@npm:0.1.13" - checksum: 728bff0b376b05639fd11ed80c648b61f7fe653c5b506d7ca118e58b6752b9b00810fe0c86227ecf02bd88da6251ab3eb19fd403aaf2e9ff5ef36a2fda643026 +"reflect-metadata@npm:0.2.2": + version: 0.2.2 + resolution: "reflect-metadata@npm:0.2.2" + checksum: 1cd93a15ea291e420204955544637c264c216e7aac527470e393d54b4bb075f10a17e60d8168ec96600c7e0b9fcc0cb0bb6e91c3fbf5b0d8c9056f04e6ac1ec2 languageName: node linkType: hard @@ -32184,10 +32136,10 @@ __metadata: languageName: node linkType: hard -"type-fest@npm:^3.0.0": - version: 3.13.1 - resolution: "type-fest@npm:3.13.1" - checksum: 547d22186f73a8c04590b70dcf63baff390078c75ea8acd366bbd510fd0646e348bd1970e47ecf795b7cff0b41d26e9c475c1fedd6ef5c45c82075fbf916b629 +"type-fest@npm:^4.0.0": + version: 4.32.0 + resolution: "type-fest@npm:4.32.0" + checksum: e2e877055487d109eba99afc58211db4a480837ff7b243c7de0b3e2ac29fdce55ab55e201c64cb1a8b2aeffce7e8f60ae3ce3a2f7e6fb68261d62743e54288ba languageName: node linkType: hard @@ -32437,16 +32389,16 @@ __metadata: languageName: node linkType: hard -"umzug@npm:3.3.1": - version: 3.3.1 - resolution: "umzug@npm:3.3.1" +"umzug@npm:3.8.2": + version: 3.8.2 + resolution: "umzug@npm:3.8.2" dependencies: "@rushstack/ts-command-line": ^4.12.2 emittery: ^0.13.0 - glob: ^8.0.3 + fast-glob: ^3.3.2 pony-cause: ^2.1.4 - type-fest: ^3.0.0 - checksum: 52ace90860f9e2adc9f33c786582ca758651f2de8894b5bda7af2353bec8906234dbb456eb37513ec9ceeb45eabfcd286d4abced871cc45c01015a05e4247187 + type-fest: ^4.0.0 + checksum: b5b9659fc3e85f486fa3b701cf0b592117b38974d3c5c039d78fd8dbc60dcbaf04ce6430aa5b79a544a64bd99f230d7c9b3deffa2528fcb00c590cd6909fbc32 languageName: node linkType: hard