@usethrottle/cart 3.13.0 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  CartSessionClient: () => CartSessionClient,
30
30
  CartTimeoutError: () => CartTimeoutError,
31
31
  CurrencyNotEnabledError: () => CurrencyNotEnabledError,
32
+ DiscountCurrencyUnsupportedError: () => DiscountCurrencyUnsupportedError,
32
33
  LineLimitReachedError: () => LineLimitReachedError,
33
34
  LineNotPurchasableError: () => LineNotPurchasableError,
34
35
  LineResolverNotAvailableError: () => LineResolverNotAvailableError,
@@ -36,6 +37,7 @@ __export(index_exports, {
36
37
  PriceLockedError: () => PriceLockedError,
37
38
  QuantityUnavailableError: () => QuantityUnavailableError,
38
39
  ResolvedLinesRequiredError: () => ResolvedLinesRequiredError,
40
+ ShippingCurrencyUnsupportedError: () => ShippingCurrencyUnsupportedError,
39
41
  ShippingMethodUnavailableError: () => ShippingMethodUnavailableError,
40
42
  ShippingQuoteUnavailableError: () => ShippingQuoteUnavailableError,
41
43
  StorefrontQuoteClient: () => StorefrontQuoteClient,
@@ -199,6 +201,21 @@ var CartChangedError = class extends ThrottleApiError {
199
201
  this.name = "CartChangedError";
200
202
  }
201
203
  };
204
+ var DiscountCurrencyUnsupportedError = class extends ThrottleApiError {
205
+ constructor(args) {
206
+ super(coded("discount_currency_unsupported", 422, args));
207
+ this.name = "DiscountCurrencyUnsupportedError";
208
+ }
209
+ };
210
+ var ShippingCurrencyUnsupportedError = class extends ThrottleApiError {
211
+ shipping;
212
+ constructor(args) {
213
+ super(coded("shipping_currency_unsupported", 422, args));
214
+ this.name = "ShippingCurrencyUnsupportedError";
215
+ const d = args.details;
216
+ this.shipping = d?.shipping && typeof d.shipping === "object" ? d.shipping : null;
217
+ }
218
+ };
202
219
  var RESOLVED_CART_ERRORS = {
203
220
  price_locked: PriceLockedError,
204
221
  quantity_unavailable: QuantityUnavailableError,
@@ -212,7 +229,9 @@ var RESOLVED_CART_ERRORS = {
212
229
  shipping_method_unavailable: ShippingMethodUnavailableError,
213
230
  shipping_quote_unavailable: ShippingQuoteUnavailableError,
214
231
  amount_too_large: AmountTooLargeError,
215
- cart_changed: CartChangedError
232
+ cart_changed: CartChangedError,
233
+ discount_currency_unsupported: DiscountCurrencyUnsupportedError,
234
+ shipping_currency_unsupported: ShippingCurrencyUnsupportedError
216
235
  };
217
236
  function cartErrorFromResponse(args) {
218
237
  if (args.statusCode === 409 && args.code === "cart_not_open") {
@@ -627,6 +646,7 @@ var CartSessionClient = class _CartSessionClient {
627
646
  CartSessionClient,
628
647
  CartTimeoutError,
629
648
  CurrencyNotEnabledError,
649
+ DiscountCurrencyUnsupportedError,
630
650
  LineLimitReachedError,
631
651
  LineNotPurchasableError,
632
652
  LineResolverNotAvailableError,
@@ -634,6 +654,7 @@ var CartSessionClient = class _CartSessionClient {
634
654
  PriceLockedError,
635
655
  QuantityUnavailableError,
636
656
  ResolvedLinesRequiredError,
657
+ ShippingCurrencyUnsupportedError,
637
658
  ShippingMethodUnavailableError,
638
659
  ShippingQuoteUnavailableError,
639
660
  StorefrontQuoteClient,
package/dist/index.d.cts CHANGED
@@ -279,7 +279,8 @@ interface CreateCartInput {
279
279
  /**
280
280
  * Make this a resolved cart: the installed app with this extension id
281
281
  * prices its lines (add them with `items.addResolvedItem()`). Requires
282
- * `currency`, which must be the environment's currency.
282
+ * `currency`: the environment's currency or one of its extra cart
283
+ * currencies (`cartCurrencies`).
283
284
  */
284
285
  lineResolver?: {
285
286
  extensionId: string;
@@ -651,7 +652,8 @@ interface CreateCartSessionInput {
651
652
  /**
652
653
  * Make this a resolved cart: the installed app with this extension id
653
654
  * prices its lines (add them with `addResolvedItem()`). Requires
654
- * `currency`, which must be the environment's currency.
655
+ * `currency`: the environment's currency or one of its extra cart
656
+ * currencies (`cartCurrencies`).
655
657
  */
656
658
  lineResolver?: {
657
659
  extensionId: string;
@@ -973,7 +975,10 @@ type CurrencyNotEnabledDetails = {
973
975
  currency: string;
974
976
  enabledCurrencies: string[];
975
977
  };
976
- /** `422 currency_not_enabled`: a resolved cart must use the environment's currency. */
978
+ /**
979
+ * `422 currency_not_enabled`: a resolved cart must use the environment's
980
+ * currency or one of its extra cart currencies (`enabledCurrencies` lists them).
981
+ */
977
982
  declare class CurrencyNotEnabledError extends ThrottleApiError {
978
983
  readonly details?: CurrencyNotEnabledDetails;
979
984
  constructor(args: CartErrorArgs);
@@ -997,14 +1002,16 @@ declare class LineLimitReachedError extends ThrottleApiError {
997
1002
  /**
998
1003
  * The stored shipping selection after the checkout hand-off re-quoted it.
999
1004
  * `amount` is the new quote, or null with a `reason`: `method_unavailable`
1000
- * (no longer offered, so cleared) or `quote_unavailable` (could not be
1001
- * quoted now; kept for the next hand-off).
1005
+ * (no longer offered, so cleared), `quote_unavailable` (could not be
1006
+ * quoted now; kept for the next hand-off) or `shipping_currency_unsupported`
1007
+ * (on a cart in an extra currency, its rate is a non-zero amount in another
1008
+ * currency; kept, and the buyer must choose another method).
1002
1009
  */
1003
1010
  type CartShippingChange = {
1004
1011
  methodId: string;
1005
1012
  previousAmount: number;
1006
1013
  amount: number | null;
1007
- reason?: 'method_unavailable' | 'quote_unavailable';
1014
+ reason?: 'method_unavailable' | 'quote_unavailable' | 'shipping_currency_unsupported';
1008
1015
  };
1009
1016
  /** `details` of `409 cart_prices_changed`. */
1010
1017
  type CartPricesChangedDetails = {
@@ -1041,6 +1048,27 @@ declare class AmountTooLargeError extends ThrottleApiError {
1041
1048
  declare class CartChangedError extends ThrottleApiError {
1042
1049
  constructor(args: CartErrorArgs);
1043
1050
  }
1051
+ /**
1052
+ * `422 discount_currency_unsupported`: a fixed-amount discount can't be used
1053
+ * on a resolved cart in an extra currency. Nothing is applied; a percentage
1054
+ * discount works.
1055
+ */
1056
+ declare class DiscountCurrencyUnsupportedError extends ThrottleApiError {
1057
+ constructor(args: CartErrorArgs);
1058
+ }
1059
+ /**
1060
+ * `422 shipping_currency_unsupported`: on a resolved cart in an extra
1061
+ * currency, a non-zero shipping rate in another currency. Nothing new is
1062
+ * selected; choose a zero-rate method. At the checkout hand-off, `shipping`
1063
+ * is the kept selection.
1064
+ */
1065
+ declare class ShippingCurrencyUnsupportedError extends ThrottleApiError {
1066
+ readonly details?: {
1067
+ shipping?: CartShippingChange;
1068
+ };
1069
+ readonly shipping: CartShippingChange | null;
1070
+ constructor(args: CartErrorArgs);
1071
+ }
1044
1072
  /**
1045
1073
  * Map a raw API error envelope to the most specific Cart SDK error class.
1046
1074
  * Falls back to {@link ThrottleApiError} for everything unrecognised.
@@ -1053,4 +1081,4 @@ declare function cartErrorFromResponse(args: {
1053
1081
  responseHeaders?: ThrottleErrorArgs['responseHeaders'];
1054
1082
  }): ThrottleApiError;
1055
1083
 
1056
- export { type AddLineItemInput, type AddResolvedLineItemInput, AmountTooLargeError, type AppliedDiscount, type Cart, type CartAddress, type CartBranding, CartChangedError, CartClient, type CartErrorArgs, type CartEvent, CartNotFoundError, CartNotOpenError, type CartPricesChangedDetails, CartPricesChangedError, type CartSession, type CartSessionCart, CartSessionClient, type CartSessionClientOptions, type CartSessionSummary, type CartShippingChange, CartTimeoutError, type CheckoutHandoff, type CheckoutHandoffInput, type CheckoutInput, type CreateCartInput, type CreateCartSessionInput, type CurrencyNotEnabledDetails, CurrencyNotEnabledError, type ExternalShippingTaxSnapshotInput, type LegacyLineRecurring, type LineItem, type LineLimitReachedDetails, LineLimitReachedError, type LineNotPurchasableDetails, LineNotPurchasableError, type LineRecurringInput, type LineResolution, type LineResolverNotAvailableDetails, LineResolverNotAvailableError, type LineResolverUnavailableDetails, LineResolverUnavailableError, type Order, type PriceLockedDetails, PriceLockedError, type QuantityUnavailableDetails, QuantityUnavailableError, type RefusedCartLine, ResolvedLinesRequiredError, type SelectShippingInput, type SelectShippingMethodInput, type SelectedShipping, ShippingMethodUnavailableError, ShippingQuoteUnavailableError, type ShippingTaxAddress, type ShippingTaxCalculationResponse, type ShippingTaxCartCalculateInput, type ShippingTaxMethod, type ShippingTaxQuoteInput, type ShippingTaxQuoteItem, type StoredLineRecurring, StorefrontQuoteClient, type SubscriptionInterval, type SubscriptionIntervalUnit, type TaxLine, type TaxLineInput, ThrottleApiError, type UpdateCartInput, type UpdateCartSessionInput, type UpdateLineItemInput, cartErrorFromResponse };
1084
+ export { type AddLineItemInput, type AddResolvedLineItemInput, AmountTooLargeError, type AppliedDiscount, type Cart, type CartAddress, type CartBranding, CartChangedError, CartClient, type CartErrorArgs, type CartEvent, CartNotFoundError, CartNotOpenError, type CartPricesChangedDetails, CartPricesChangedError, type CartSession, type CartSessionCart, CartSessionClient, type CartSessionClientOptions, type CartSessionSummary, type CartShippingChange, CartTimeoutError, type CheckoutHandoff, type CheckoutHandoffInput, type CheckoutInput, type CreateCartInput, type CreateCartSessionInput, type CurrencyNotEnabledDetails, CurrencyNotEnabledError, DiscountCurrencyUnsupportedError, type ExternalShippingTaxSnapshotInput, type LegacyLineRecurring, type LineItem, type LineLimitReachedDetails, LineLimitReachedError, type LineNotPurchasableDetails, LineNotPurchasableError, type LineRecurringInput, type LineResolution, type LineResolverNotAvailableDetails, LineResolverNotAvailableError, type LineResolverUnavailableDetails, LineResolverUnavailableError, type Order, type PriceLockedDetails, PriceLockedError, type QuantityUnavailableDetails, QuantityUnavailableError, type RefusedCartLine, ResolvedLinesRequiredError, type SelectShippingInput, type SelectShippingMethodInput, type SelectedShipping, ShippingCurrencyUnsupportedError, ShippingMethodUnavailableError, ShippingQuoteUnavailableError, type ShippingTaxAddress, type ShippingTaxCalculationResponse, type ShippingTaxCartCalculateInput, type ShippingTaxMethod, type ShippingTaxQuoteInput, type ShippingTaxQuoteItem, type StoredLineRecurring, StorefrontQuoteClient, type SubscriptionInterval, type SubscriptionIntervalUnit, type TaxLine, type TaxLineInput, ThrottleApiError, type UpdateCartInput, type UpdateCartSessionInput, type UpdateLineItemInput, cartErrorFromResponse };
package/dist/index.d.ts CHANGED
@@ -279,7 +279,8 @@ interface CreateCartInput {
279
279
  /**
280
280
  * Make this a resolved cart: the installed app with this extension id
281
281
  * prices its lines (add them with `items.addResolvedItem()`). Requires
282
- * `currency`, which must be the environment's currency.
282
+ * `currency`: the environment's currency or one of its extra cart
283
+ * currencies (`cartCurrencies`).
283
284
  */
284
285
  lineResolver?: {
285
286
  extensionId: string;
@@ -651,7 +652,8 @@ interface CreateCartSessionInput {
651
652
  /**
652
653
  * Make this a resolved cart: the installed app with this extension id
653
654
  * prices its lines (add them with `addResolvedItem()`). Requires
654
- * `currency`, which must be the environment's currency.
655
+ * `currency`: the environment's currency or one of its extra cart
656
+ * currencies (`cartCurrencies`).
655
657
  */
656
658
  lineResolver?: {
657
659
  extensionId: string;
@@ -973,7 +975,10 @@ type CurrencyNotEnabledDetails = {
973
975
  currency: string;
974
976
  enabledCurrencies: string[];
975
977
  };
976
- /** `422 currency_not_enabled`: a resolved cart must use the environment's currency. */
978
+ /**
979
+ * `422 currency_not_enabled`: a resolved cart must use the environment's
980
+ * currency or one of its extra cart currencies (`enabledCurrencies` lists them).
981
+ */
977
982
  declare class CurrencyNotEnabledError extends ThrottleApiError {
978
983
  readonly details?: CurrencyNotEnabledDetails;
979
984
  constructor(args: CartErrorArgs);
@@ -997,14 +1002,16 @@ declare class LineLimitReachedError extends ThrottleApiError {
997
1002
  /**
998
1003
  * The stored shipping selection after the checkout hand-off re-quoted it.
999
1004
  * `amount` is the new quote, or null with a `reason`: `method_unavailable`
1000
- * (no longer offered, so cleared) or `quote_unavailable` (could not be
1001
- * quoted now; kept for the next hand-off).
1005
+ * (no longer offered, so cleared), `quote_unavailable` (could not be
1006
+ * quoted now; kept for the next hand-off) or `shipping_currency_unsupported`
1007
+ * (on a cart in an extra currency, its rate is a non-zero amount in another
1008
+ * currency; kept, and the buyer must choose another method).
1002
1009
  */
1003
1010
  type CartShippingChange = {
1004
1011
  methodId: string;
1005
1012
  previousAmount: number;
1006
1013
  amount: number | null;
1007
- reason?: 'method_unavailable' | 'quote_unavailable';
1014
+ reason?: 'method_unavailable' | 'quote_unavailable' | 'shipping_currency_unsupported';
1008
1015
  };
1009
1016
  /** `details` of `409 cart_prices_changed`. */
1010
1017
  type CartPricesChangedDetails = {
@@ -1041,6 +1048,27 @@ declare class AmountTooLargeError extends ThrottleApiError {
1041
1048
  declare class CartChangedError extends ThrottleApiError {
1042
1049
  constructor(args: CartErrorArgs);
1043
1050
  }
1051
+ /**
1052
+ * `422 discount_currency_unsupported`: a fixed-amount discount can't be used
1053
+ * on a resolved cart in an extra currency. Nothing is applied; a percentage
1054
+ * discount works.
1055
+ */
1056
+ declare class DiscountCurrencyUnsupportedError extends ThrottleApiError {
1057
+ constructor(args: CartErrorArgs);
1058
+ }
1059
+ /**
1060
+ * `422 shipping_currency_unsupported`: on a resolved cart in an extra
1061
+ * currency, a non-zero shipping rate in another currency. Nothing new is
1062
+ * selected; choose a zero-rate method. At the checkout hand-off, `shipping`
1063
+ * is the kept selection.
1064
+ */
1065
+ declare class ShippingCurrencyUnsupportedError extends ThrottleApiError {
1066
+ readonly details?: {
1067
+ shipping?: CartShippingChange;
1068
+ };
1069
+ readonly shipping: CartShippingChange | null;
1070
+ constructor(args: CartErrorArgs);
1071
+ }
1044
1072
  /**
1045
1073
  * Map a raw API error envelope to the most specific Cart SDK error class.
1046
1074
  * Falls back to {@link ThrottleApiError} for everything unrecognised.
@@ -1053,4 +1081,4 @@ declare function cartErrorFromResponse(args: {
1053
1081
  responseHeaders?: ThrottleErrorArgs['responseHeaders'];
1054
1082
  }): ThrottleApiError;
1055
1083
 
1056
- export { type AddLineItemInput, type AddResolvedLineItemInput, AmountTooLargeError, type AppliedDiscount, type Cart, type CartAddress, type CartBranding, CartChangedError, CartClient, type CartErrorArgs, type CartEvent, CartNotFoundError, CartNotOpenError, type CartPricesChangedDetails, CartPricesChangedError, type CartSession, type CartSessionCart, CartSessionClient, type CartSessionClientOptions, type CartSessionSummary, type CartShippingChange, CartTimeoutError, type CheckoutHandoff, type CheckoutHandoffInput, type CheckoutInput, type CreateCartInput, type CreateCartSessionInput, type CurrencyNotEnabledDetails, CurrencyNotEnabledError, type ExternalShippingTaxSnapshotInput, type LegacyLineRecurring, type LineItem, type LineLimitReachedDetails, LineLimitReachedError, type LineNotPurchasableDetails, LineNotPurchasableError, type LineRecurringInput, type LineResolution, type LineResolverNotAvailableDetails, LineResolverNotAvailableError, type LineResolverUnavailableDetails, LineResolverUnavailableError, type Order, type PriceLockedDetails, PriceLockedError, type QuantityUnavailableDetails, QuantityUnavailableError, type RefusedCartLine, ResolvedLinesRequiredError, type SelectShippingInput, type SelectShippingMethodInput, type SelectedShipping, ShippingMethodUnavailableError, ShippingQuoteUnavailableError, type ShippingTaxAddress, type ShippingTaxCalculationResponse, type ShippingTaxCartCalculateInput, type ShippingTaxMethod, type ShippingTaxQuoteInput, type ShippingTaxQuoteItem, type StoredLineRecurring, StorefrontQuoteClient, type SubscriptionInterval, type SubscriptionIntervalUnit, type TaxLine, type TaxLineInput, ThrottleApiError, type UpdateCartInput, type UpdateCartSessionInput, type UpdateLineItemInput, cartErrorFromResponse };
1084
+ export { type AddLineItemInput, type AddResolvedLineItemInput, AmountTooLargeError, type AppliedDiscount, type Cart, type CartAddress, type CartBranding, CartChangedError, CartClient, type CartErrorArgs, type CartEvent, CartNotFoundError, CartNotOpenError, type CartPricesChangedDetails, CartPricesChangedError, type CartSession, type CartSessionCart, CartSessionClient, type CartSessionClientOptions, type CartSessionSummary, type CartShippingChange, CartTimeoutError, type CheckoutHandoff, type CheckoutHandoffInput, type CheckoutInput, type CreateCartInput, type CreateCartSessionInput, type CurrencyNotEnabledDetails, CurrencyNotEnabledError, DiscountCurrencyUnsupportedError, type ExternalShippingTaxSnapshotInput, type LegacyLineRecurring, type LineItem, type LineLimitReachedDetails, LineLimitReachedError, type LineNotPurchasableDetails, LineNotPurchasableError, type LineRecurringInput, type LineResolution, type LineResolverNotAvailableDetails, LineResolverNotAvailableError, type LineResolverUnavailableDetails, LineResolverUnavailableError, type Order, type PriceLockedDetails, PriceLockedError, type QuantityUnavailableDetails, QuantityUnavailableError, type RefusedCartLine, ResolvedLinesRequiredError, type SelectShippingInput, type SelectShippingMethodInput, type SelectedShipping, ShippingCurrencyUnsupportedError, ShippingMethodUnavailableError, ShippingQuoteUnavailableError, type ShippingTaxAddress, type ShippingTaxCalculationResponse, type ShippingTaxCartCalculateInput, type ShippingTaxMethod, type ShippingTaxQuoteInput, type ShippingTaxQuoteItem, type StoredLineRecurring, StorefrontQuoteClient, type SubscriptionInterval, type SubscriptionIntervalUnit, type TaxLine, type TaxLineInput, ThrottleApiError, type UpdateCartInput, type UpdateCartSessionInput, type UpdateLineItemInput, cartErrorFromResponse };
package/dist/index.js CHANGED
@@ -151,6 +151,21 @@ var CartChangedError = class extends ThrottleApiError {
151
151
  this.name = "CartChangedError";
152
152
  }
153
153
  };
154
+ var DiscountCurrencyUnsupportedError = class extends ThrottleApiError {
155
+ constructor(args) {
156
+ super(coded("discount_currency_unsupported", 422, args));
157
+ this.name = "DiscountCurrencyUnsupportedError";
158
+ }
159
+ };
160
+ var ShippingCurrencyUnsupportedError = class extends ThrottleApiError {
161
+ shipping;
162
+ constructor(args) {
163
+ super(coded("shipping_currency_unsupported", 422, args));
164
+ this.name = "ShippingCurrencyUnsupportedError";
165
+ const d = args.details;
166
+ this.shipping = d?.shipping && typeof d.shipping === "object" ? d.shipping : null;
167
+ }
168
+ };
154
169
  var RESOLVED_CART_ERRORS = {
155
170
  price_locked: PriceLockedError,
156
171
  quantity_unavailable: QuantityUnavailableError,
@@ -164,7 +179,9 @@ var RESOLVED_CART_ERRORS = {
164
179
  shipping_method_unavailable: ShippingMethodUnavailableError,
165
180
  shipping_quote_unavailable: ShippingQuoteUnavailableError,
166
181
  amount_too_large: AmountTooLargeError,
167
- cart_changed: CartChangedError
182
+ cart_changed: CartChangedError,
183
+ discount_currency_unsupported: DiscountCurrencyUnsupportedError,
184
+ shipping_currency_unsupported: ShippingCurrencyUnsupportedError
168
185
  };
169
186
  function cartErrorFromResponse(args) {
170
187
  if (args.statusCode === 409 && args.code === "cart_not_open") {
@@ -578,6 +595,7 @@ export {
578
595
  CartSessionClient,
579
596
  CartTimeoutError,
580
597
  CurrencyNotEnabledError,
598
+ DiscountCurrencyUnsupportedError,
581
599
  LineLimitReachedError,
582
600
  LineNotPurchasableError,
583
601
  LineResolverNotAvailableError,
@@ -585,6 +603,7 @@ export {
585
603
  PriceLockedError,
586
604
  QuantityUnavailableError,
587
605
  ResolvedLinesRequiredError,
606
+ ShippingCurrencyUnsupportedError,
588
607
  ShippingMethodUnavailableError,
589
608
  ShippingQuoteUnavailableError,
590
609
  StorefrontQuoteClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/cart",
3
- "version": "3.13.0",
3
+ "version": "3.14.0",
4
4
  "description": "Typed REST client for the Throttle Cart API.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",