chore(types): add price types for shipping option endpoints (#10509)

what:

- adds missing price types for shipping options
This commit is contained in:
Riqwan Thamir
2024-12-09 17:30:31 +01:00
committed by GitHub
parent 9534751b5c
commit f8f5d57c7c
5 changed files with 73 additions and 2 deletions

View File

@@ -127,6 +127,8 @@ export const listShippingOptionsForCartWorkflow = createWorkflow(
"rules.operator",
"calculated_price.*",
"prices.*",
"prices.price_rules.*",
],
variables: queryVariables,
}).config({ name: "shipping-options-query" })

View File

@@ -1,4 +1,5 @@
import { ShippingOptionPriceType } from "../../../fulfillment"
import { StoreCalculatedPrice, StorePrice } from "../../pricing/store/entities"
// TODO: The way the cart shipping options are listed now differs from most other endpoints as it is fetched in a workflow.
// We should consider refactoring this to be more consistent with other endpoints.
@@ -13,7 +14,7 @@ export interface StoreCartShippingOption {
name: string
/**
* The type of the shipping option's price. `flat` means the price
* is fixed, whereas `calculated` means the price is calculated by the
* is fixed, whereas `calculated` means the price is calculated by the
* associated fulfillment provider.
*/
price_type: ShippingOptionPriceType
@@ -31,7 +32,7 @@ export interface StoreCartShippingOption {
provider_id: string
/**
* The data useful for the fulfillment provider when handling the shipment and fulfillment.
*
*
* Learn more in [this documentation](https://docs.medusajs.com/resources/commerce-modules/fulfillment/shipping-option#data-property).
*/
data: Record<string, unknown> | null
@@ -73,4 +74,14 @@ export interface StoreCartShippingOption {
* The shipping option's amount.
*/
amount: number
/**
* All the prices for this shipping option
*/
prices: StorePrice[]
/**
* Calculated price for the shipping option
*/
calculated_price: StoreCalculatedPrice
}

View File

@@ -1 +1,2 @@
export * from "./admin"
export * from "./store"

View File

@@ -0,0 +1,56 @@
import { PricingRuleOperatorValues } from "../../../pricing"
import { BaseCalculatedPriceSet } from "../common"
export interface StorePrice {
/**
* The price's ID.
*/
id: string
/**
* The price's currency code.
*
* @example
* usd
*/
currency_code: string
/**
* The price's amount.
*/
amount: number
/**
* The minimum quantity that must be available in the cart for the price to be applied.
*/
min_quantity: number | null
/**
* The maximum quantity allowed to be available in the cart for the price to be applied.
*/
max_quantity: number | null
/**
* The rules enabled to enable the current price
*/
price_rules?: StorePriceRule[]
}
export interface StorePriceRule {
/**
* The ID of the price rule.
*/
id: string
/**
* The attribute of the price rule
*/
attribute: string
/**
* The operator of the price rule
*/
operator: PricingRuleOperatorValues
/**
* The value of the price rule.
*/
value: string
}
export interface StoreCalculatedPrice extends BaseCalculatedPriceSet {}

View File

@@ -0,0 +1 @@
export * from "./entities"