feat(order): module foundation (#6399)

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

No files matched your search

+14
View File
@@ -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
+26
View File
@@ -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
+90
View File
@@ -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
}
+8
View File
@@ -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")
}
}
+192
View File
@@ -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!
}
}
+168
View File
@@ -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!
}
}
+48
View File
@@ -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
}
+44
View File
@@ -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,
}
+1
View File
@@ -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)
})
})
+1
View File
@@ -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>
}
+20
View File
@@ -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 {}
+15
View File
@@ -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
}
+39
View File
@@ -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
}
+33
View File
@@ -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>
}
+18
View File
@@ -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
}