Skip to content

Commit

Permalink
fix: Minor updates to the http typings (medusajs#7378)
Browse files Browse the repository at this point in the history
  • Loading branch information
sradevski authored May 21, 2024
1 parent 2371626 commit e72174c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 16 deletions.
31 changes: 31 additions & 0 deletions packages/core/types/src/http/cart/common.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { BigNumberValue } from "../../totals"
import { BasePaymentCollection } from "../payment/common"
import { BaseProduct, BaseProductVariant } from "../product/common"
import { BaseRegion } from "../region/common"

export interface BaseCart {
/**
* The ID of the cart.
*/
id: string

/**
* The associated region.
*
* @expandable
*/
region?: BaseRegion

/**
* The ID of the region the cart belongs to.
*/
Expand Down Expand Up @@ -59,6 +69,13 @@ export interface BaseCart {
*/
shipping_methods?: BaseCartShippingMethod[]

/**
* The associated payment collection
*
* @expandable
*/
payment_collection?: BasePaymentCollection

/**
* Holds custom data in key-value pairs.
*/
Expand Down Expand Up @@ -405,6 +422,13 @@ export interface BaseCartLineItem extends BaseCartLineItemTotals {
*/
quantity: BigNumberValue

/**
* The associated product with the line item.
*
* @expandable
*/
product?: BaseProduct

/**
* The ID of the associated product.
*/
Expand Down Expand Up @@ -440,6 +464,13 @@ export interface BaseCartLineItem extends BaseCartLineItemTotals {
*/
product_handle?: string

/**
* The associated variant with the line item.
*
* @expandable
*/
variant?: BaseProductVariant

/**
* The associated variant's ID of the line item.
*/
Expand Down
10 changes: 9 additions & 1 deletion packages/core/types/src/http/order/admin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { BaseOrder } from "./common"
import {
BaseOrder,
BaseOrderAddress,
BaseOrderLineItem,
BaseOrderShippingMethod,
} from "./common"

export interface AdminOrder extends BaseOrder {}
export interface AdminOrderLineItem extends BaseOrderLineItem {}
export interface AdminOrderAddress extends BaseOrderAddress {}
export interface AdminOrderShippingMethod extends BaseOrderShippingMethod {}
44 changes: 30 additions & 14 deletions packages/core/types/src/http/order/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
interface BaseOrderSummary {
import { BigNumberValue } from "../../totals"
import { BasePaymentCollection } from "../payment/common"
import { BaseProduct, BaseProductVariant } from "../product/common"

export interface BaseOrderSummary {
total: number
subtotal: number
total_tax: number
Expand All @@ -21,7 +25,7 @@ interface BaseOrderSummary {
refunded_total: number
}

interface BaseOrderAdjustmentLine {
export interface BaseOrderAdjustmentLine {
id: string
code?: string
amount: number
Expand All @@ -33,17 +37,18 @@ interface BaseOrderAdjustmentLine {
updated_at: Date | string
}

interface BaseOrderShippingMethodAdjustment extends BaseOrderAdjustmentLine {
export interface BaseOrderShippingMethodAdjustment
extends BaseOrderAdjustmentLine {
shipping_method: BaseOrderShippingMethod
shipping_method_id: string
}

interface BaseOrderLineItemAdjustment extends BaseOrderAdjustmentLine {
export interface BaseOrderLineItemAdjustment extends BaseOrderAdjustmentLine {
item: BaseOrderLineItem
item_id: string
}

interface BaseOrderTaxLine {
export interface BaseOrderTaxLine {
id: string
description?: string
tax_rate_id?: string
Expand All @@ -54,21 +59,21 @@ interface BaseOrderTaxLine {
updated_at: Date | string
}

interface BaseOrderShippingMethodTaxLine extends BaseOrderTaxLine {
export interface BaseOrderShippingMethodTaxLine extends BaseOrderTaxLine {
shipping_method: BaseOrderShippingMethod
shipping_method_id: string
total: number
subtotal: number
}

interface BaseOrderLineItemTaxLine extends BaseOrderTaxLine {
export interface BaseOrderLineItemTaxLine extends BaseOrderTaxLine {
item: BaseOrderLineItem
item_id: string
total: number
subtotal: number
}

interface BaseOrderAddress {
export interface BaseOrderAddress {
id: string
customer_id?: string
first_name?: string
Expand All @@ -86,7 +91,7 @@ interface BaseOrderAddress {
updated_at: Date | string
}

interface BaseOrderShippingMethod {
export interface BaseOrderShippingMethod {
id: string
order_id: string
name: string
Expand All @@ -98,16 +103,26 @@ interface BaseOrderShippingMethod {
metadata: Record<string, unknown> | null
tax_lines?: BaseOrderShippingMethodTaxLine[]
adjustments?: BaseOrderShippingMethodAdjustment[]
original_total: BigNumberValue
original_subtotal: BigNumberValue
original_tax_total: BigNumberValue
total: BigNumberValue
subtotal: BigNumberValue
tax_total: BigNumberValue
discount_total: BigNumberValue
discount_tax_total: BigNumberValue
created_at: Date | string
updated_at: Date | string
}

interface BaseOrderLineItem {
export interface BaseOrderLineItem {
id: string
title: string
subtitle: string | null
thumbnail: string | null
variant?: BaseProductVariant
variant_id: string | null
product?: BaseProduct
product_id: string | null
product_title: string | null
product_description: string | null
Expand Down Expand Up @@ -144,7 +159,7 @@ interface BaseOrderLineItem {
discount_tax_total: number
}

interface BaseOrderItemDetail {
export interface BaseOrderItemDetail {
id: string
item_id: string
item: BaseOrderLineItem
Expand All @@ -160,7 +175,7 @@ interface BaseOrderItemDetail {
updated_at: Date
}

interface BaseOrderChange {
export interface BaseOrderChange {
id: string
order_id: string
actions: BaseOrderChangeAction[]
Expand All @@ -179,7 +194,7 @@ interface BaseOrderChange {
updated_at: Date | string
}

interface BaseOrderChangeAction {
export interface BaseOrderChangeAction {
id: string
order_change_id: string | null
order_change: BaseOrderChange | null
Expand All @@ -193,7 +208,7 @@ interface BaseOrderChangeAction {
updated_at: Date | string
}

interface BaseOrderTransaction {
export interface BaseOrderTransaction {
id: string
order_id: string
amount: number
Expand All @@ -218,6 +233,7 @@ export interface BaseOrder {
billing_address?: BaseOrderAddress
items: BaseOrderLineItem[] | null
shipping_methods: BaseOrderShippingMethod[] | null
payment_collection?: BasePaymentCollection
transactions?: BaseOrderTransaction[]
summary: BaseOrderSummary
metadata: Record<string, unknown> | null
Expand Down
10 changes: 9 additions & 1 deletion packages/core/types/src/http/order/store.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { BaseOrder } from "./common"
import {
BaseOrder,
BaseOrderAddress,
BaseOrderLineItem,
BaseOrderShippingMethod,
} from "./common"

export interface StoreOrder extends BaseOrder {}
export interface StoreOrderLineItem extends BaseOrderLineItem {}
export interface StoreOrderAddress extends BaseOrderAddress {}
export interface StoreOrderShippingMethod extends BaseOrderShippingMethod {}

0 comments on commit e72174c

Please sign in to comment.