Skip to content

Commit 28d57b7

Browse files
authored
fix(types): missing rules in prices types (#13669)
This was missing from the types although they are in validators. https://github.com/medusajs/medusa/blob/bb6cc586f7e883ea2eaa29ef459f8b3dbd3a345b/packages/medusa/src/api/admin/shipping-options/validators.ts#L88-L103 CLOSES #13610 CLOSES #12910
1 parent f85df8f commit 28d57b7

File tree

3 files changed

+40
-35
lines changed

3 files changed

+40
-35
lines changed

.changeset/metal-mayflies-add.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/types": patch
3+
---
4+
5+
fix(types): missing rules in prices types

packages/core/types/src/http/shipping-option/admin/payloads.ts

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RuleOperatorType } from "../../../common"
22
import { ShippingOptionPriceType } from "../../../fulfillment"
3+
import { PriceRule } from "../../../pricing"
34

45
export interface AdminCreateShippingOptionRule {
56
/**
@@ -52,36 +53,12 @@ export interface AdminUpdateShippingOptionType {
5253
code?: string
5354
}
5455

55-
interface AdminShippingOptionPriceRulePayload {
56-
/**
57-
* The operator of the shipping option price rule.
58-
*
59-
* @example
60-
* "eq"
61-
*/
62-
operator: string
63-
/**
64-
* The attribute of the shipping option price rule.
65-
*
66-
* @example
67-
* "region_id"
68-
*/
69-
attribute: string
70-
/**
71-
* The value of the shipping option price rule.
72-
*
73-
* @example
74-
* "region_123"
75-
*/
76-
value: string | string[] | number
77-
}
78-
7956
interface AdminShippingOptionPriceWithRules {
8057
/**
8158
* The rules of the shipping option price that
8259
* indicate when the price should be applied.
8360
*/
84-
rules?: AdminShippingOptionPriceRulePayload[]
61+
rules?: PriceRule[]
8562
}
8663

8764
export interface AdminCreateShippingOptionPriceWithCurrency
@@ -111,7 +88,10 @@ export interface AdminCreateShippingOptionPriceWithRegion
11188
amount: number
11289
}
11390

114-
export interface AdminCreateShippingOption {
91+
/**
92+
* Common properties for all shipping option create inputs.
93+
*/
94+
interface AdminCreateShippingOptionBase {
11595
/**
11696
* The name of the shipping option. Customers can
11797
* view this name during checkout.
@@ -164,13 +144,6 @@ export interface AdminCreateShippingOption {
164144
* documentation.
165145
*/
166146
type_id?: string
167-
/**
168-
* The prices of the shipping option.
169-
*/
170-
prices: (
171-
| AdminCreateShippingOptionPriceWithCurrency
172-
| AdminCreateShippingOptionPriceWithRegion
173-
)[]
174147
/**
175148
* The rules of the shipping option.
176149
*
@@ -184,6 +157,30 @@ export interface AdminCreateShippingOption {
184157
metadata?: Record<string, unknown>
185158
}
186159

160+
/**
161+
* Flat rate shipping option creation input.
162+
*/
163+
export interface AdminCreateFlatRateShippingOption
164+
extends AdminCreateShippingOptionBase {
165+
price_type: "flat"
166+
prices: (
167+
| AdminCreateShippingOptionPriceWithCurrency
168+
| AdminCreateShippingOptionPriceWithRegion
169+
)[]
170+
}
171+
172+
/**
173+
* Calculated shipping option creation input.
174+
*/
175+
export interface AdminCreateCalculatedShippingOption
176+
extends AdminCreateShippingOptionBase {
177+
price_type: "calculated"
178+
}
179+
180+
export type AdminCreateShippingOption =
181+
| AdminCreateFlatRateShippingOption
182+
| AdminCreateCalculatedShippingOption
183+
187184
export interface AdminUpdateShippingOptionRule
188185
extends AdminCreateShippingOptionRule {
189186
/**

packages/core/types/src/workflow/fulfillment/create-shipping-options.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { ShippingOptionDTO } from "../../fulfillment"
22
import { RuleOperatorType } from "../../common"
3+
import { PriceRule } from "../../pricing"
34

45
type CreateFlatRateShippingOptionPriceRecord =
56
| {
67
currency_code: string
78
amount: number
9+
rules?: PriceRule[]
810
}
911
| {
1012
region_id: string
1113
amount: number
14+
rules?: PriceRule[]
1215
}
1316

1417
/**
@@ -69,14 +72,14 @@ type CreateFlatShippingOptionInputBase = {
6972
attribute: string
7073
/**
7174
* The operator to use when matching the attribute.
72-
*
75+
*
7376
* @example
7477
* in
7578
*/
7679
operator: RuleOperatorType
7780
/**
7881
* The value to match against.
79-
*
82+
*
8083
* @example
8184
* cusgrp_123
8285
*/

0 commit comments

Comments
 (0)