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:
1 parent
811a004c03
commit
339a946f38
77 files changed
+3998
-93
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/modules-sdk": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
"@medusajs/utils": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Initial Order module implementation
|
||||||
@@ -21,7 +21,7 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_address",
|
tableName: "fulfillment_address",
|
||||||
columns: "fulfillment_id",
|
columns: "fulfillment_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const fulfillmentDeletedAtIndexName = "IDX_fulfillment_address_deleted_at"
|
const fulfillmentDeletedAtIndexName = "IDX_fulfillment_address_deleted_at"
|
||||||
const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -29,7 +29,7 @@ const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_address",
|
tableName: "fulfillment_address",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity({ tableName: "fulfillment_address" })
|
@Entity({ tableName: "fulfillment_address" })
|
||||||
export default class Address {
|
export default class Address {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -15,7 +16,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import Fulfillment from "./fulfillment"
|
import Fulfillment from "./fulfillment"
|
||||||
|
|
||||||
type FulfillmentItemOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type FulfillmentItemOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -26,7 +26,7 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_item",
|
tableName: "fulfillment_item",
|
||||||
columns: "fulfillment_id",
|
columns: "fulfillment_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const lineItemIndexName = "IDX_fulfillment_item_line_item_id"
|
const lineItemIndexName = "IDX_fulfillment_item_line_item_id"
|
||||||
const lineItemIdIndexStatement = createPsqlIndexStatementHelper({
|
const lineItemIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -34,7 +34,7 @@ const lineItemIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_item",
|
tableName: "fulfillment_item",
|
||||||
columns: "line_item_id",
|
columns: "line_item_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const inventoryItemIndexName = "IDX_fulfillment_item_inventory_item_id"
|
const inventoryItemIndexName = "IDX_fulfillment_item_inventory_item_id"
|
||||||
const inventoryItemIdIndexStatement = createPsqlIndexStatementHelper({
|
const inventoryItemIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -42,7 +42,7 @@ const inventoryItemIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_item",
|
tableName: "fulfillment_item",
|
||||||
columns: "inventory_item_id",
|
columns: "inventory_item_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const fulfillmentItemDeletedAtIndexName = "IDX_fulfillment_item_deleted_at"
|
const fulfillmentItemDeletedAtIndexName = "IDX_fulfillment_item_deleted_at"
|
||||||
const fulfillmentItemDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
const fulfillmentItemDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -50,7 +50,7 @@ const fulfillmentItemDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_item",
|
tableName: "fulfillment_item",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -15,7 +16,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import Fulfillment from "./fulfillment"
|
import Fulfillment from "./fulfillment"
|
||||||
|
|
||||||
type FulfillmentLabelOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type FulfillmentLabelOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -26,7 +26,7 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_label",
|
tableName: "fulfillment_label",
|
||||||
columns: "fulfillment_id",
|
columns: "fulfillment_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const deletedAtIndexName = "IDX_fulfillment_label_deleted_at"
|
const deletedAtIndexName = "IDX_fulfillment_label_deleted_at"
|
||||||
const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -34,7 +34,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_label",
|
tableName: "fulfillment_label",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Collection,
|
Collection,
|
||||||
@@ -17,12 +18,11 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import ShippingOption from "./shipping-option"
|
|
||||||
import ServiceProvider from "./service-provider"
|
|
||||||
import Address from "./address"
|
import Address from "./address"
|
||||||
import FulfillmentItem from "./fulfillment-item"
|
import FulfillmentItem from "./fulfillment-item"
|
||||||
import FulfillmentLabel from "./fulfillment-label"
|
import FulfillmentLabel from "./fulfillment-label"
|
||||||
|
import ServiceProvider from "./service-provider"
|
||||||
|
import ShippingOption from "./shipping-option"
|
||||||
|
|
||||||
type FulfillmentOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type FulfillmentOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment",
|
tableName: "fulfillment",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const fulfillmentProviderIdIndexName = "IDX_fulfillment_provider_id"
|
const fulfillmentProviderIdIndexName = "IDX_fulfillment_provider_id"
|
||||||
const fulfillmentProviderIdIndexStatement = createPsqlIndexStatementHelper({
|
const fulfillmentProviderIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -40,7 +40,7 @@ const fulfillmentProviderIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment",
|
tableName: "fulfillment",
|
||||||
columns: "provider_id",
|
columns: "provider_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const fulfillmentLocationIdIndexName = "IDX_fulfillment_location_id"
|
const fulfillmentLocationIdIndexName = "IDX_fulfillment_location_id"
|
||||||
const fulfillmentLocationIdIndexStatement = createPsqlIndexStatementHelper({
|
const fulfillmentLocationIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -48,7 +48,7 @@ const fulfillmentLocationIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment",
|
tableName: "fulfillment",
|
||||||
columns: "location_id",
|
columns: "location_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const fulfillmentShippingOptionIdIndexName =
|
const fulfillmentShippingOptionIdIndexName =
|
||||||
"IDX_fulfillment_shipping_option_id"
|
"IDX_fulfillment_shipping_option_id"
|
||||||
@@ -58,7 +58,7 @@ const fulfillmentShippingOptionIdIndexStatement =
|
|||||||
tableName: "fulfillment",
|
tableName: "fulfillment",
|
||||||
columns: "shipping_option_id",
|
columns: "shipping_option_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Cascade,
|
Cascade,
|
||||||
@@ -17,7 +18,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import ServiceZone from "./service-zone"
|
import ServiceZone from "./service-zone"
|
||||||
|
|
||||||
type FulfillmentSetOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type FulfillmentSetOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -28,7 +28,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "fulfillment_set",
|
tableName: "fulfillment_set",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const nameIndexName = "IDX_fulfillment_set_name_unique"
|
const nameIndexName = "IDX_fulfillment_set_name_unique"
|
||||||
const nameIndexStatement = createPsqlIndexStatementHelper({
|
const nameIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -37,7 +37,7 @@ const nameIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
columns: "name",
|
columns: "name",
|
||||||
unique: true,
|
unique: true,
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
GeoZoneType,
|
GeoZoneType,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -17,7 +18,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import ServiceZone from "./service-zone"
|
import ServiceZone from "./service-zone"
|
||||||
|
|
||||||
type GeoZoneOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type GeoZoneOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -28,7 +28,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "geo_zone",
|
tableName: "geo_zone",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const countryCodeIndexName = "IDX_geo_zone_country_code"
|
const countryCodeIndexName = "IDX_geo_zone_country_code"
|
||||||
const countryCodeIndexStatement = createPsqlIndexStatementHelper({
|
const countryCodeIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -36,7 +36,7 @@ const countryCodeIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "geo_zone",
|
tableName: "geo_zone",
|
||||||
columns: "country_code",
|
columns: "country_code",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const provinceCodeIndexName = "IDX_geo_zone_province_code"
|
const provinceCodeIndexName = "IDX_geo_zone_province_code"
|
||||||
const provinceCodeIndexStatement = createPsqlIndexStatementHelper({
|
const provinceCodeIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -44,7 +44,7 @@ const provinceCodeIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "geo_zone",
|
tableName: "geo_zone",
|
||||||
columns: "province_code",
|
columns: "province_code",
|
||||||
where: "deleted_at IS NULL AND province_code IS NOT NULL",
|
where: "deleted_at IS NULL AND province_code IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const cityIndexName = "IDX_geo_zone_city"
|
const cityIndexName = "IDX_geo_zone_city"
|
||||||
const cityIndexStatement = createPsqlIndexStatementHelper({
|
const cityIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -52,7 +52,7 @@ const cityIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "geo_zone",
|
tableName: "geo_zone",
|
||||||
columns: "city",
|
columns: "city",
|
||||||
where: "deleted_at IS NULL AND city IS NOT NULL",
|
where: "deleted_at IS NULL AND city IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const serviceZoneIdIndexName = "IDX_geo_zone_service_zone_id"
|
const serviceZoneIdIndexName = "IDX_geo_zone_service_zone_id"
|
||||||
const serviceZoneIdStatement = createPsqlIndexStatementHelper({
|
const serviceZoneIdStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -60,7 +60,7 @@ const serviceZoneIdStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "geo_zone",
|
tableName: "geo_zone",
|
||||||
columns: "service_zone_id",
|
columns: "service_zone_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Collection,
|
Collection,
|
||||||
@@ -16,7 +17,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import ShippingOption from "./shipping-option"
|
import ShippingOption from "./shipping-option"
|
||||||
|
|
||||||
type ServiceProviderOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type ServiceProviderOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -27,7 +27,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "service_provider",
|
tableName: "service_provider",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Cascade,
|
Cascade,
|
||||||
@@ -18,7 +19,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import FulfillmentSet from "./fullfilment-set"
|
import FulfillmentSet from "./fullfilment-set"
|
||||||
import GeoZone from "./geo-zone"
|
import GeoZone from "./geo-zone"
|
||||||
import ShippingOption from "./shipping-option"
|
import ShippingOption from "./shipping-option"
|
||||||
@@ -31,7 +31,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "service_zone",
|
tableName: "service_zone",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const nameIndexName = "IDX_service_zone_name_unique"
|
const nameIndexName = "IDX_service_zone_name_unique"
|
||||||
const nameIndexStatement = createPsqlIndexStatementHelper({
|
const nameIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -40,7 +40,7 @@ const nameIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
columns: "name",
|
columns: "name",
|
||||||
unique: true,
|
unique: true,
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const fulfillmentSetIdIndexName = "IDX_service_zone_fulfillment_set_id"
|
const fulfillmentSetIdIndexName = "IDX_service_zone_fulfillment_set_id"
|
||||||
const fulfillmentSetIdIndexStatement = createPsqlIndexStatementHelper({
|
const fulfillmentSetIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -48,7 +48,7 @@ const fulfillmentSetIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "service_zone",
|
tableName: "service_zone",
|
||||||
columns: "fulfillment_set_id",
|
columns: "fulfillment_set_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -15,7 +16,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import ShippingOption from "./shipping-option"
|
import ShippingOption from "./shipping-option"
|
||||||
|
|
||||||
type ShippingOptionRuleOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type ShippingOptionRuleOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -29,7 +29,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option_rule",
|
tableName: "shipping_option_rule",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -15,7 +16,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import ShippingOption from "./shipping-option"
|
import ShippingOption from "./shipping-option"
|
||||||
|
|
||||||
type ShippingOptionTypeOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type ShippingOptionTypeOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -26,7 +26,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option_type",
|
tableName: "shipping_option_type",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const shippingOptionIdIndexName = "IDX_shipping_option_type_shipping_option_id"
|
const shippingOptionIdIndexName = "IDX_shipping_option_type_shipping_option_id"
|
||||||
const shippingOptionIdIndexStatement = createPsqlIndexStatementHelper({
|
const shippingOptionIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -34,7 +34,7 @@ const shippingOptionIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option_type",
|
tableName: "shipping_option_type",
|
||||||
columns: "shipping_option_id",
|
columns: "shipping_option_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
ShippingOptionPriceType,
|
ShippingOptionPriceType,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Collection,
|
Collection,
|
||||||
@@ -20,13 +21,12 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} 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 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
|
type ShippingOptionOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option",
|
tableName: "shipping_option",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const serviceZoneIdIndexName = "IDX_shipping_option_service_zone_id"
|
const serviceZoneIdIndexName = "IDX_shipping_option_service_zone_id"
|
||||||
const serviceZoneIdIndexStatement = createPsqlIndexStatementHelper({
|
const serviceZoneIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -44,7 +44,7 @@ const serviceZoneIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option",
|
tableName: "shipping_option",
|
||||||
columns: "service_zone_id",
|
columns: "service_zone_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const shippingProfileIdIndexName = "IDX_shipping_option_shipping_profile_id"
|
const shippingProfileIdIndexName = "IDX_shipping_option_shipping_profile_id"
|
||||||
const shippingProfileIdIndexStatement = createPsqlIndexStatementHelper({
|
const shippingProfileIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -52,7 +52,7 @@ const shippingProfileIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option",
|
tableName: "shipping_option",
|
||||||
columns: "shipping_profile_id",
|
columns: "shipping_profile_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const serviceProviderIdIndexName = "IDX_shipping_option_service_provider_id"
|
const serviceProviderIdIndexName = "IDX_shipping_option_service_provider_id"
|
||||||
const serviceProviderIdIndexStatement = createPsqlIndexStatementHelper({
|
const serviceProviderIdIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -60,7 +60,7 @@ const serviceProviderIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option",
|
tableName: "shipping_option",
|
||||||
columns: "service_provider_id",
|
columns: "service_provider_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const shippingOptionTypeIdIndexName =
|
const shippingOptionTypeIdIndexName =
|
||||||
"IDX_shipping_option_shipping_option_type_id"
|
"IDX_shipping_option_shipping_option_type_id"
|
||||||
@@ -69,7 +69,7 @@ const shippingOptionTypeIdIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_option",
|
tableName: "shipping_option",
|
||||||
columns: "shipping_option_type_id",
|
columns: "shipping_option_type_id",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
generateEntityId,
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Collection,
|
Collection,
|
||||||
@@ -16,7 +17,6 @@ import {
|
|||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
import ShippingOption from "./shipping-option"
|
import ShippingOption from "./shipping-option"
|
||||||
|
|
||||||
type ShippingProfileOptionalProps = DAL.SoftDeletableEntityDateColumns
|
type ShippingProfileOptionalProps = DAL.SoftDeletableEntityDateColumns
|
||||||
@@ -27,7 +27,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "shipping_profile",
|
tableName: "shipping_profile",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
FeatureFlagDecorators,
|
FeatureFlagDecorators,
|
||||||
} from "../utils/feature-flag-decorators"
|
} from "../utils/feature-flag-decorators"
|
||||||
|
|
||||||
|
import { MedusaV2Flag } from "@medusajs/utils"
|
||||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||||
import { generateEntityId } from "../utils/generate-entity-id"
|
import { generateEntityId } from "../utils/generate-entity-id"
|
||||||
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
||||||
@@ -41,7 +42,6 @@ import { Return } from "./return"
|
|||||||
import { SalesChannel } from "./sales-channel"
|
import { SalesChannel } from "./sales-channel"
|
||||||
import { ShippingMethod } from "./shipping-method"
|
import { ShippingMethod } from "./shipping-method"
|
||||||
import { Swap } from "./swap"
|
import { Swap } from "./swap"
|
||||||
import { MedusaV2Flag } from "@medusajs/utils"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum
|
* @enum
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export enum Modules {
|
|||||||
USER = "user",
|
USER = "user",
|
||||||
WORKFLOW_ENGINE = "workflows",
|
WORKFLOW_ENGINE = "workflows",
|
||||||
REGION = "region",
|
REGION = "region",
|
||||||
|
ORDER = "order",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ModuleRegistrationName {
|
export enum ModuleRegistrationName {
|
||||||
@@ -43,6 +44,7 @@ export enum ModuleRegistrationName {
|
|||||||
USER = "userModuleService",
|
USER = "userModuleService",
|
||||||
WORKFLOW_ENGINE = "workflowsModuleService",
|
WORKFLOW_ENGINE = "workflowsModuleService",
|
||||||
REGION = "regionModuleService",
|
REGION = "regionModuleService",
|
||||||
|
ORDER = "orderModuleService",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MODULE_PACKAGE_NAMES = {
|
export const MODULE_PACKAGE_NAMES = {
|
||||||
@@ -63,6 +65,7 @@ export const MODULE_PACKAGE_NAMES = {
|
|||||||
[Modules.USER]: "@medusajs/user",
|
[Modules.USER]: "@medusajs/user",
|
||||||
[Modules.WORKFLOW_ENGINE]: "@medusajs/workflow-engine-inmemory",
|
[Modules.WORKFLOW_ENGINE]: "@medusajs/workflow-engine-inmemory",
|
||||||
[Modules.REGION]: "@medusajs/region",
|
[Modules.REGION]: "@medusajs/region",
|
||||||
|
[Modules.ORDER]: "@medusajs/order",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ModulesDefinition: { [key: string | Modules]: ModuleDefinition } =
|
export const ModulesDefinition: { [key: string | Modules]: ModuleDefinition } =
|
||||||
@@ -276,6 +279,19 @@ export const ModulesDefinition: { [key: string | Modules]: ModuleDefinition } =
|
|||||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
[Modules.ORDER]: {
|
||||||
|
key: Modules.ORDER,
|
||||||
|
registrationName: ModuleRegistrationName.ORDER,
|
||||||
|
defaultPackage: false,
|
||||||
|
label: upperCaseFirst(ModuleRegistrationName.ORDER),
|
||||||
|
isRequired: false,
|
||||||
|
isQueryable: true,
|
||||||
|
dependencies: ["logger", "eventBusService"],
|
||||||
|
defaultModuleDeclaration: {
|
||||||
|
scope: MODULE_SCOPE.INTERNAL,
|
||||||
|
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MODULE_DEFINITIONS: ModuleDefinition[] =
|
export const MODULE_DEFINITIONS: ModuleDefinition[] =
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/dist
|
||||||
|
node_modules
|
||||||
|
.DS_store
|
||||||
|
.env*
|
||||||
|
.env
|
||||||
|
*.sql
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Order Module
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
// noop
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
describe("noop", function () {
|
||||||
|
it("should run", function () {
|
||||||
|
expect(true).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
if (typeof process.env.DB_TEMP_NAME === "undefined") {
|
||||||
|
const tempName = parseInt(process.env.JEST_WORKER_ID || "1")
|
||||||
|
process.env.DB_TEMP_NAME = `medusa-order-integration-${tempName}`
|
||||||
|
}
|
||||||
|
|
||||||
|
process.env.MEDUSA_ORDER_DB_SCHEMA = "public"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { JestUtils } from "medusa-test-utils"
|
||||||
|
|
||||||
|
JestUtils.afterAllHookDropDatabase()
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { TestDatabaseUtils } from "medusa-test-utils"
|
||||||
|
|
||||||
|
import * as Models from "@models"
|
||||||
|
|
||||||
|
const mikroOrmEntities = Models as unknown as any[]
|
||||||
|
|
||||||
|
export const MikroOrmWrapper = TestDatabaseUtils.getMikroOrmWrapper(
|
||||||
|
mikroOrmEntities,
|
||||||
|
null,
|
||||||
|
process.env.MEDUSA_FULFILLMENT_DB_SCHEMA
|
||||||
|
)
|
||||||
|
|
||||||
|
export const DB_URL = TestDatabaseUtils.getDatabaseURL()
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { Modules, ModulesDefinition } from "@medusajs/modules-sdk"
|
||||||
|
|
||||||
|
import { DB_URL } from "./database"
|
||||||
|
|
||||||
|
export function getInitModuleConfig() {
|
||||||
|
const moduleOptions = {
|
||||||
|
defaultAdapterOptions: {
|
||||||
|
database: {
|
||||||
|
clientUrl: DB_URL,
|
||||||
|
schema: process.env.MEDUSA_ORDER_DB_SCHEMA,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const injectedDependencies = {}
|
||||||
|
|
||||||
|
const modulesConfig_ = {
|
||||||
|
[Modules.ORDER]: {
|
||||||
|
definition: ModulesDefinition[Modules.ORDER],
|
||||||
|
options: moduleOptions,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
injectedDependencies,
|
||||||
|
modulesConfig: modulesConfig_,
|
||||||
|
databaseConfig: {
|
||||||
|
clientUrl: DB_URL,
|
||||||
|
schema: process.env.MEDUSA_ORDER_DB_SCHEMA,
|
||||||
|
},
|
||||||
|
joinerConfig: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./database"
|
||||||
|
export * from "./get-init-module-config"
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
module.exports = {
|
||||||
|
moduleNameMapper: {
|
||||||
|
"^@models": "<rootDir>/src/models",
|
||||||
|
"^@services": "<rootDir>/src/services",
|
||||||
|
"^@repositories": "<rootDir>/src/repositories",
|
||||||
|
"^@types": "<rootDir>/src/types",
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
"^.+\\.[jt]s?$": [
|
||||||
|
"ts-jest",
|
||||||
|
{
|
||||||
|
tsConfig: "tsconfig.spec.json",
|
||||||
|
isolatedModules: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
testEnvironment: `node`,
|
||||||
|
moduleFileExtensions: [`js`, `ts`],
|
||||||
|
modulePathIgnorePatterns: ["dist/"],
|
||||||
|
setupFiles: ["<rootDir>/integration-tests/setup-env.js"],
|
||||||
|
setupFilesAfterEnv: ["<rootDir>/integration-tests/setup.js"],
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { TSMigrationGenerator } from "@medusajs/utils"
|
||||||
|
import * as entities from "./src/models"
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entities: Object.values(entities),
|
||||||
|
schema: "public",
|
||||||
|
clientUrl: "postgres://postgres@localhost/medusa-order",
|
||||||
|
type: "postgresql",
|
||||||
|
migrations: {
|
||||||
|
generator: TSMigrationGenerator,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"name": "@medusajs/order",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Medusa Order module",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"medusa-order-seed": "dist/scripts/bin/run-seed.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/medusajs/medusa",
|
||||||
|
"directory": "packages/order"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"author": "Medusa",
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"watch": "tsc --build --watch",
|
||||||
|
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
||||||
|
"prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
|
||||||
|
"build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
|
||||||
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
||||||
|
"test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
||||||
|
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
||||||
|
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
|
||||||
|
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
|
||||||
|
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up",
|
||||||
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@mikro-orm/cli": "5.9.7",
|
||||||
|
"cross-env": "^5.2.1",
|
||||||
|
"jest": "^29.6.3",
|
||||||
|
"medusa-test-utils": "^1.1.40",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"ts-jest": "^29.1.1",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
|
"tsc-alias": "^1.8.6",
|
||||||
|
"typescript": "^5.1.6"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@medusajs/modules-sdk": "^1.12.4",
|
||||||
|
"@medusajs/types": "^1.11.8",
|
||||||
|
"@medusajs/utils": "^1.11.1",
|
||||||
|
"@mikro-orm/core": "5.9.7",
|
||||||
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
|
"awilix": "^8.0.0",
|
||||||
|
"dotenv": "^16.1.4",
|
||||||
|
"knex": "2.4.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { initializeFactory, Modules } from "@medusajs/modules-sdk"
|
||||||
|
import { moduleDefinition } from "./module-definition"
|
||||||
|
|
||||||
|
export * from "./models"
|
||||||
|
export * from "./services"
|
||||||
|
export * from "./types"
|
||||||
|
|
||||||
|
export const initialize = initializeFactory({
|
||||||
|
moduleName: Modules.ORDER,
|
||||||
|
moduleDefinition,
|
||||||
|
})
|
||||||
|
export const runMigrations = moduleDefinition.runMigrations
|
||||||
|
export const revertMigration = moduleDefinition.revertMigration
|
||||||
|
export default moduleDefinition
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
|
import { ModuleJoinerConfig } from "@medusajs/types"
|
||||||
|
import { MapToConfig } from "@medusajs/utils"
|
||||||
|
|
||||||
|
export const LinkableKeys: Record<string, string> = {
|
||||||
|
order_id: "Order",
|
||||||
|
order_item_id: "OrderLineItem",
|
||||||
|
}
|
||||||
|
|
||||||
|
const entityLinkableKeysMap: MapToConfig = {}
|
||||||
|
Object.entries(LinkableKeys).forEach(([key, value]) => {
|
||||||
|
entityLinkableKeysMap[value] ??= []
|
||||||
|
entityLinkableKeysMap[value].push({
|
||||||
|
mapTo: key,
|
||||||
|
valueFrom: key.split("_").pop()!,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
export const entityNameToLinkableKeysMap: MapToConfig = entityLinkableKeysMap
|
||||||
|
|
||||||
|
export const joinerConfig: ModuleJoinerConfig = {
|
||||||
|
serviceName: Modules.ORDER,
|
||||||
|
primaryKeys: ["id"],
|
||||||
|
linkableKeys: LinkableKeys,
|
||||||
|
alias: [],
|
||||||
|
} as ModuleJoinerConfig
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import { DAL } from "@medusajs/types"
|
||||||
|
import {
|
||||||
|
createPsqlIndexStatementHelper,
|
||||||
|
generateEntityId,
|
||||||
|
} from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
Entity,
|
||||||
|
OnInit,
|
||||||
|
OptionalProps,
|
||||||
|
PrimaryKey,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
|
||||||
|
type OptionalAddressProps = DAL.EntityDateColumns
|
||||||
|
|
||||||
|
const customerIdIndex = createPsqlIndexStatementHelper({
|
||||||
|
tableName: "order_address",
|
||||||
|
columns: "customer_id",
|
||||||
|
})
|
||||||
|
|
||||||
|
@Entity({ tableName: "order_address" })
|
||||||
|
export default class Address {
|
||||||
|
[OptionalProps]: OptionalAddressProps
|
||||||
|
|
||||||
|
@PrimaryKey({ columnType: "text" })
|
||||||
|
id!: string
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
@customerIdIndex.MikroORMIndex()
|
||||||
|
customer_id: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
company: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
first_name: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
last_name: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
address_1: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
address_2: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
city: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
country_code: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
province: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
postal_code: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
phone: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
metadata: Record<string, unknown> | 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
|
||||||
|
|
||||||
|
@BeforeCreate()
|
||||||
|
onCreate() {
|
||||||
|
this.id = generateEntityId(this.id, "ordaddr")
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnInit()
|
||||||
|
onInit() {
|
||||||
|
this.id = generateEntityId(this.id, "ordaddr")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { BigNumberRawValue, DAL } from "@medusajs/types"
|
||||||
|
import { BigNumber } from "@medusajs/utils"
|
||||||
|
import { OptionalProps, PrimaryKey, Property } from "@mikro-orm/core"
|
||||||
|
|
||||||
|
type OptionalAdjustmentLineProps = DAL.EntityDateColumns
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
|
||||||
|
@Property({ columnType: "numeric" })
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export { default as Address } from "./address"
|
||||||
|
export { default as LineItem } from "./line-item"
|
||||||
|
export { default as LineItemAdjustment } from "./line-item-adjustment"
|
||||||
|
export { default as LineItemTaxLine } from "./line-item-tax-line"
|
||||||
|
export { default as Order } from "./order"
|
||||||
|
export { default as ShippingMethod } from "./shipping-method"
|
||||||
|
export { default as ShippingMethodAdjustment } from "./shipping-method-adjustment"
|
||||||
|
export { default as ShippingMethodTaxLine } from "./shipping-method-tax-line"
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { generateEntityId } from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
Cascade,
|
||||||
|
Check,
|
||||||
|
Entity,
|
||||||
|
ManyToOne,
|
||||||
|
OnInit,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
import AdjustmentLine from "./adjustment-line"
|
||||||
|
import LineItem from "./line-item"
|
||||||
|
|
||||||
|
@Entity({ tableName: "order_line_item_adjustment" })
|
||||||
|
@Check<LineItemAdjustment>({
|
||||||
|
expression: (columns) => `${columns.amount} >= 0`,
|
||||||
|
})
|
||||||
|
export default class LineItemAdjustment extends AdjustmentLine {
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => LineItem,
|
||||||
|
index: "IDX_order_line_item_adjustment_item_id",
|
||||||
|
cascade: [Cascade.REMOVE, Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
item: LineItem
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
item_id: string
|
||||||
|
|
||||||
|
@BeforeCreate()
|
||||||
|
onCreate() {
|
||||||
|
this.id = generateEntityId(this.id, "ordliadj")
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnInit()
|
||||||
|
onInit() {
|
||||||
|
this.id = generateEntityId(this.id, "ordliadj")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { generateEntityId } from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
Cascade,
|
||||||
|
Entity,
|
||||||
|
ManyToOne,
|
||||||
|
OnInit,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
import LineItem from "./line-item"
|
||||||
|
import TaxLine from "./tax-line"
|
||||||
|
|
||||||
|
@Entity({ tableName: "order_line_item_tax_line" })
|
||||||
|
export default class LineItemTaxLine extends TaxLine {
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => LineItem,
|
||||||
|
index: "IDX_order_line_item_tax_line_item_id",
|
||||||
|
cascade: [Cascade.REMOVE, Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
item: LineItem
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
item_id: string
|
||||||
|
|
||||||
|
@BeforeCreate()
|
||||||
|
onCreate() {
|
||||||
|
this.id = generateEntityId(this.id, "ordlitxl")
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnInit()
|
||||||
|
onInit() {
|
||||||
|
this.id = generateEntityId(this.id, "ordlitxl")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
import { BigNumberRawValue, DAL } from "@medusajs/types"
|
||||||
|
import {
|
||||||
|
BigNumber,
|
||||||
|
createPsqlIndexStatementHelper,
|
||||||
|
generateEntityId,
|
||||||
|
} from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
BeforeUpdate,
|
||||||
|
Cascade,
|
||||||
|
Collection,
|
||||||
|
Entity,
|
||||||
|
ManyToOne,
|
||||||
|
OnInit,
|
||||||
|
OneToMany,
|
||||||
|
OptionalProps,
|
||||||
|
PrimaryKey,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
import LineItemAdjustment from "./line-item-adjustment"
|
||||||
|
import LineItemTaxLine from "./line-item-tax-line"
|
||||||
|
import Order from "./order"
|
||||||
|
|
||||||
|
type OptionalLineItemProps =
|
||||||
|
| "is_discoutable"
|
||||||
|
| "is_tax_inclusive"
|
||||||
|
| "compare_at_unit_price"
|
||||||
|
| "requires_shipping"
|
||||||
|
| "order"
|
||||||
|
| DAL.EntityDateColumns
|
||||||
|
|
||||||
|
const productIdIndex = createPsqlIndexStatementHelper({
|
||||||
|
tableName: "order_line_item",
|
||||||
|
columns: "product_id",
|
||||||
|
})
|
||||||
|
|
||||||
|
const variantIdIndex = createPsqlIndexStatementHelper({
|
||||||
|
tableName: "order_line_item",
|
||||||
|
columns: "variant_id",
|
||||||
|
})
|
||||||
|
|
||||||
|
@Entity({ tableName: "order_line_item" })
|
||||||
|
export default class LineItem {
|
||||||
|
[OptionalProps]?: OptionalLineItemProps
|
||||||
|
|
||||||
|
@PrimaryKey({ columnType: "text" })
|
||||||
|
id: string
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
order_id: string
|
||||||
|
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => Order,
|
||||||
|
onDelete: "cascade",
|
||||||
|
index: "IDX_order_line_item_order_id",
|
||||||
|
cascade: [Cascade.REMOVE, Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
order: Order
|
||||||
|
|
||||||
|
@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: "numeric" })
|
||||||
|
quantity: BigNumber | number
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb" })
|
||||||
|
raw_quantity: BigNumberRawValue
|
||||||
|
|
||||||
|
@Property({
|
||||||
|
columnType: "text",
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
@variantIdIndex.MikroORMIndex()
|
||||||
|
variant_id: string | null = null
|
||||||
|
|
||||||
|
@Property({
|
||||||
|
columnType: "text",
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
@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
|
||||||
|
|
||||||
|
@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<string, unknown> | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "boolean" })
|
||||||
|
requires_shipping = true
|
||||||
|
|
||||||
|
@Property({ columnType: "boolean" })
|
||||||
|
is_discountable = true
|
||||||
|
|
||||||
|
@Property({ columnType: "boolean" })
|
||||||
|
is_tax_inclusive = false
|
||||||
|
|
||||||
|
@Property({ columnType: "numeric", nullable: true })
|
||||||
|
compare_at_unit_price?: BigNumber | number | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
raw_compare_at_unit_price: BigNumberRawValue | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "numeric" })
|
||||||
|
unit_price: BigNumber | number
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb" })
|
||||||
|
raw_unit_price: BigNumberRawValue
|
||||||
|
|
||||||
|
@OneToMany(() => LineItemTaxLine, (taxLine) => taxLine.item, {
|
||||||
|
cascade: [Cascade.REMOVE],
|
||||||
|
})
|
||||||
|
tax_lines = new Collection<LineItemTaxLine>(this)
|
||||||
|
|
||||||
|
@OneToMany(() => LineItemAdjustment, (adjustment) => adjustment.item, {
|
||||||
|
cascade: [Cascade.REMOVE],
|
||||||
|
})
|
||||||
|
adjustments = new Collection<LineItemAdjustment>(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
|
||||||
|
|
||||||
|
@BeforeCreate()
|
||||||
|
onCreate() {
|
||||||
|
this.id = generateEntityId(this.id, "ordli")
|
||||||
|
|
||||||
|
const val = new BigNumber(this.raw_unit_price ?? this.unit_price)
|
||||||
|
|
||||||
|
this.unit_price = val.numeric
|
||||||
|
this.raw_unit_price = val.raw!
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
onUpdate() {
|
||||||
|
const val = new BigNumber(this.raw_unit_price ?? this.unit_price)
|
||||||
|
|
||||||
|
this.unit_price = val.numeric
|
||||||
|
this.raw_unit_price = val.raw as BigNumberRawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnInit()
|
||||||
|
onInit() {
|
||||||
|
this.id = generateEntityId(this.id, "ordli")
|
||||||
|
|
||||||
|
const val = new BigNumber(this.raw_unit_price ?? this.unit_price)
|
||||||
|
|
||||||
|
this.unit_price = val.numeric
|
||||||
|
this.raw_unit_price = val.raw!
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
import { DAL } from "@medusajs/types"
|
||||||
|
import {
|
||||||
|
OrderStatus,
|
||||||
|
createPsqlIndexStatementHelper,
|
||||||
|
generateEntityId,
|
||||||
|
} from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
Cascade,
|
||||||
|
Collection,
|
||||||
|
Entity,
|
||||||
|
Enum,
|
||||||
|
ManyToOne,
|
||||||
|
OnInit,
|
||||||
|
OneToMany,
|
||||||
|
OptionalProps,
|
||||||
|
PrimaryKey,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
import Address from "./address"
|
||||||
|
import LineItem from "./line-item"
|
||||||
|
import ShippingMethod from "./shipping-method"
|
||||||
|
|
||||||
|
type OptionalOrderProps =
|
||||||
|
| "shipping_address"
|
||||||
|
| "billing_address"
|
||||||
|
| DAL.EntityDateColumns
|
||||||
|
|
||||||
|
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",
|
||||||
|
})
|
||||||
|
|
||||||
|
@Entity({ tableName: "order" })
|
||||||
|
export default class Order {
|
||||||
|
[OptionalProps]?: OptionalOrderProps
|
||||||
|
|
||||||
|
@PrimaryKey({ columnType: "text" })
|
||||||
|
id: string
|
||||||
|
|
||||||
|
@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: "text",
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
@salesChannelIdIndex.MikroORMIndex()
|
||||||
|
sales_channel_id: string | null = null
|
||||||
|
|
||||||
|
@Enum({ items: () => OrderStatus, default: OrderStatus.PENDING })
|
||||||
|
status: OrderStatus
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
email: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
@currencyCodeIndex.MikroORMIndex()
|
||||||
|
currency_code: string
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
shipping_address_id?: string | null
|
||||||
|
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => Address,
|
||||||
|
fieldName: "shipping_address_id",
|
||||||
|
nullable: true,
|
||||||
|
index: "IDX_order_shipping_address_id",
|
||||||
|
cascade: [Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
shipping_address?: Address | null
|
||||||
|
|
||||||
|
@Property({ columnType: "text", nullable: true })
|
||||||
|
billing_address_id?: string | null
|
||||||
|
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => Address,
|
||||||
|
fieldName: "billing_address_id",
|
||||||
|
nullable: true,
|
||||||
|
index: "IDX_order_billing_address_id",
|
||||||
|
cascade: [Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
billing_address?: Address | null
|
||||||
|
|
||||||
|
@Property({ columnType: "boolean", nullable: true })
|
||||||
|
no_notification: boolean | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
metadata: Record<string, unknown> | null = null
|
||||||
|
|
||||||
|
@OneToMany(() => LineItem, (lineItem) => lineItem.order, {
|
||||||
|
cascade: [Cascade.REMOVE],
|
||||||
|
})
|
||||||
|
items = new Collection<LineItem>(this)
|
||||||
|
|
||||||
|
@OneToMany(() => ShippingMethod, (shippingMethod) => shippingMethod.order, {
|
||||||
|
cascade: [Cascade.REMOVE],
|
||||||
|
})
|
||||||
|
shipping_methods = new Collection<ShippingMethod>(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")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { generateEntityId } from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
Cascade,
|
||||||
|
Entity,
|
||||||
|
ManyToOne,
|
||||||
|
OnInit,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
import AdjustmentLine from "./adjustment-line"
|
||||||
|
import ShippingMethod from "./shipping-method"
|
||||||
|
|
||||||
|
@Entity({ tableName: "order_shipping_method_adjustment" })
|
||||||
|
export default class ShippingMethodAdjustment extends AdjustmentLine {
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => ShippingMethod,
|
||||||
|
fieldName: "shipping_method_id",
|
||||||
|
index: "IDX_order_shipping_method_adjustment_shipping_method_id",
|
||||||
|
cascade: [Cascade.REMOVE, Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
shipping_method: ShippingMethod
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
shipping_method_id: string
|
||||||
|
|
||||||
|
@BeforeCreate()
|
||||||
|
onCreate() {
|
||||||
|
this.id = generateEntityId(this.id, "ordsmadj")
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnInit()
|
||||||
|
onInit() {
|
||||||
|
this.id = generateEntityId(this.id, "ordsmadj")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { generateEntityId } from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
Cascade,
|
||||||
|
Entity,
|
||||||
|
ManyToOne,
|
||||||
|
OnInit,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
import ShippingMethod from "./shipping-method"
|
||||||
|
import TaxLine from "./tax-line"
|
||||||
|
|
||||||
|
@Entity({ tableName: "order_shipping_method_tax_line" })
|
||||||
|
export default class ShippingMethodTaxLine extends TaxLine {
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => ShippingMethod,
|
||||||
|
fieldName: "shipping_method_id",
|
||||||
|
index: "IDX_order_tax_line_shipping_method_id",
|
||||||
|
cascade: [Cascade.REMOVE, Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
shipping_method: ShippingMethod
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
shipping_method_id: string
|
||||||
|
|
||||||
|
@BeforeCreate()
|
||||||
|
onCreate() {
|
||||||
|
this.id = generateEntityId(this.id, "ordsmtxl")
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnInit()
|
||||||
|
onInit() {
|
||||||
|
this.id = generateEntityId(this.id, "ordsmtxl")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import { BigNumberRawValue } from "@medusajs/types"
|
||||||
|
import {
|
||||||
|
BigNumber,
|
||||||
|
createPsqlIndexStatementHelper,
|
||||||
|
generateEntityId,
|
||||||
|
} from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
BeforeCreate,
|
||||||
|
Cascade,
|
||||||
|
Check,
|
||||||
|
Collection,
|
||||||
|
Entity,
|
||||||
|
ManyToOne,
|
||||||
|
OnInit,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryKey,
|
||||||
|
Property,
|
||||||
|
} from "@mikro-orm/core"
|
||||||
|
import { BeforeUpdate } from "typeorm"
|
||||||
|
import Order from "./order"
|
||||||
|
import ShippingMethodAdjustment from "./shipping-method-adjustment"
|
||||||
|
import ShippingMethodTaxLine from "./shipping-method-tax-line"
|
||||||
|
|
||||||
|
const shippingOptionIdIndex = createPsqlIndexStatementHelper({
|
||||||
|
tableName: "order_shipping_method",
|
||||||
|
columns: "shipping_option_id",
|
||||||
|
})
|
||||||
|
|
||||||
|
@Entity({ tableName: "order_shipping_method" })
|
||||||
|
@Check<ShippingMethod>({ expression: (columns) => `${columns.amount} >= 0` })
|
||||||
|
export default class ShippingMethod {
|
||||||
|
@PrimaryKey({ columnType: "text" })
|
||||||
|
id: string
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
order_id: string
|
||||||
|
|
||||||
|
@ManyToOne({
|
||||||
|
entity: () => Order,
|
||||||
|
fieldName: "order_id",
|
||||||
|
index: "IDX_order_shipping_method_order_id",
|
||||||
|
cascade: [Cascade.REMOVE, Cascade.PERSIST],
|
||||||
|
})
|
||||||
|
order: Order
|
||||||
|
|
||||||
|
@Property({ columnType: "text" })
|
||||||
|
name: string
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
description: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "numeric" })
|
||||||
|
amount: BigNumber | number
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb" })
|
||||||
|
raw_amount: BigNumberRawValue
|
||||||
|
|
||||||
|
@Property({ columnType: "boolean" })
|
||||||
|
is_tax_inclusive = false
|
||||||
|
|
||||||
|
@Property({
|
||||||
|
columnType: "text",
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
@shippingOptionIdIndex.MikroORMIndex()
|
||||||
|
shipping_option_id: string | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
data: Record<string, unknown> | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
metadata: Record<string, unknown> | null = null
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ShippingMethodTaxLine,
|
||||||
|
(taxLine) => taxLine.shipping_method,
|
||||||
|
{
|
||||||
|
cascade: [Cascade.REMOVE],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
tax_lines = new Collection<ShippingMethodTaxLine>(this)
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ShippingMethodAdjustment,
|
||||||
|
(adjustment) => adjustment.shipping_method,
|
||||||
|
{
|
||||||
|
cascade: [Cascade.REMOVE],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
adjustments = new Collection<ShippingMethodAdjustment>(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
|
||||||
|
|
||||||
|
@BeforeCreate()
|
||||||
|
onCreate() {
|
||||||
|
this.id = generateEntityId(this.id, "ordsm")
|
||||||
|
|
||||||
|
const val = new BigNumber(this.raw_amount ?? this.amount)
|
||||||
|
|
||||||
|
this.amount = val.numeric
|
||||||
|
this.raw_amount = val.raw!
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
onUpdate() {
|
||||||
|
const val = new BigNumber(this.raw_amount ?? this.amount)
|
||||||
|
|
||||||
|
this.amount = val.numeric
|
||||||
|
this.raw_amount = val.raw as BigNumberRawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnInit()
|
||||||
|
onInit() {
|
||||||
|
this.id = generateEntityId(this.id, "ordsm")
|
||||||
|
|
||||||
|
const val = new BigNumber(this.raw_amount ?? this.amount)
|
||||||
|
|
||||||
|
this.amount = val.numeric
|
||||||
|
this.raw_amount = val.raw!
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { BigNumberRawValue } from "@medusajs/types"
|
||||||
|
import { BigNumber } from "@medusajs/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
|
||||||
|
|
||||||
|
@Property({ columnType: "numeric" })
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
|
import { ModuleExports } from "@medusajs/types"
|
||||||
|
import { ModulesSdkUtils } from "@medusajs/utils"
|
||||||
|
import * as Models from "@models"
|
||||||
|
import * as ModuleModels from "@models"
|
||||||
|
import * as ModuleRepositories from "@repositories"
|
||||||
|
import * as ModuleServices from "@services"
|
||||||
|
import { OrderModuleService } from "@services"
|
||||||
|
|
||||||
|
const migrationScriptOptions = {
|
||||||
|
moduleName: Modules.ORDER,
|
||||||
|
models: Models,
|
||||||
|
pathToMigrations: __dirname + "/migrations",
|
||||||
|
}
|
||||||
|
|
||||||
|
const runMigrations = ModulesSdkUtils.buildMigrationScript(
|
||||||
|
migrationScriptOptions
|
||||||
|
)
|
||||||
|
|
||||||
|
const revertMigration = ModulesSdkUtils.buildRevertMigrationScript(
|
||||||
|
migrationScriptOptions
|
||||||
|
)
|
||||||
|
|
||||||
|
const containerLoader = ModulesSdkUtils.moduleContainerLoaderFactory({
|
||||||
|
moduleModels: ModuleModels,
|
||||||
|
moduleRepositories: ModuleRepositories,
|
||||||
|
moduleServices: ModuleServices,
|
||||||
|
})
|
||||||
|
|
||||||
|
const connectionLoader = ModulesSdkUtils.mikroOrmConnectionLoaderFactory({
|
||||||
|
moduleName: Modules.ORDER,
|
||||||
|
moduleModels: Object.values(Models),
|
||||||
|
migrationsPath: __dirname + "/migrations",
|
||||||
|
})
|
||||||
|
|
||||||
|
const service = OrderModuleService
|
||||||
|
const loaders = [containerLoader, connectionLoader] as any
|
||||||
|
|
||||||
|
export const moduleDefinition: ModuleExports = {
|
||||||
|
service,
|
||||||
|
loaders,
|
||||||
|
revertMigration,
|
||||||
|
runMigrations,
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils"
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
|
import { ModulesSdkUtils } from "@medusajs/utils"
|
||||||
|
import * as Models from "@models"
|
||||||
|
import { EOL } from "os"
|
||||||
|
|
||||||
|
const args = process.argv
|
||||||
|
const path = args.pop() as string
|
||||||
|
|
||||||
|
export default (async () => {
|
||||||
|
const { config } = await import("dotenv")
|
||||||
|
config()
|
||||||
|
if (!path) {
|
||||||
|
throw new Error(
|
||||||
|
`filePath is required.${EOL}Example: medusa-order-seed <filePath>`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const run = ModulesSdkUtils.buildSeedScript({
|
||||||
|
moduleName: Modules.ORDER,
|
||||||
|
models: Models,
|
||||||
|
pathToMigrations: __dirname + "/../../migrations",
|
||||||
|
seedHandler: async ({ manager, data }) => {
|
||||||
|
// TODO: Add seed logic
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await run({ path })
|
||||||
|
})()
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
describe("noop", function () {
|
||||||
|
it("should run", function () {
|
||||||
|
expect(true).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default as OrderModuleService } from "./order-module-service"
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
|||||||
|
import { BigNumberInput } from "@medusajs/types"
|
||||||
|
|
||||||
|
export interface UpdateOrderShippingMethodDTO {
|
||||||
|
id: string
|
||||||
|
name?: string
|
||||||
|
amount?: BigNumberInput
|
||||||
|
data?: Record<string, unknown>
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
export interface UpsertOrderAddressDTO {
|
||||||
|
customer_id?: string
|
||||||
|
company?: string
|
||||||
|
first_name?: string
|
||||||
|
last_name?: string
|
||||||
|
address_1?: string
|
||||||
|
address_2?: string
|
||||||
|
city?: string
|
||||||
|
country_code?: string
|
||||||
|
province?: string
|
||||||
|
postal_code?: string
|
||||||
|
phone?: string
|
||||||
|
metadata?: Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderAddressDTO extends UpsertOrderAddressDTO {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderAddressDTO extends UpsertOrderAddressDTO {}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { IEventBusModuleService, Logger } from "@medusajs/types"
|
||||||
|
|
||||||
|
export * from "./address"
|
||||||
|
export * from "./line-item"
|
||||||
|
export * from "./line-item-adjustment"
|
||||||
|
export * from "./line-item-tax-line"
|
||||||
|
export * from "./order"
|
||||||
|
export * from "./shipping-method"
|
||||||
|
export * from "./shipping-method-adjustment"
|
||||||
|
export * from "./shipping-method-tax-line"
|
||||||
|
|
||||||
|
export type InitializeModuleInjectableDependencies = {
|
||||||
|
logger?: Logger
|
||||||
|
eventBusService?: IEventBusModuleService
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { BigNumberInput } from "@medusajs/types"
|
||||||
|
|
||||||
|
export interface CreateOrderLineItemAdjustmentDTO {
|
||||||
|
item_id: string
|
||||||
|
amount: BigNumberInput
|
||||||
|
code?: string
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderLineItemAdjustmentDTO
|
||||||
|
extends Partial<CreateOrderLineItemAdjustmentDTO> {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { CreateOrderTaxLineDTO, UpdateOrderTaxLineDTO } from "./tax-line"
|
||||||
|
|
||||||
|
export interface CreateOrderLineItemTaxLineDTO extends CreateOrderTaxLineDTO {
|
||||||
|
item_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderLineItemTaxLineDTO extends UpdateOrderTaxLineDTO {
|
||||||
|
item_id: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { BigNumberInput } from "@medusajs/types"
|
||||||
|
|
||||||
|
interface PartialUpsertOrderLineItemDTO {
|
||||||
|
subtitle?: string
|
||||||
|
thumbnail?: string
|
||||||
|
|
||||||
|
product_id?: string
|
||||||
|
product_title?: string
|
||||||
|
product_description?: string
|
||||||
|
product_subtitle?: string
|
||||||
|
product_type?: string
|
||||||
|
product_collection?: string
|
||||||
|
product_handle?: string
|
||||||
|
|
||||||
|
variant_id?: string
|
||||||
|
variant_sku?: string
|
||||||
|
variant_barcode?: string
|
||||||
|
variant_title?: string
|
||||||
|
variant_option_values?: Record<string, unknown>
|
||||||
|
|
||||||
|
requires_shipping?: boolean
|
||||||
|
is_discountable?: boolean
|
||||||
|
is_tax_inclusive?: boolean
|
||||||
|
|
||||||
|
compare_at_unit_price?: BigNumberInput
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderLineItemDTO extends PartialUpsertOrderLineItemDTO {
|
||||||
|
title: string
|
||||||
|
quantity: BigNumberInput
|
||||||
|
unit_price: BigNumberInput
|
||||||
|
order_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderLineItemDTO
|
||||||
|
extends PartialUpsertOrderLineItemDTO,
|
||||||
|
Partial<CreateOrderLineItemDTO> {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { OrderStatus } from "@medusajs/utils"
|
||||||
|
import {
|
||||||
|
CreateOrderLineItemAdjustmentDTO,
|
||||||
|
UpdateOrderLineItemAdjustmentDTO,
|
||||||
|
} from "./line-item-adjustment"
|
||||||
|
|
||||||
|
export interface CreateOrderDTO {
|
||||||
|
region_id?: string
|
||||||
|
customer_id?: string
|
||||||
|
sales_channel_id?: string
|
||||||
|
email?: string
|
||||||
|
currency_code: string
|
||||||
|
status?: OrderStatus
|
||||||
|
no_notification?: boolean
|
||||||
|
metadata?: Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderDTO {
|
||||||
|
id: string
|
||||||
|
region_id?: string
|
||||||
|
customer_id?: string
|
||||||
|
sales_channel_id?: string
|
||||||
|
email?: string
|
||||||
|
currency_code?: string
|
||||||
|
status?: OrderStatus
|
||||||
|
no_notification?: boolean
|
||||||
|
metadata?: Record<string, unknown>
|
||||||
|
|
||||||
|
adjustments?: (
|
||||||
|
| CreateOrderLineItemAdjustmentDTO
|
||||||
|
| UpdateOrderLineItemAdjustmentDTO
|
||||||
|
)[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { BigNumberInput } from "@medusajs/types"
|
||||||
|
|
||||||
|
export interface CreateOrderShippingMethodAdjustmentDTO {
|
||||||
|
shipping_method_id: string
|
||||||
|
code: string
|
||||||
|
amount: BigNumberInput
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderShippingMethodAdjustmentDTO {
|
||||||
|
id: string
|
||||||
|
code?: string
|
||||||
|
amount?: BigNumberInput
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { CreateOrderTaxLineDTO, UpdateOrderTaxLineDTO } from "./tax-line"
|
||||||
|
|
||||||
|
export interface CreateOrderShippingMethodTaxLineDTO
|
||||||
|
extends CreateOrderTaxLineDTO {
|
||||||
|
shipping_method_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderShippingMethodTaxLineDTO
|
||||||
|
extends UpdateOrderTaxLineDTO {
|
||||||
|
shipping_method_id: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { BigNumberInput } from "@medusajs/types"
|
||||||
|
|
||||||
|
export interface CreateOrderShippingMethodDTO {
|
||||||
|
name: string
|
||||||
|
shipping_method_id: string
|
||||||
|
amount: BigNumberInput
|
||||||
|
data?: Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderShippingMethodDTO {
|
||||||
|
id: string
|
||||||
|
name?: string
|
||||||
|
amount?: BigNumberInput
|
||||||
|
data?: Record<string, unknown>
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { BigNumberInput } from "@medusajs/types"
|
||||||
|
|
||||||
|
export interface UpdateOrderTaxLineDTO {
|
||||||
|
id: string
|
||||||
|
description?: string
|
||||||
|
tax_rate_id?: string
|
||||||
|
code?: string
|
||||||
|
rate?: BigNumberInput
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderTaxLineDTO {
|
||||||
|
description?: string
|
||||||
|
tax_rate_id?: string
|
||||||
|
code: string
|
||||||
|
rate: BigNumberInput
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["es2020"],
|
||||||
|
"target": "es2020",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"declaration": true,
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"sourceMap": false,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"strictFunctionTypes": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"downlevelIteration": true, // to use ES5 specific tooling
|
||||||
|
"baseUrl": ".",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"paths": {
|
||||||
|
"@models": ["./src/models"],
|
||||||
|
"@services": ["./src/services"],
|
||||||
|
"@repositories": ["./src/repositories"],
|
||||||
|
"@types": ["./src/types"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": [
|
||||||
|
"dist",
|
||||||
|
"./src/**/__tests__",
|
||||||
|
"./src/**/__mocks__",
|
||||||
|
"./src/**/__fixtures__",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src", "integration-tests"],
|
||||||
|
"exclude": ["node_modules", "dist"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"sourceMap": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ export * as FulfillmentTypes from "./fulfillment"
|
|||||||
export * as InventoryTypes from "./inventory"
|
export * as InventoryTypes from "./inventory"
|
||||||
export * as LoggerTypes from "./logger"
|
export * as LoggerTypes from "./logger"
|
||||||
export * as ModulesSdkTypes from "./modules-sdk"
|
export * as ModulesSdkTypes from "./modules-sdk"
|
||||||
|
export * as OrderTypes from "./order"
|
||||||
export * as PricingTypes from "./pricing"
|
export * as PricingTypes from "./pricing"
|
||||||
export * as ProductTypes from "./product"
|
export * as ProductTypes from "./product"
|
||||||
export * as PromotionTypes from "./promotion"
|
export * as PromotionTypes from "./promotion"
|
||||||
@@ -20,4 +21,3 @@ export * as StockLocationTypes from "./stock-location"
|
|||||||
export * as TransactionBaseTypes from "./transaction-base"
|
export * as TransactionBaseTypes from "./transaction-base"
|
||||||
export * as UserTypes from "./user"
|
export * as UserTypes from "./user"
|
||||||
export * as WorkflowTypes from "./workflow"
|
export * as WorkflowTypes from "./workflow"
|
||||||
|
|
||||||
@@ -8,13 +8,14 @@ export * from "./customer"
|
|||||||
export * from "./dal"
|
export * from "./dal"
|
||||||
export * from "./event-bus"
|
export * from "./event-bus"
|
||||||
export * from "./feature-flag"
|
export * from "./feature-flag"
|
||||||
export * from "./fulfillment"
|
|
||||||
export * from "./file-service"
|
export * from "./file-service"
|
||||||
|
export * from "./fulfillment"
|
||||||
export * from "./inventory"
|
export * from "./inventory"
|
||||||
export * from "./joiner"
|
export * from "./joiner"
|
||||||
export * from "./link-modules"
|
export * from "./link-modules"
|
||||||
export * from "./logger"
|
export * from "./logger"
|
||||||
export * from "./modules-sdk"
|
export * from "./modules-sdk"
|
||||||
|
export * from "./order"
|
||||||
export * from "./payment"
|
export * from "./payment"
|
||||||
export * from "./pricing"
|
export * from "./pricing"
|
||||||
export * from "./product"
|
export * from "./product"
|
||||||
@@ -30,4 +31,3 @@ export * from "./totals"
|
|||||||
export * from "./transaction-base"
|
export * from "./transaction-base"
|
||||||
export * from "./user"
|
export * from "./user"
|
||||||
export * from "./workflow"
|
export * from "./workflow"
|
||||||
|
|
||||||
@@ -0,0 +1,570 @@
|
|||||||
|
import { BaseFilterable } from "../dal"
|
||||||
|
import { OperatorMap } from "../dal/utils"
|
||||||
|
|
||||||
|
export interface OrderAdjustmentLineDTO {
|
||||||
|
/**
|
||||||
|
* The ID of the adjustment line
|
||||||
|
*/
|
||||||
|
id: string
|
||||||
|
/**
|
||||||
|
* The code of the adjustment line
|
||||||
|
*/
|
||||||
|
code?: string
|
||||||
|
/**
|
||||||
|
* The amount of the adjustment line
|
||||||
|
*/
|
||||||
|
amount: number
|
||||||
|
/**
|
||||||
|
* The ID of the associated order
|
||||||
|
*/
|
||||||
|
order_id: string
|
||||||
|
/**
|
||||||
|
* The description of the adjustment line
|
||||||
|
*/
|
||||||
|
description?: string
|
||||||
|
/**
|
||||||
|
* The ID of the associated promotion
|
||||||
|
*/
|
||||||
|
promotion_id?: string
|
||||||
|
/**
|
||||||
|
* The ID of the associated provider
|
||||||
|
*/
|
||||||
|
provider_id?: string
|
||||||
|
/**
|
||||||
|
* When the adjustment line was created
|
||||||
|
*/
|
||||||
|
created_at: Date | string
|
||||||
|
/**
|
||||||
|
* When the adjustment line was updated
|
||||||
|
*/
|
||||||
|
updated_at: Date | string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderShippingMethodAdjustmentDTO
|
||||||
|
extends OrderAdjustmentLineDTO {
|
||||||
|
/**
|
||||||
|
* The associated shipping method
|
||||||
|
*/
|
||||||
|
shipping_method: OrderShippingMethodDTO
|
||||||
|
/**
|
||||||
|
* The ID of the associated shipping method
|
||||||
|
*/
|
||||||
|
shipping_method_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderLineItemAdjustmentDTO extends OrderAdjustmentLineDTO {
|
||||||
|
/**
|
||||||
|
* The associated line item
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
item: OrderLineItemDTO
|
||||||
|
/**
|
||||||
|
* The associated line item
|
||||||
|
*/
|
||||||
|
item_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderTaxLineDTO {
|
||||||
|
/**
|
||||||
|
* The ID of the tax line
|
||||||
|
*/
|
||||||
|
id: string
|
||||||
|
/**
|
||||||
|
* The description of the tax line
|
||||||
|
*/
|
||||||
|
description?: string
|
||||||
|
/**
|
||||||
|
* The ID of the associated tax rate
|
||||||
|
*/
|
||||||
|
tax_rate_id?: string
|
||||||
|
/**
|
||||||
|
* The code of the tax line
|
||||||
|
*/
|
||||||
|
code: string
|
||||||
|
/**
|
||||||
|
* The rate of the tax line
|
||||||
|
*/
|
||||||
|
rate: number
|
||||||
|
/**
|
||||||
|
* The ID of the associated provider
|
||||||
|
*/
|
||||||
|
provider_id?: string
|
||||||
|
/**
|
||||||
|
* When the tax line was created
|
||||||
|
*/
|
||||||
|
created_at: Date | string
|
||||||
|
/**
|
||||||
|
* When the tax line was updated
|
||||||
|
*/
|
||||||
|
updated_at: Date | string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderShippingMethodTaxLineDTO extends OrderTaxLineDTO {
|
||||||
|
/**
|
||||||
|
* The associated shipping method
|
||||||
|
*/
|
||||||
|
shipping_method: OrderShippingMethodDTO
|
||||||
|
/**
|
||||||
|
* The ID of the associated shipping method
|
||||||
|
*/
|
||||||
|
shipping_method_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderLineItemTaxLineDTO extends OrderTaxLineDTO {
|
||||||
|
/**
|
||||||
|
* The associated line item
|
||||||
|
*/
|
||||||
|
item: OrderLineItemDTO
|
||||||
|
/**
|
||||||
|
* The ID of the associated line item
|
||||||
|
*/
|
||||||
|
item_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderAddressDTO {
|
||||||
|
/**
|
||||||
|
* The ID of the address
|
||||||
|
*/
|
||||||
|
id: string
|
||||||
|
/**
|
||||||
|
* The customer ID of the address
|
||||||
|
*/
|
||||||
|
customer_id?: string
|
||||||
|
/**
|
||||||
|
* The first name of the address
|
||||||
|
*/
|
||||||
|
first_name?: string
|
||||||
|
/**
|
||||||
|
* The last name of the address
|
||||||
|
*/
|
||||||
|
last_name?: string
|
||||||
|
/**
|
||||||
|
* The phone number of the address
|
||||||
|
*/
|
||||||
|
phone?: string
|
||||||
|
/**
|
||||||
|
* The company of the address
|
||||||
|
*/
|
||||||
|
company?: string
|
||||||
|
/**
|
||||||
|
* The first address line of the address
|
||||||
|
*/
|
||||||
|
address_1?: string
|
||||||
|
/**
|
||||||
|
* The second address line of the address
|
||||||
|
*/
|
||||||
|
address_2?: string
|
||||||
|
/**
|
||||||
|
* The city of the address
|
||||||
|
*/
|
||||||
|
city?: string
|
||||||
|
/**
|
||||||
|
* The country code of the address
|
||||||
|
*/
|
||||||
|
country_code?: string
|
||||||
|
/**
|
||||||
|
* The province/state of the address
|
||||||
|
*/
|
||||||
|
province?: string
|
||||||
|
/**
|
||||||
|
* The postal code of the address
|
||||||
|
*/
|
||||||
|
postal_code?: string
|
||||||
|
/**
|
||||||
|
* Holds custom data in key-value pairs.
|
||||||
|
*/
|
||||||
|
metadata?: Record<string, unknown> | null
|
||||||
|
/**
|
||||||
|
* When the address was created.
|
||||||
|
*/
|
||||||
|
created_at: Date | string
|
||||||
|
/**
|
||||||
|
* When the address was updated.
|
||||||
|
*/
|
||||||
|
updated_at: Date | string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderShippingMethodDTO {
|
||||||
|
/**
|
||||||
|
* The ID of the shipping method
|
||||||
|
*/
|
||||||
|
id: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the associated order
|
||||||
|
*/
|
||||||
|
order_id: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the shipping method
|
||||||
|
*/
|
||||||
|
name: string
|
||||||
|
/**
|
||||||
|
* The description of the shipping method
|
||||||
|
*/
|
||||||
|
description?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The price of the shipping method
|
||||||
|
*/
|
||||||
|
unit_price: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the shipping method price is tax inclusive or not
|
||||||
|
*/
|
||||||
|
is_tax_inclusive: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the shipping option the method was created from
|
||||||
|
*/
|
||||||
|
shipping_option_id?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional data needed for fulfillment.
|
||||||
|
*/
|
||||||
|
data?: Record<string, unknown>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds custom data in key-value pairs.
|
||||||
|
*/
|
||||||
|
metadata?: Record<string, unknown> | null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The associated tax lines.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
tax_lines?: OrderShippingMethodTaxLineDTO[]
|
||||||
|
/**
|
||||||
|
* The associated adjustments.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
adjustments?: OrderShippingMethodAdjustmentDTO[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the shipping method was created.
|
||||||
|
*/
|
||||||
|
created_at: Date | string
|
||||||
|
/**
|
||||||
|
* When the shipping method was updated.
|
||||||
|
*/
|
||||||
|
updated_at: Date | string
|
||||||
|
|
||||||
|
original_total: number
|
||||||
|
original_subtotal: number
|
||||||
|
original_tax_total: number
|
||||||
|
|
||||||
|
total: number
|
||||||
|
subtotal: number
|
||||||
|
tax_total: number
|
||||||
|
discount_total: number
|
||||||
|
discount_tax_total: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderLineItemTotalsDTO {
|
||||||
|
original_total: number
|
||||||
|
original_subtotal: number
|
||||||
|
original_tax_total: number
|
||||||
|
|
||||||
|
item_total: number
|
||||||
|
item_subtotal: number
|
||||||
|
item_tax_total: number
|
||||||
|
|
||||||
|
total: number
|
||||||
|
subtotal: number
|
||||||
|
tax_total: number
|
||||||
|
discount_total: number
|
||||||
|
discount_tax_total: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderLineItemDTO extends OrderLineItemTotalsDTO {
|
||||||
|
/**
|
||||||
|
* The ID of the line item.
|
||||||
|
*/
|
||||||
|
id: string
|
||||||
|
/**
|
||||||
|
* The title of the line item.
|
||||||
|
*/
|
||||||
|
title: string
|
||||||
|
/**
|
||||||
|
* The subtitle of the line item.
|
||||||
|
*/
|
||||||
|
subtitle?: string
|
||||||
|
/**
|
||||||
|
* The url of the line item thumbnail.
|
||||||
|
*/
|
||||||
|
thumbnail?: string
|
||||||
|
/**
|
||||||
|
* The line item quantity
|
||||||
|
*/
|
||||||
|
quantity: number
|
||||||
|
/**
|
||||||
|
* The product ID of the line item.
|
||||||
|
*/
|
||||||
|
product_id?: string
|
||||||
|
/**
|
||||||
|
* The product title of the line item.
|
||||||
|
*/
|
||||||
|
product_title?: string
|
||||||
|
/**
|
||||||
|
* The product description of the line item.
|
||||||
|
*/
|
||||||
|
product_description?: string
|
||||||
|
/**
|
||||||
|
* The product subtitle of the line item.
|
||||||
|
*/
|
||||||
|
product_subtitle?: string
|
||||||
|
/**
|
||||||
|
* The product type of the line item.
|
||||||
|
*/
|
||||||
|
product_type?: string
|
||||||
|
/**
|
||||||
|
* The product collection of the line item.
|
||||||
|
*/
|
||||||
|
product_collection?: string
|
||||||
|
/**
|
||||||
|
* The product handle of the line item.
|
||||||
|
*/
|
||||||
|
product_handle?: string
|
||||||
|
/**
|
||||||
|
* The variant ID of the line item.
|
||||||
|
*/
|
||||||
|
variant_id?: string
|
||||||
|
/**
|
||||||
|
* The variant sku of the line item.
|
||||||
|
*/
|
||||||
|
variant_sku?: string
|
||||||
|
/**
|
||||||
|
* The variant barcode of the line item.
|
||||||
|
*/
|
||||||
|
variant_barcode?: string
|
||||||
|
/**
|
||||||
|
* The variant title of the line item.
|
||||||
|
*/
|
||||||
|
variant_title?: string
|
||||||
|
/**
|
||||||
|
* The variant option values of the line item.
|
||||||
|
*/
|
||||||
|
variant_option_values?: Record<string, unknown>
|
||||||
|
/**
|
||||||
|
* Whether the line item requires shipping or not
|
||||||
|
*/
|
||||||
|
requires_shipping: boolean
|
||||||
|
/**
|
||||||
|
* Whether the line item is discountable or not
|
||||||
|
*/
|
||||||
|
is_discountable: boolean
|
||||||
|
/**
|
||||||
|
* Whether the line item price is tax inclusive or not
|
||||||
|
*/
|
||||||
|
is_tax_inclusive: boolean
|
||||||
|
/**
|
||||||
|
* The original price of the item before an adjustment or a sale.
|
||||||
|
*/
|
||||||
|
compare_at_unit_price?: number
|
||||||
|
/**
|
||||||
|
* The price of the item
|
||||||
|
*/
|
||||||
|
unit_price: number
|
||||||
|
/**
|
||||||
|
* The associated tax lines.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
tax_lines?: OrderLineItemTaxLineDTO[]
|
||||||
|
/**
|
||||||
|
* The associated adjustments.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
adjustments?: OrderLineItemAdjustmentDTO[]
|
||||||
|
/**
|
||||||
|
* The associated order.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
order: OrderDTO
|
||||||
|
/**
|
||||||
|
* The ID of the associated order.
|
||||||
|
*/
|
||||||
|
order_id: string
|
||||||
|
/**
|
||||||
|
* Holds custom data in key-value pairs.
|
||||||
|
*/
|
||||||
|
metadata?: Record<string, unknown> | null
|
||||||
|
/**
|
||||||
|
* When the line item was created.
|
||||||
|
*/
|
||||||
|
created_at?: Date
|
||||||
|
/**
|
||||||
|
* When the line item was updated.
|
||||||
|
*/
|
||||||
|
updated_at?: Date
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderDTO {
|
||||||
|
/**
|
||||||
|
* The ID of the order.
|
||||||
|
*/
|
||||||
|
id: string
|
||||||
|
/**
|
||||||
|
* The ID of the region the order belongs to.
|
||||||
|
*/
|
||||||
|
region_id?: string
|
||||||
|
/**
|
||||||
|
* The ID of the customer on the order.
|
||||||
|
*/
|
||||||
|
customer_id?: string
|
||||||
|
/**
|
||||||
|
* The ID of the sales channel the order belongs to.
|
||||||
|
*/
|
||||||
|
sales_channel_id?: string
|
||||||
|
/**
|
||||||
|
* The email of the order.
|
||||||
|
*/
|
||||||
|
email?: string
|
||||||
|
/**
|
||||||
|
* The currency of the order
|
||||||
|
*/
|
||||||
|
currency_code: string
|
||||||
|
/**
|
||||||
|
* The associated shipping address.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
shipping_address?: OrderAddressDTO
|
||||||
|
/**
|
||||||
|
* The associated billing address.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
billing_address?: OrderAddressDTO
|
||||||
|
/**
|
||||||
|
* The associated line items.
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
items?: OrderLineItemDTO[]
|
||||||
|
/**
|
||||||
|
* The associated shipping methods
|
||||||
|
*
|
||||||
|
* @expandable
|
||||||
|
*/
|
||||||
|
shipping_methods?: OrderShippingMethodDTO[]
|
||||||
|
/**
|
||||||
|
* Holds custom data in key-value pairs.
|
||||||
|
*/
|
||||||
|
metadata?: Record<string, unknown> | null
|
||||||
|
/**
|
||||||
|
* When the order was created.
|
||||||
|
*/
|
||||||
|
created_at?: string | Date
|
||||||
|
/**
|
||||||
|
* When the order was updated.
|
||||||
|
*/
|
||||||
|
updated_at?: string | Date
|
||||||
|
|
||||||
|
original_item_total: number
|
||||||
|
original_item_subtotal: number
|
||||||
|
original_item_tax_total: number
|
||||||
|
|
||||||
|
item_total: number
|
||||||
|
item_subtotal: number
|
||||||
|
item_tax_total: number
|
||||||
|
|
||||||
|
original_total: number
|
||||||
|
original_subtotal: number
|
||||||
|
original_tax_total: number
|
||||||
|
|
||||||
|
total: number
|
||||||
|
subtotal: number
|
||||||
|
tax_total: number
|
||||||
|
discount_total: number
|
||||||
|
raw_discount_total: any
|
||||||
|
discount_tax_total: number
|
||||||
|
|
||||||
|
gift_card_total: number
|
||||||
|
gift_card_tax_total: number
|
||||||
|
|
||||||
|
shipping_total: number
|
||||||
|
shipping_subtotal: number
|
||||||
|
shipping_tax_total: number
|
||||||
|
|
||||||
|
original_shipping_total: number
|
||||||
|
original_shipping_subtotal: number
|
||||||
|
original_shipping_tax_total: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FilterableOrderProps
|
||||||
|
extends BaseFilterable<FilterableOrderProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
|
||||||
|
sales_channel_id?: string | string[] | OperatorMap<string>
|
||||||
|
customer_id?: string | string[] | OperatorMap<string>
|
||||||
|
region_id?: string | string[] | OperatorMap<string>
|
||||||
|
|
||||||
|
created_at?: OperatorMap<string>
|
||||||
|
updated_at?: OperatorMap<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FilterableOrderAddressProps
|
||||||
|
extends BaseFilterable<FilterableOrderAddressProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FilterableOrderLineItemProps
|
||||||
|
extends BaseFilterable<FilterableOrderLineItemProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
order_id?: string | string[]
|
||||||
|
title?: string
|
||||||
|
variant_id?: string | string[]
|
||||||
|
product_id?: string | string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FilterableOrderLineItemAdjustmentProps
|
||||||
|
extends BaseFilterable<FilterableOrderLineItemAdjustmentProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
item_id?: string | string[]
|
||||||
|
promotion_id?: string | string[]
|
||||||
|
provider_id?: string | string[]
|
||||||
|
item?: FilterableOrderLineItemProps
|
||||||
|
}
|
||||||
|
export interface FilterableOrderShippingMethodProps
|
||||||
|
extends BaseFilterable<FilterableOrderShippingMethodProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
order_id?: string | string[]
|
||||||
|
name?: string
|
||||||
|
shipping_option_id?: string | string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FilterableOrderShippingMethodAdjustmentProps
|
||||||
|
extends BaseFilterable<FilterableOrderShippingMethodAdjustmentProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
shipping_method_id?: string | string[]
|
||||||
|
promotion_id?: string | string[]
|
||||||
|
provider_id?: string | string[]
|
||||||
|
shipping_method?: FilterableOrderShippingMethodProps
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FilterableOrderLineItemTaxLineProps
|
||||||
|
extends BaseFilterable<FilterableOrderLineItemTaxLineProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
description?: string
|
||||||
|
code?: string | string[]
|
||||||
|
tax_rate_id?: string | string[]
|
||||||
|
provider_id?: string | string[]
|
||||||
|
item_id?: string | string[]
|
||||||
|
item?: FilterableOrderLineItemProps
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FilterableOrderShippingMethodTaxLineProps
|
||||||
|
extends BaseFilterable<FilterableOrderShippingMethodTaxLineProps> {
|
||||||
|
id?: string | string[]
|
||||||
|
description?: string
|
||||||
|
code?: string | string[]
|
||||||
|
tax_rate_id?: string | string[]
|
||||||
|
provider_id?: string | string[]
|
||||||
|
shipping_method_id?: string | string[]
|
||||||
|
shipping_method?: FilterableOrderShippingMethodProps
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export * from "./common"
|
||||||
|
export * from "./mutations"
|
||||||
|
export * from "./service"
|
||||||
@@ -0,0 +1,241 @@
|
|||||||
|
import { OrderLineItemDTO } from "./common"
|
||||||
|
|
||||||
|
/** ADDRESS START */
|
||||||
|
export interface UpsertOrderAddressDTO {
|
||||||
|
customer_id?: string
|
||||||
|
company?: string
|
||||||
|
first_name?: string
|
||||||
|
last_name?: string
|
||||||
|
address_1?: string
|
||||||
|
address_2?: string
|
||||||
|
city?: string
|
||||||
|
country_code?: string
|
||||||
|
province?: string
|
||||||
|
postal_code?: string
|
||||||
|
phone?: string
|
||||||
|
metadata?: Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderAddressDTO extends UpsertOrderAddressDTO {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderAddressDTO extends UpsertOrderAddressDTO {}
|
||||||
|
|
||||||
|
/** ADDRESS END */
|
||||||
|
|
||||||
|
/** ORDER START */
|
||||||
|
export interface CreateOrderDTO {
|
||||||
|
region_id?: string
|
||||||
|
customer_id?: string
|
||||||
|
sales_channel_id?: string
|
||||||
|
status?: string
|
||||||
|
email?: string
|
||||||
|
currency_code: string
|
||||||
|
shipping_address_id?: string
|
||||||
|
billing_address_id?: string
|
||||||
|
shipping_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO
|
||||||
|
billing_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO
|
||||||
|
no_notification?: boolean
|
||||||
|
metadata?: Record<string, unknown>
|
||||||
|
|
||||||
|
items?: CreateOrderLineItemDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderDTO {
|
||||||
|
id: string
|
||||||
|
region_id?: string
|
||||||
|
customer_id?: string
|
||||||
|
sales_channel_id?: string
|
||||||
|
status?: string
|
||||||
|
email?: string
|
||||||
|
currency_code?: string
|
||||||
|
shipping_address_id?: string
|
||||||
|
billing_address_id?: string
|
||||||
|
billing_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO
|
||||||
|
shipping_address?: CreateOrderAddressDTO | UpdateOrderAddressDTO
|
||||||
|
no_notification?: boolean
|
||||||
|
metadata?: Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ORDER END */
|
||||||
|
|
||||||
|
/** ADJUSTMENT START */
|
||||||
|
export interface CreateOrderAdjustmentDTO {
|
||||||
|
code: string
|
||||||
|
amount: number
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderAdjustmentDTO {
|
||||||
|
id: string
|
||||||
|
code?: string
|
||||||
|
amount: number
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderLineItemAdjustmentDTO
|
||||||
|
extends CreateOrderAdjustmentDTO {
|
||||||
|
item_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderLineItemAdjustmentDTO
|
||||||
|
extends UpdateOrderAdjustmentDTO {
|
||||||
|
item_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpsertOrderLineItemAdjustmentDTO {
|
||||||
|
id?: string
|
||||||
|
item_id: string
|
||||||
|
code?: string
|
||||||
|
amount?: number
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ADJUSTMENTS END */
|
||||||
|
|
||||||
|
/** TAX LINES START */
|
||||||
|
|
||||||
|
export interface CreateOrderTaxLineDTO {
|
||||||
|
description?: string
|
||||||
|
tax_rate_id?: string
|
||||||
|
code: string
|
||||||
|
rate: number
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderTaxLineDTO {
|
||||||
|
id: string
|
||||||
|
description?: string
|
||||||
|
tax_rate_id?: string
|
||||||
|
code?: string
|
||||||
|
rate?: number
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderShippingMethodTaxLineDTO
|
||||||
|
extends CreateOrderTaxLineDTO {}
|
||||||
|
|
||||||
|
export interface UpdateOrderShippingMethodTaxLineDTO
|
||||||
|
extends UpdateOrderTaxLineDTO {}
|
||||||
|
|
||||||
|
export interface CreateOrderLineItemTaxLineDTO extends CreateOrderTaxLineDTO {}
|
||||||
|
|
||||||
|
export interface UpdateOrderLineItemTaxLineDTO extends UpdateOrderTaxLineDTO {}
|
||||||
|
|
||||||
|
/** TAX LINES END */
|
||||||
|
|
||||||
|
/** LINE ITEMS START */
|
||||||
|
export interface CreateOrderLineItemDTO {
|
||||||
|
title: string
|
||||||
|
subtitle?: string
|
||||||
|
thumbnail?: string
|
||||||
|
|
||||||
|
order_id?: string
|
||||||
|
|
||||||
|
quantity: number
|
||||||
|
|
||||||
|
product_id?: string
|
||||||
|
product_title?: string
|
||||||
|
product_description?: string
|
||||||
|
product_subtitle?: string
|
||||||
|
product_type?: string
|
||||||
|
product_collection?: string
|
||||||
|
product_handle?: string
|
||||||
|
|
||||||
|
variant_id?: string
|
||||||
|
variant_sku?: string
|
||||||
|
variant_barcode?: string
|
||||||
|
variant_title?: string
|
||||||
|
variant_option_values?: Record<string, unknown>
|
||||||
|
|
||||||
|
requires_shipping?: boolean
|
||||||
|
is_discountable?: boolean
|
||||||
|
is_tax_inclusive?: boolean
|
||||||
|
|
||||||
|
compare_at_unit_price?: number
|
||||||
|
unit_price: number | string
|
||||||
|
|
||||||
|
tax_lines?: CreateOrderTaxLineDTO[]
|
||||||
|
adjustments?: CreateOrderAdjustmentDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderLineItemForOrderDTO extends CreateOrderLineItemDTO {
|
||||||
|
order_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderLineItemWithSelectorDTO {
|
||||||
|
selector: Partial<OrderLineItemDTO>
|
||||||
|
data: Partial<UpdateOrderLineItemDTO>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderLineItemDTO
|
||||||
|
extends Omit<
|
||||||
|
CreateOrderLineItemDTO,
|
||||||
|
"tax_lines" | "adjustments" | "title" | "quantity" | "unit_price"
|
||||||
|
> {
|
||||||
|
id: string
|
||||||
|
|
||||||
|
title?: string
|
||||||
|
quantity?: number
|
||||||
|
unit_price?: number
|
||||||
|
|
||||||
|
tax_lines?: UpdateOrderTaxLineDTO[] | CreateOrderTaxLineDTO[]
|
||||||
|
adjustments?: UpdateOrderAdjustmentDTO[] | CreateOrderAdjustmentDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** LINE ITEMS END */
|
||||||
|
|
||||||
|
/** SHIPPING METHODS START */
|
||||||
|
|
||||||
|
export interface CreateOrderShippingMethodDTO {
|
||||||
|
name: string
|
||||||
|
order_id: string
|
||||||
|
amount: number
|
||||||
|
data?: Record<string, unknown>
|
||||||
|
tax_lines?: CreateOrderTaxLineDTO[]
|
||||||
|
adjustments?: CreateOrderAdjustmentDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderShippingMethodForSingleOrderDTO {
|
||||||
|
name: string
|
||||||
|
amount: number
|
||||||
|
data?: Record<string, unknown>
|
||||||
|
tax_lines?: CreateOrderTaxLineDTO[]
|
||||||
|
adjustments?: CreateOrderAdjustmentDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderShippingMethodDTO {
|
||||||
|
id: string
|
||||||
|
name?: string
|
||||||
|
amount?: number
|
||||||
|
data?: Record<string, unknown>
|
||||||
|
tax_lines?: UpdateOrderTaxLineDTO[] | CreateOrderTaxLineDTO[]
|
||||||
|
adjustments?: CreateOrderAdjustmentDTO[] | UpdateOrderAdjustmentDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrderShippingMethodAdjustmentDTO {
|
||||||
|
shipping_method_id: string
|
||||||
|
code: string
|
||||||
|
amount: number
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrderShippingMethodAdjustmentDTO {
|
||||||
|
id: string
|
||||||
|
code?: string
|
||||||
|
amount?: number
|
||||||
|
description?: string
|
||||||
|
promotion_id?: string
|
||||||
|
provider_id?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** SHIPPING METHODS END */
|
||||||
@@ -0,0 +1,328 @@
|
|||||||
|
import { FindConfig } from "../common"
|
||||||
|
import { IModuleService } from "../modules-sdk"
|
||||||
|
import { Context } from "../shared-context"
|
||||||
|
import {
|
||||||
|
FilterableOrderAddressProps,
|
||||||
|
FilterableOrderLineItemAdjustmentProps,
|
||||||
|
FilterableOrderLineItemProps,
|
||||||
|
FilterableOrderLineItemTaxLineProps,
|
||||||
|
FilterableOrderProps,
|
||||||
|
FilterableOrderShippingMethodAdjustmentProps,
|
||||||
|
FilterableOrderShippingMethodProps,
|
||||||
|
FilterableOrderShippingMethodTaxLineProps,
|
||||||
|
OrderAddressDTO,
|
||||||
|
OrderDTO,
|
||||||
|
OrderLineItemAdjustmentDTO,
|
||||||
|
OrderLineItemDTO,
|
||||||
|
OrderLineItemTaxLineDTO,
|
||||||
|
OrderShippingMethodAdjustmentDTO,
|
||||||
|
OrderShippingMethodDTO,
|
||||||
|
OrderShippingMethodTaxLineDTO,
|
||||||
|
} from "./common"
|
||||||
|
import {
|
||||||
|
CreateOrderAddressDTO,
|
||||||
|
CreateOrderAdjustmentDTO,
|
||||||
|
CreateOrderDTO,
|
||||||
|
CreateOrderLineItemDTO,
|
||||||
|
CreateOrderLineItemForOrderDTO,
|
||||||
|
CreateOrderLineItemTaxLineDTO,
|
||||||
|
CreateOrderShippingMethodAdjustmentDTO,
|
||||||
|
CreateOrderShippingMethodDTO,
|
||||||
|
CreateOrderShippingMethodForSingleOrderDTO,
|
||||||
|
CreateOrderShippingMethodTaxLineDTO,
|
||||||
|
UpdateOrderAddressDTO,
|
||||||
|
UpdateOrderDTO,
|
||||||
|
UpdateOrderLineItemDTO,
|
||||||
|
UpdateOrderLineItemTaxLineDTO,
|
||||||
|
UpdateOrderLineItemWithSelectorDTO,
|
||||||
|
UpdateOrderShippingMethodAdjustmentDTO,
|
||||||
|
UpdateOrderShippingMethodTaxLineDTO,
|
||||||
|
UpsertOrderLineItemAdjustmentDTO,
|
||||||
|
} from "./mutations"
|
||||||
|
|
||||||
|
export interface IOrderModuleService extends IModuleService {
|
||||||
|
retrieve(
|
||||||
|
orderId: string,
|
||||||
|
config?: FindConfig<OrderDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderDTO>
|
||||||
|
|
||||||
|
list(
|
||||||
|
filters?: FilterableOrderProps,
|
||||||
|
config?: FindConfig<OrderDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderDTO[]>
|
||||||
|
|
||||||
|
listAndCount(
|
||||||
|
filters?: FilterableOrderProps,
|
||||||
|
config?: FindConfig<OrderDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<[OrderDTO[], number]>
|
||||||
|
|
||||||
|
create(data: CreateOrderDTO[], sharedContext?: Context): Promise<OrderDTO[]>
|
||||||
|
create(data: CreateOrderDTO, sharedContext?: Context): Promise<OrderDTO>
|
||||||
|
|
||||||
|
update(data: UpdateOrderDTO[], sharedContext?: Context): Promise<OrderDTO[]>
|
||||||
|
update(data: UpdateOrderDTO, sharedContext?: Context): Promise<OrderDTO>
|
||||||
|
|
||||||
|
delete(orderIds: string[], sharedContext?: Context): Promise<void>
|
||||||
|
delete(orderId: string, sharedContext?: Context): Promise<void>
|
||||||
|
|
||||||
|
listAddresses(
|
||||||
|
filters?: FilterableOrderAddressProps,
|
||||||
|
config?: FindConfig<OrderAddressDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderAddressDTO[]>
|
||||||
|
|
||||||
|
createAddresses(
|
||||||
|
data: CreateOrderAddressDTO[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderAddressDTO[]>
|
||||||
|
createAddresses(
|
||||||
|
data: CreateOrderAddressDTO,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderAddressDTO>
|
||||||
|
|
||||||
|
updateAddresses(
|
||||||
|
data: UpdateOrderAddressDTO[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderAddressDTO[]>
|
||||||
|
updateAddresses(
|
||||||
|
data: UpdateOrderAddressDTO,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderAddressDTO>
|
||||||
|
|
||||||
|
deleteAddresses(ids: string[], sharedContext?: Context): Promise<void>
|
||||||
|
deleteAddresses(ids: string, sharedContext?: Context): Promise<void>
|
||||||
|
|
||||||
|
retrieveLineItem(
|
||||||
|
itemId: string,
|
||||||
|
config?: FindConfig<OrderLineItemDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemDTO>
|
||||||
|
|
||||||
|
listLineItems(
|
||||||
|
filters: FilterableOrderLineItemProps,
|
||||||
|
config?: FindConfig<OrderLineItemDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemDTO[]>
|
||||||
|
|
||||||
|
addLineItems(
|
||||||
|
data: CreateOrderLineItemForOrderDTO
|
||||||
|
): Promise<OrderLineItemDTO[]>
|
||||||
|
addLineItems(
|
||||||
|
data: CreateOrderLineItemForOrderDTO[]
|
||||||
|
): Promise<OrderLineItemDTO[]>
|
||||||
|
addLineItems(
|
||||||
|
orderId: string,
|
||||||
|
items: CreateOrderLineItemDTO[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemDTO[]>
|
||||||
|
|
||||||
|
updateLineItems(
|
||||||
|
data: UpdateOrderLineItemWithSelectorDTO[]
|
||||||
|
): Promise<OrderLineItemDTO[]>
|
||||||
|
updateLineItems(
|
||||||
|
selector: Partial<OrderLineItemDTO>,
|
||||||
|
data: Partial<UpdateOrderLineItemDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemDTO[]>
|
||||||
|
updateLineItems(
|
||||||
|
lineId: string,
|
||||||
|
data: Partial<UpdateOrderLineItemDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemDTO>
|
||||||
|
|
||||||
|
removeLineItems(itemIds: string[], sharedContext?: Context): Promise<void>
|
||||||
|
removeLineItems(itemIds: string, sharedContext?: Context): Promise<void>
|
||||||
|
removeLineItems(
|
||||||
|
selector: Partial<OrderLineItemDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
listShippingMethods(
|
||||||
|
filters: FilterableOrderShippingMethodProps,
|
||||||
|
config: FindConfig<OrderShippingMethodDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodDTO[]>
|
||||||
|
|
||||||
|
addShippingMethods(
|
||||||
|
data: CreateOrderShippingMethodDTO
|
||||||
|
): Promise<OrderShippingMethodDTO>
|
||||||
|
addShippingMethods(
|
||||||
|
data: CreateOrderShippingMethodDTO[]
|
||||||
|
): Promise<OrderShippingMethodDTO[]>
|
||||||
|
addShippingMethods(
|
||||||
|
orderId: string,
|
||||||
|
methods: CreateOrderShippingMethodForSingleOrderDTO[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodDTO[]>
|
||||||
|
|
||||||
|
removeShippingMethods(
|
||||||
|
methodIds: string[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeShippingMethods(
|
||||||
|
methodIds: string,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeShippingMethods(
|
||||||
|
selector: Partial<OrderShippingMethodDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
listLineItemAdjustments(
|
||||||
|
filters: FilterableOrderLineItemAdjustmentProps,
|
||||||
|
config?: FindConfig<OrderLineItemAdjustmentDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemAdjustmentDTO[]>
|
||||||
|
|
||||||
|
addLineItemAdjustments(
|
||||||
|
data: CreateOrderAdjustmentDTO[]
|
||||||
|
): Promise<OrderLineItemAdjustmentDTO[]>
|
||||||
|
addLineItemAdjustments(
|
||||||
|
data: CreateOrderAdjustmentDTO
|
||||||
|
): Promise<OrderLineItemAdjustmentDTO[]>
|
||||||
|
addLineItemAdjustments(
|
||||||
|
orderId: string,
|
||||||
|
data: CreateOrderAdjustmentDTO[]
|
||||||
|
): Promise<OrderLineItemAdjustmentDTO[]>
|
||||||
|
|
||||||
|
setLineItemAdjustments(
|
||||||
|
orderId: string,
|
||||||
|
data: UpsertOrderLineItemAdjustmentDTO[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemAdjustmentDTO[]>
|
||||||
|
|
||||||
|
removeLineItemAdjustments(
|
||||||
|
adjustmentIds: string[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeLineItemAdjustments(
|
||||||
|
adjustmentIds: string,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeLineItemAdjustments(
|
||||||
|
selector: Partial<OrderLineItemAdjustmentDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
listShippingMethodAdjustments(
|
||||||
|
filters: FilterableOrderShippingMethodAdjustmentProps,
|
||||||
|
config?: FindConfig<OrderShippingMethodAdjustmentDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodAdjustmentDTO[]>
|
||||||
|
|
||||||
|
addShippingMethodAdjustments(
|
||||||
|
data: CreateOrderShippingMethodAdjustmentDTO[]
|
||||||
|
): Promise<OrderShippingMethodAdjustmentDTO[]>
|
||||||
|
addShippingMethodAdjustments(
|
||||||
|
data: CreateOrderShippingMethodAdjustmentDTO
|
||||||
|
): Promise<OrderShippingMethodAdjustmentDTO>
|
||||||
|
addShippingMethodAdjustments(
|
||||||
|
orderId: string,
|
||||||
|
data: CreateOrderShippingMethodAdjustmentDTO[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodAdjustmentDTO[]>
|
||||||
|
|
||||||
|
setShippingMethodAdjustments(
|
||||||
|
orderId: string,
|
||||||
|
data: (
|
||||||
|
| CreateOrderShippingMethodAdjustmentDTO
|
||||||
|
| UpdateOrderShippingMethodAdjustmentDTO
|
||||||
|
)[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodAdjustmentDTO[]>
|
||||||
|
|
||||||
|
removeShippingMethodAdjustments(
|
||||||
|
adjustmentIds: string[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeShippingMethodAdjustments(
|
||||||
|
adjustmentId: string,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeShippingMethodAdjustments(
|
||||||
|
selector: Partial<OrderShippingMethodAdjustmentDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
listLineItemTaxLines(
|
||||||
|
filters: FilterableOrderLineItemTaxLineProps,
|
||||||
|
config?: FindConfig<OrderLineItemTaxLineDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemTaxLineDTO[]>
|
||||||
|
|
||||||
|
addLineItemTaxLines(
|
||||||
|
taxLines: CreateOrderLineItemTaxLineDTO[]
|
||||||
|
): Promise<OrderLineItemTaxLineDTO[]>
|
||||||
|
addLineItemTaxLines(
|
||||||
|
taxLine: CreateOrderLineItemTaxLineDTO
|
||||||
|
): Promise<OrderLineItemTaxLineDTO>
|
||||||
|
addLineItemTaxLines(
|
||||||
|
orderId: string,
|
||||||
|
taxLines: CreateOrderLineItemTaxLineDTO[] | CreateOrderLineItemTaxLineDTO,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemTaxLineDTO[]>
|
||||||
|
|
||||||
|
setLineItemTaxLines(
|
||||||
|
orderId: string,
|
||||||
|
taxLines: (CreateOrderLineItemTaxLineDTO | UpdateOrderLineItemTaxLineDTO)[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderLineItemTaxLineDTO[]>
|
||||||
|
|
||||||
|
removeLineItemTaxLines(
|
||||||
|
taxLineIds: string[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeLineItemTaxLines(
|
||||||
|
taxLineIds: string,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeLineItemTaxLines(
|
||||||
|
selector: FilterableOrderLineItemTaxLineProps,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
listShippingMethodTaxLines(
|
||||||
|
filters: FilterableOrderShippingMethodTaxLineProps,
|
||||||
|
config?: FindConfig<OrderShippingMethodTaxLineDTO>,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodTaxLineDTO[]>
|
||||||
|
|
||||||
|
addShippingMethodTaxLines(
|
||||||
|
taxLines: CreateOrderShippingMethodTaxLineDTO[]
|
||||||
|
): Promise<OrderShippingMethodTaxLineDTO[]>
|
||||||
|
addShippingMethodTaxLines(
|
||||||
|
taxLine: CreateOrderShippingMethodTaxLineDTO
|
||||||
|
): Promise<OrderShippingMethodTaxLineDTO>
|
||||||
|
addShippingMethodTaxLines(
|
||||||
|
orderId: string,
|
||||||
|
taxLines:
|
||||||
|
| CreateOrderShippingMethodTaxLineDTO[]
|
||||||
|
| CreateOrderShippingMethodTaxLineDTO,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodTaxLineDTO[]>
|
||||||
|
|
||||||
|
setShippingMethodTaxLines(
|
||||||
|
orderId: string,
|
||||||
|
taxLines: (
|
||||||
|
| CreateOrderShippingMethodTaxLineDTO
|
||||||
|
| UpdateOrderShippingMethodTaxLineDTO
|
||||||
|
)[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<OrderShippingMethodTaxLineDTO[]>
|
||||||
|
|
||||||
|
removeShippingMethodTaxLines(
|
||||||
|
taxLineIds: string[],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeShippingMethodTaxLines(
|
||||||
|
taxLineIds: string,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
removeShippingMethodTaxLines(
|
||||||
|
selector: FilterableOrderShippingMethodTaxLineProps,
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<void>
|
||||||
|
}
|
||||||
@@ -5,8 +5,4 @@ export type BigNumberRawValue = {
|
|||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BigNumberRawPriceInput =
|
export type BigNumberInput = BigNumberRawValue | number | string | BigNumber
|
||||||
| BigNumberRawValue
|
|
||||||
| number
|
|
||||||
| string
|
|
||||||
| BigNumber
|
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
|
Filter,
|
||||||
|
Index,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
OptionalProps,
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
Index,
|
|
||||||
Filter,
|
|
||||||
OptionalProps,
|
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
|
|
||||||
|
import { DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
DALUtils,
|
DALUtils,
|
||||||
generateEntityId,
|
|
||||||
createPsqlIndexStatementHelper,
|
createPsqlIndexStatementHelper,
|
||||||
|
generateEntityId,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { DAL } from "@medusajs/types"
|
|
||||||
|
|
||||||
const inviteEmailIndexName = "IDX_invite_email"
|
const inviteEmailIndexName = "IDX_invite_email"
|
||||||
const inviteEmailIndexStatement = createPsqlIndexStatementHelper({
|
const inviteEmailIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -23,7 +23,7 @@ const inviteEmailIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
columns: "email",
|
columns: "email",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
unique: true,
|
unique: true,
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const inviteTokenIndexName = "IDX_invite_token"
|
const inviteTokenIndexName = "IDX_invite_token"
|
||||||
const inviteTokenIndexStatement = createPsqlIndexStatementHelper({
|
const inviteTokenIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -31,7 +31,7 @@ const inviteTokenIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "invite",
|
tableName: "invite",
|
||||||
columns: "token",
|
columns: "token",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const inviteDeletedAtIndexName = "IDX_invite_deleted_at"
|
const inviteDeletedAtIndexName = "IDX_invite_deleted_at"
|
||||||
const inviteDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
const inviteDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -39,7 +39,7 @@ const inviteDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "invite",
|
tableName: "invite",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
type OptionalFields =
|
type OptionalFields =
|
||||||
| "metadata"
|
| "metadata"
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
|
Filter,
|
||||||
|
Index,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
OptionalProps,
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
Property,
|
Property,
|
||||||
Index,
|
|
||||||
OptionalProps,
|
|
||||||
Filter,
|
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
|
|
||||||
import { DALUtils, generateEntityId } from "@medusajs/utils"
|
|
||||||
import { DAL } from "@medusajs/types"
|
import { DAL } from "@medusajs/types"
|
||||||
import { createPsqlIndexStatementHelper } from "@medusajs/utils"
|
import {
|
||||||
|
DALUtils,
|
||||||
|
createPsqlIndexStatementHelper,
|
||||||
|
generateEntityId,
|
||||||
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
const userEmailIndexName = "IDX_user_email"
|
const userEmailIndexName = "IDX_user_email"
|
||||||
const userEmailIndexStatement = createPsqlIndexStatementHelper({
|
const userEmailIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -19,7 +22,7 @@ const userEmailIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "user",
|
tableName: "user",
|
||||||
columns: "email",
|
columns: "email",
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
const userDeletedAtIndexName = "IDX_user_deleted_at"
|
const userDeletedAtIndexName = "IDX_user_deleted_at"
|
||||||
const userDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
const userDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
||||||
@@ -27,7 +30,7 @@ const userDeletedAtIndexStatement = createPsqlIndexStatementHelper({
|
|||||||
tableName: "user",
|
tableName: "user",
|
||||||
columns: "deleted_at",
|
columns: "deleted_at",
|
||||||
where: "deleted_at IS NOT NULL",
|
where: "deleted_at IS NOT NULL",
|
||||||
})
|
}).expression
|
||||||
|
|
||||||
type OptionalFields =
|
type OptionalFields =
|
||||||
| "first_name"
|
| "first_name"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export * as FeatureFlagUtils from "./feature-flags"
|
|||||||
export * as FulfillmentUtils from "./fulfillment"
|
export * as FulfillmentUtils from "./fulfillment"
|
||||||
export * as ModulesSdkUtils from "./modules-sdk"
|
export * as ModulesSdkUtils from "./modules-sdk"
|
||||||
export * as OrchestrationUtils from "./orchestration"
|
export * as OrchestrationUtils from "./orchestration"
|
||||||
|
export * as OrderUtils from "./order"
|
||||||
export * as ProductUtils from "./product"
|
export * as ProductUtils from "./product"
|
||||||
export * as PromotionUtils from "./promotion"
|
export * as PromotionUtils from "./promotion"
|
||||||
export * as SearchUtils from "./search"
|
export * as SearchUtils from "./search"
|
||||||
|
|||||||
@@ -9,11 +9,23 @@ describe("createPsqlIndexStatementHelper", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||||
expect(indexStatement).toEqual(
|
expect(indexStatement + "").toEqual(
|
||||||
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${options.tableName}" (${options.columns})`
|
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${options.tableName}" (${options.columns})`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should generate a simple index and auto compose its name", function () {
|
||||||
|
const options = {
|
||||||
|
tableName: "table_name",
|
||||||
|
columns: "column_name",
|
||||||
|
}
|
||||||
|
|
||||||
|
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||||
|
expect(indexStatement + "").toEqual(
|
||||||
|
`CREATE INDEX IF NOT EXISTS "IDX_table_name_column_name" ON "${options.tableName}" (${options.columns})`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it("should generate a composite index", function () {
|
it("should generate a composite index", function () {
|
||||||
const options = {
|
const options = {
|
||||||
name: "index_name",
|
name: "index_name",
|
||||||
@@ -22,7 +34,7 @@ describe("createPsqlIndexStatementHelper", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||||
expect(indexStatement).toEqual(
|
expect(indexStatement.expression).toEqual(
|
||||||
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${
|
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${
|
||||||
options.tableName
|
options.tableName
|
||||||
}" (${options.columns.join(", ")})`
|
}" (${options.columns.join(", ")})`
|
||||||
@@ -38,7 +50,7 @@ describe("createPsqlIndexStatementHelper", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||||
expect(indexStatement).toEqual(
|
expect(indexStatement.expression).toEqual(
|
||||||
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${
|
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${
|
||||||
options.tableName
|
options.tableName
|
||||||
}" (${options.columns.join(", ")}) WHERE ${options.where}`
|
}" (${options.columns.join(", ")}) WHERE ${options.where}`
|
||||||
@@ -55,7 +67,7 @@ describe("createPsqlIndexStatementHelper", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||||
expect(indexStatement).toEqual(
|
expect(indexStatement.toString()).toEqual(
|
||||||
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${
|
`CREATE INDEX IF NOT EXISTS "${options.name}" ON "${
|
||||||
options.tableName
|
options.tableName
|
||||||
}" USING GIN (${options.columns.join(", ")}) WHERE ${options.where}`
|
}" USING GIN (${options.columns.join(", ")}) WHERE ${options.where}`
|
||||||
@@ -64,7 +76,6 @@ describe("createPsqlIndexStatementHelper", function () {
|
|||||||
|
|
||||||
it("should generate unique constraint", function () {
|
it("should generate unique constraint", function () {
|
||||||
const options = {
|
const options = {
|
||||||
name: "index_name",
|
|
||||||
tableName: "table_name",
|
tableName: "table_name",
|
||||||
columns: ["column_name_1", "column_name_2"],
|
columns: ["column_name_1", "column_name_2"],
|
||||||
unique: true,
|
unique: true,
|
||||||
@@ -72,8 +83,8 @@ describe("createPsqlIndexStatementHelper", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||||
expect(indexStatement).toEqual(
|
expect(indexStatement.expression).toEqual(
|
||||||
`CREATE UNIQUE INDEX IF NOT EXISTS "${options.name}" ON "${
|
`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_table_name_column_name_1_column_name_2" ON "${
|
||||||
options.tableName
|
options.tableName
|
||||||
}" (${options.columns.join(", ")}) WHERE ${options.where}`
|
}" (${options.columns.join(", ")}) WHERE ${options.where}`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { Index } from "@mikro-orm/core"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a PSQL index statement
|
* Create a PSQL index statement
|
||||||
* @param name The name of the index
|
* @param name The name of the index, if not provided it will be generated in the format IDX_tableName_columnName
|
||||||
* @param tableName The name of the table
|
* @param tableName The name of the table
|
||||||
* @param columns The columns to index
|
* @param columns The columns to index
|
||||||
* @param type The type of index (e.g GIN, GIST, BTREE, etc)
|
* @param type The type of index (e.g GIN, GIST, BTREE, etc)
|
||||||
@@ -16,7 +18,7 @@
|
|||||||
* where: "email IS NOT NULL"
|
* where: "email IS NOT NULL"
|
||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* // CREATE INDEX IF NOT EXISTS idx_user_email ON user USING btree (email) WHERE email IS NOT NULL;
|
* // expression: CREATE INDEX IF NOT EXISTS idx_user_email ON user USING btree (email) WHERE email IS NOT NULL;
|
||||||
*
|
*
|
||||||
* createPsqlIndexStatementHelper({
|
* createPsqlIndexStatementHelper({
|
||||||
* name: "idx_user_email",
|
* name: "idx_user_email",
|
||||||
@@ -24,7 +26,7 @@
|
|||||||
* columns: "email"
|
* columns: "email"
|
||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* // CREATE INDEX IF NOT EXISTS idx_user_email ON user (email);
|
* // expression: CREATE INDEX IF NOT EXISTS idx_user_email ON user (email);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function createPsqlIndexStatementHelper({
|
export function createPsqlIndexStatementHelper({
|
||||||
@@ -35,17 +37,38 @@ export function createPsqlIndexStatementHelper({
|
|||||||
where,
|
where,
|
||||||
unique,
|
unique,
|
||||||
}: {
|
}: {
|
||||||
name: string
|
name?: string
|
||||||
tableName: string
|
tableName: string
|
||||||
columns: string | string[]
|
columns: string | string[]
|
||||||
type?: string
|
type?: string
|
||||||
where?: string
|
where?: string
|
||||||
unique?: boolean
|
unique?: boolean
|
||||||
}) {
|
}) {
|
||||||
|
const columnsName = Array.isArray(columns) ? columns.join("_") : columns
|
||||||
|
|
||||||
columns = Array.isArray(columns) ? columns.join(", ") : columns
|
columns = Array.isArray(columns) ? columns.join(", ") : columns
|
||||||
|
name = name || `IDX_${tableName}_${columnsName}`
|
||||||
|
|
||||||
const typeStr = type ? ` USING ${type}` : ""
|
const typeStr = type ? ` USING ${type}` : ""
|
||||||
const optionsStr = where ? ` WHERE ${where}` : ""
|
const optionsStr = where ? ` WHERE ${where}` : ""
|
||||||
const uniqueStr = unique ? "UNIQUE " : ""
|
const uniqueStr = unique ? "UNIQUE " : ""
|
||||||
|
|
||||||
return `CREATE ${uniqueStr}INDEX IF NOT EXISTS "${name}" ON "${tableName}"${typeStr} (${columns})${optionsStr}`
|
const expression = `CREATE ${uniqueStr}INDEX IF NOT EXISTS "${name}" ON "${tableName}"${typeStr} (${columns})${optionsStr}`
|
||||||
|
return {
|
||||||
|
toString: () => {
|
||||||
|
return expression
|
||||||
|
},
|
||||||
|
valueOf: () => {
|
||||||
|
return expression
|
||||||
|
},
|
||||||
|
name,
|
||||||
|
expression,
|
||||||
|
MikroORMIndex: (options = {}) => {
|
||||||
|
return Index({
|
||||||
|
name,
|
||||||
|
expression,
|
||||||
|
...options,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ export * from "./feature-flags"
|
|||||||
export * from "./fulfillment"
|
export * from "./fulfillment"
|
||||||
export * from "./modules-sdk"
|
export * from "./modules-sdk"
|
||||||
export * from "./orchestration"
|
export * from "./orchestration"
|
||||||
|
export * from "./order"
|
||||||
export * from "./payment"
|
export * from "./payment"
|
||||||
export * from "./pricing"
|
export * from "./pricing"
|
||||||
export * from "./product"
|
export * from "./product"
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./status"
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* @enum
|
||||||
|
*
|
||||||
|
* The order's status.
|
||||||
|
*/
|
||||||
|
export enum OrderStatus {
|
||||||
|
/**
|
||||||
|
* The order is pending.
|
||||||
|
*/
|
||||||
|
PENDING = "pending",
|
||||||
|
/**
|
||||||
|
* The order is completed
|
||||||
|
*/
|
||||||
|
COMPLETED = "completed",
|
||||||
|
/**
|
||||||
|
* The order is a draft.
|
||||||
|
*/
|
||||||
|
DRAFT = "draft",
|
||||||
|
/**
|
||||||
|
* The order is archived.
|
||||||
|
*/
|
||||||
|
ARCHIVED = "archived",
|
||||||
|
/**
|
||||||
|
* The order is canceled.
|
||||||
|
*/
|
||||||
|
CANCELED = "canceled",
|
||||||
|
/**
|
||||||
|
* The order requires action.
|
||||||
|
*/
|
||||||
|
REQUIRES_ACTION = "requires_action",
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BigNumberRawPriceInput, BigNumberRawValue } from "@medusajs/types"
|
import { BigNumberInput, BigNumberRawValue } from "@medusajs/types"
|
||||||
import { BigNumber as BigNumberJS } from "bignumber.js"
|
import { BigNumber as BigNumberJS } from "bignumber.js"
|
||||||
import { isBigNumber, isString } from "../common"
|
import { isBigNumber, isString } from "../common"
|
||||||
|
|
||||||
@@ -8,11 +8,11 @@ export class BigNumber {
|
|||||||
private numeric_: number
|
private numeric_: number
|
||||||
private raw_?: BigNumberRawValue
|
private raw_?: BigNumberRawValue
|
||||||
|
|
||||||
constructor(rawPrice: BigNumberRawPriceInput) {
|
constructor(rawPrice: BigNumberInput) {
|
||||||
this.setRawPriceOrThrow(rawPrice)
|
this.setRawPriceOrThrow(rawPrice)
|
||||||
}
|
}
|
||||||
|
|
||||||
setRawPriceOrThrow(rawPrice: BigNumberRawPriceInput) {
|
setRawPriceOrThrow(rawPrice: BigNumberInput) {
|
||||||
if (BigNumberJS.isBigNumber(rawPrice)) {
|
if (BigNumberJS.isBigNumber(rawPrice)) {
|
||||||
/**
|
/**
|
||||||
* Example:
|
* Example:
|
||||||
@@ -67,7 +67,7 @@ export class BigNumber {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set numeric(value: BigNumberRawPriceInput) {
|
set numeric(value: BigNumberInput) {
|
||||||
const newValue = new BigNumber(value)
|
const newValue = new BigNumber(value)
|
||||||
this.numeric_ = newValue.numeric_
|
this.numeric_ = newValue.numeric_
|
||||||
this.raw_ = newValue.raw_
|
this.raw_ = newValue.raw_
|
||||||
@@ -77,7 +77,7 @@ export class BigNumber {
|
|||||||
return this.raw_
|
return this.raw_
|
||||||
}
|
}
|
||||||
|
|
||||||
set raw(rawValue: BigNumberRawPriceInput) {
|
set raw(rawValue: BigNumberInput) {
|
||||||
const newValue = new BigNumber(rawValue)
|
const newValue = new BigNumber(rawValue)
|
||||||
this.numeric_ = newValue.numeric_
|
this.numeric_ = newValue.numeric_
|
||||||
this.raw_ = newValue.raw_
|
this.raw_ = newValue.raw_
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BigNumberRawPriceInput } from "@medusajs/types"
|
import { BigNumberInput } from "@medusajs/types"
|
||||||
import { BigNumber as BigNumberJs } from "bignumber.js"
|
import { BigNumber as BigNumberJs } from "bignumber.js"
|
||||||
import { isDefined, toCamelCase } from "../common"
|
import { isDefined, toCamelCase } from "../common"
|
||||||
import { BigNumber } from "./big-number"
|
import { BigNumber } from "./big-number"
|
||||||
@@ -18,7 +18,7 @@ export function toBigNumberJs<T, V extends string>(
|
|||||||
): Output<V> {
|
): Output<V> {
|
||||||
return fields.reduce((acc, field: string) => {
|
return fields.reduce((acc, field: string) => {
|
||||||
const camelCased = toCamelCase(field)
|
const camelCased = toCamelCase(field)
|
||||||
let val: BigNumberRawPriceInput = 0
|
let val: BigNumberInput = 0
|
||||||
|
|
||||||
if (isDefined(entity[field])) {
|
if (isDefined(entity[field])) {
|
||||||
const entityField = entity[field]
|
const entityField = entity[field]
|
||||||
|
|||||||
@@ -8494,6 +8494,33 @@ __metadata:
|
|||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
|
"@medusajs/order@workspace:packages/order":
|
||||||
|
version: 0.0.0-use.local
|
||||||
|
resolution: "@medusajs/order@workspace:packages/order"
|
||||||
|
dependencies:
|
||||||
|
"@medusajs/modules-sdk": ^1.12.4
|
||||||
|
"@medusajs/types": ^1.11.8
|
||||||
|
"@medusajs/utils": ^1.11.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
|
||||||
|
awilix: ^8.0.0
|
||||||
|
cross-env: ^5.2.1
|
||||||
|
dotenv: ^16.1.4
|
||||||
|
jest: ^29.6.3
|
||||||
|
knex: 2.4.2
|
||||||
|
medusa-test-utils: ^1.1.40
|
||||||
|
rimraf: ^3.0.2
|
||||||
|
ts-jest: ^29.1.1
|
||||||
|
ts-node: ^10.9.1
|
||||||
|
tsc-alias: ^1.8.6
|
||||||
|
typescript: ^5.1.6
|
||||||
|
bin:
|
||||||
|
medusa-order-seed: dist/scripts/bin/run-seed.js
|
||||||
|
languageName: unknown
|
||||||
|
linkType: soft
|
||||||
|
|
||||||
"@medusajs/payment@workspace:packages/payment":
|
"@medusajs/payment@workspace:packages/payment":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/payment@workspace:packages/payment"
|
resolution: "@medusajs/payment@workspace:packages/payment"
|
||||||
|
|||||||
Reference in new issue
Block a user