fix(types): missing rules in prices types (#13669)

This was missing from the types although they are in validators. bb6cc586f7/packages/medusa/src/api/admin/shipping-options/validators.ts (L88-L103)

CLOSES #13610
CLOSES #12910
This commit is contained in:
William Bouchard
2025-10-06 11:22:55 -04:00
committed by GitHub
parent f85df8fcdc
commit 28d57b7bf8
3 changed files with 40 additions and 35 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/types": patch
---
fix(types): missing rules in prices types

View File

@@ -1,5 +1,6 @@
import { RuleOperatorType } from "../../../common"
import { ShippingOptionPriceType } from "../../../fulfillment"
import { PriceRule } from "../../../pricing"
export interface AdminCreateShippingOptionRule {
/**
@@ -52,36 +53,12 @@ export interface AdminUpdateShippingOptionType {
code?: string
}
interface AdminShippingOptionPriceRulePayload {
/**
* The operator of the shipping option price rule.
*
* @example
* "eq"
*/
operator: string
/**
* The attribute of the shipping option price rule.
*
* @example
* "region_id"
*/
attribute: string
/**
* The value of the shipping option price rule.
*
* @example
* "region_123"
*/
value: string | string[] | number
}
interface AdminShippingOptionPriceWithRules {
/**
* The rules of the shipping option price that
* indicate when the price should be applied.
*/
rules?: AdminShippingOptionPriceRulePayload[]
rules?: PriceRule[]
}
export interface AdminCreateShippingOptionPriceWithCurrency
@@ -111,7 +88,10 @@ export interface AdminCreateShippingOptionPriceWithRegion
amount: number
}
export interface AdminCreateShippingOption {
/**
* Common properties for all shipping option create inputs.
*/
interface AdminCreateShippingOptionBase {
/**
* The name of the shipping option. Customers can
* view this name during checkout.
@@ -164,13 +144,6 @@ export interface AdminCreateShippingOption {
* documentation.
*/
type_id?: string
/**
* The prices of the shipping option.
*/
prices: (
| AdminCreateShippingOptionPriceWithCurrency
| AdminCreateShippingOptionPriceWithRegion
)[]
/**
* The rules of the shipping option.
*
@@ -184,6 +157,30 @@ export interface AdminCreateShippingOption {
metadata?: Record<string, unknown>
}
/**
* Flat rate shipping option creation input.
*/
export interface AdminCreateFlatRateShippingOption
extends AdminCreateShippingOptionBase {
price_type: "flat"
prices: (
| AdminCreateShippingOptionPriceWithCurrency
| AdminCreateShippingOptionPriceWithRegion
)[]
}
/**
* Calculated shipping option creation input.
*/
export interface AdminCreateCalculatedShippingOption
extends AdminCreateShippingOptionBase {
price_type: "calculated"
}
export type AdminCreateShippingOption =
| AdminCreateFlatRateShippingOption
| AdminCreateCalculatedShippingOption
export interface AdminUpdateShippingOptionRule
extends AdminCreateShippingOptionRule {
/**

View File

@@ -1,14 +1,17 @@
import { ShippingOptionDTO } from "../../fulfillment"
import { RuleOperatorType } from "../../common"
import { PriceRule } from "../../pricing"
type CreateFlatRateShippingOptionPriceRecord =
| {
currency_code: string
amount: number
rules?: PriceRule[]
}
| {
region_id: string
amount: number
rules?: PriceRule[]
}
/**
@@ -69,14 +72,14 @@ type CreateFlatShippingOptionInputBase = {
attribute: string
/**
* The operator to use when matching the attribute.
*
*
* @example
* in
*/
operator: RuleOperatorType
/**
* The value to match against.
*
*
* @example
* cusgrp_123
*/