feat(order): module foundation (#6399)

What:
Initial Order module foundation.
Basic models and methods to manage entites like in Cart Module
This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2024-02-15 13:26:00 +00:00
1 parent 811a004c03
commit 339a946f38
77 files changed
+3998 -93

No files matched your search

+2 -2
View File
@@ -21,7 +21,7 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_address",
columns: "fulfillment_id",
where: "deleted_at IS NULL",
})
}).expression
const fulfillmentDeletedAtIndexName = "IDX_fulfillment_address_deleted_at"
const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
@@ -29,7 +29,7 @@ const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_address",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
@Entity({ tableName: "fulfillment_address" })
export default class Address {
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
@@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import Fulfillment from "./fulfillment"
type FulfillmentItemOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -26,7 +26,7 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_item",
columns: "fulfillment_id",
where: "deleted_at IS NULL",
})
}).expression
const lineItemIndexName = "IDX_fulfillment_item_line_item_id"
const lineItemIdIndexStatement = createPsqlIndexStatementHelper({
@@ -34,7 +34,7 @@ const lineItemIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_item",
columns: "line_item_id",
where: "deleted_at IS NULL",
})
}).expression
const inventoryItemIndexName = "IDX_fulfillment_item_inventory_item_id"
const inventoryItemIdIndexStatement = createPsqlIndexStatementHelper({
@@ -42,7 +42,7 @@ const inventoryItemIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_item",
columns: "inventory_item_id",
where: "deleted_at IS NULL",
})
}).expression
const fulfillmentItemDeletedAtIndexName = "IDX_fulfillment_item_deleted_at"
const fulfillmentItemDeletedAtIndexStatement = createPsqlIndexStatementHelper({
@@ -50,7 +50,7 @@ const fulfillmentItemDeletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_item",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
@@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import Fulfillment from "./fulfillment"
type FulfillmentLabelOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -26,7 +26,7 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_label",
columns: "fulfillment_id",
where: "deleted_at IS NULL",
})
}).expression
const deletedAtIndexName = "IDX_fulfillment_label_deleted_at"
const deletedAtIndexStatement = createPsqlIndexStatementHelper({
@@ -34,7 +34,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_label",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Collection,
@@ -17,12 +18,11 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"
import ServiceProvider from "./service-provider"
import Address from "./address"
import FulfillmentItem from "./fulfillment-item"
import FulfillmentLabel from "./fulfillment-label"
import ServiceProvider from "./service-provider"
import ShippingOption from "./shipping-option"
type FulfillmentOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -32,7 +32,7 @@ const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
const fulfillmentProviderIdIndexName = "IDX_fulfillment_provider_id"
const fulfillmentProviderIdIndexStatement = createPsqlIndexStatementHelper({
@@ -40,7 +40,7 @@ const fulfillmentProviderIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment",
columns: "provider_id",
where: "deleted_at IS NULL",
})
}).expression
const fulfillmentLocationIdIndexName = "IDX_fulfillment_location_id"
const fulfillmentLocationIdIndexStatement = createPsqlIndexStatementHelper({
@@ -48,7 +48,7 @@ const fulfillmentLocationIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment",
columns: "location_id",
where: "deleted_at IS NULL",
})
}).expression
const fulfillmentShippingOptionIdIndexName =
"IDX_fulfillment_shipping_option_id"
@@ -58,7 +58,7 @@ const fulfillmentShippingOptionIdIndexStatement =
tableName: "fulfillment",
columns: "shipping_option_id",
where: "deleted_at IS NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Cascade,
@@ -17,7 +18,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ServiceZone from "./service-zone"
type FulfillmentSetOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -28,7 +28,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_set",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
const nameIndexName = "IDX_fulfillment_set_name_unique"
const nameIndexStatement = createPsqlIndexStatementHelper({
@@ -37,7 +37,7 @@ const nameIndexStatement = createPsqlIndexStatementHelper({
columns: "name",
unique: true,
where: "deleted_at IS NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
+6 -6
View File
@@ -5,6 +5,7 @@ import {
GeoZoneType,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
@@ -17,7 +18,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ServiceZone from "./service-zone"
type GeoZoneOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -28,7 +28,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "geo_zone",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
const countryCodeIndexName = "IDX_geo_zone_country_code"
const countryCodeIndexStatement = createPsqlIndexStatementHelper({
@@ -36,7 +36,7 @@ const countryCodeIndexStatement = createPsqlIndexStatementHelper({
tableName: "geo_zone",
columns: "country_code",
where: "deleted_at IS NULL",
})
}).expression
const provinceCodeIndexName = "IDX_geo_zone_province_code"
const provinceCodeIndexStatement = createPsqlIndexStatementHelper({
@@ -44,7 +44,7 @@ const provinceCodeIndexStatement = createPsqlIndexStatementHelper({
tableName: "geo_zone",
columns: "province_code",
where: "deleted_at IS NULL AND province_code IS NOT NULL",
})
}).expression
const cityIndexName = "IDX_geo_zone_city"
const cityIndexStatement = createPsqlIndexStatementHelper({
@@ -52,7 +52,7 @@ const cityIndexStatement = createPsqlIndexStatementHelper({
tableName: "geo_zone",
columns: "city",
where: "deleted_at IS NULL AND city IS NOT NULL",
})
}).expression
const serviceZoneIdIndexName = "IDX_geo_zone_service_zone_id"
const serviceZoneIdStatement = createPsqlIndexStatementHelper({
@@ -60,7 +60,7 @@ const serviceZoneIdStatement = createPsqlIndexStatementHelper({
tableName: "geo_zone",
columns: "service_zone_id",
where: "deleted_at IS NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Collection,
@@ -16,7 +17,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"
type ServiceProviderOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -27,7 +27,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "service_provider",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Cascade,
@@ -18,7 +19,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import FulfillmentSet from "./fullfilment-set"
import GeoZone from "./geo-zone"
import ShippingOption from "./shipping-option"
@@ -31,7 +31,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "service_zone",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
const nameIndexName = "IDX_service_zone_name_unique"
const nameIndexStatement = createPsqlIndexStatementHelper({
@@ -40,7 +40,7 @@ const nameIndexStatement = createPsqlIndexStatementHelper({
columns: "name",
unique: true,
where: "deleted_at IS NULL",
})
}).expression
const fulfillmentSetIdIndexName = "IDX_service_zone_fulfillment_set_id"
const fulfillmentSetIdIndexStatement = createPsqlIndexStatementHelper({
@@ -48,7 +48,7 @@ const fulfillmentSetIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "service_zone",
columns: "fulfillment_set_id",
where: "deleted_at IS NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
@@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"
type ShippingOptionRuleOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -29,7 +29,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option_rule",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
@@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"
type ShippingOptionTypeOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -26,7 +26,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option_type",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
const shippingOptionIdIndexName = "IDX_shipping_option_type_shipping_option_id"
const shippingOptionIdIndexStatement = createPsqlIndexStatementHelper({
@@ -34,7 +34,7 @@ const shippingOptionIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option_type",
columns: "shipping_option_id",
where: "deleted_at IS NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -5,6 +5,7 @@ import {
ShippingOptionPriceType,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Collection,
@@ -20,13 +21,12 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ServiceZone from "./service-zone"
import ShippingProfile from "./shipping-profile"
import ServiceProvider from "./service-provider"
import ShippingOptionType from "./shipping-option-type"
import ShippingOptionRule from "./shipping-option-rule"
import Fulfillment from "./fulfillment"
import ServiceProvider from "./service-provider"
import ServiceZone from "./service-zone"
import ShippingOptionRule from "./shipping-option-rule"
import ShippingOptionType from "./shipping-option-type"
import ShippingProfile from "./shipping-profile"
type ShippingOptionOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -36,7 +36,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
const serviceZoneIdIndexName = "IDX_shipping_option_service_zone_id"
const serviceZoneIdIndexStatement = createPsqlIndexStatementHelper({
@@ -44,7 +44,7 @@ const serviceZoneIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option",
columns: "service_zone_id",
where: "deleted_at IS NULL",
})
}).expression
const shippingProfileIdIndexName = "IDX_shipping_option_shipping_profile_id"
const shippingProfileIdIndexStatement = createPsqlIndexStatementHelper({
@@ -52,7 +52,7 @@ const shippingProfileIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option",
columns: "shipping_profile_id",
where: "deleted_at IS NULL",
})
}).expression
const serviceProviderIdIndexName = "IDX_shipping_option_service_provider_id"
const serviceProviderIdIndexStatement = createPsqlIndexStatementHelper({
@@ -60,7 +60,7 @@ const serviceProviderIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option",
columns: "service_provider_id",
where: "deleted_at IS NULL",
})
}).expression
const shippingOptionTypeIdIndexName =
"IDX_shipping_option_shipping_option_type_id"
@@ -69,7 +69,7 @@ const shippingOptionTypeIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option",
columns: "shipping_option_type_id",
where: "deleted_at IS NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
@@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"
import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Collection,
@@ -16,7 +17,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"
type ShippingProfileOptionalProps = DAL.SoftDeletableEntityDateColumns
@@ -27,7 +27,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_profile",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression
@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)