@usethrottle/cart 3.9.1 → 3.10.1

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
@@ -44,13 +44,25 @@ var ThrottleApiError = class extends import_errors.ThrottleError {
44
44
  };
45
45
  var CartNotOpenError = class extends ThrottleApiError {
46
46
  constructor(args) {
47
- super({ code: "cart_not_open", statusCode: args.statusCode ?? 409, message: args.message, details: args.details });
47
+ super({
48
+ code: "cart_not_open",
49
+ statusCode: args.statusCode ?? 409,
50
+ message: args.message,
51
+ details: args.details,
52
+ responseHeaders: args.responseHeaders
53
+ });
48
54
  this.name = "CartNotOpenError";
49
55
  }
50
56
  };
51
57
  var CartNotFoundError = class extends ThrottleApiError {
52
58
  constructor(args) {
53
- super({ code: "cart_not_found", statusCode: args.statusCode ?? 404, message: args.message, details: args.details });
59
+ super({
60
+ code: "cart_not_found",
61
+ statusCode: args.statusCode ?? 404,
62
+ message: args.message,
63
+ details: args.details,
64
+ responseHeaders: args.responseHeaders
65
+ });
54
66
  this.name = "CartNotFoundError";
55
67
  }
56
68
  };
@@ -67,10 +79,20 @@ var CartTimeoutError = class extends import_errors.ThrottleError {
67
79
  };
68
80
  function cartErrorFromResponse(args) {
69
81
  if (args.statusCode === 409 && args.code === "cart_not_open") {
70
- return new CartNotOpenError({ message: args.message, statusCode: args.statusCode, details: args.details });
82
+ return new CartNotOpenError({
83
+ message: args.message,
84
+ statusCode: args.statusCode,
85
+ details: args.details,
86
+ responseHeaders: args.responseHeaders
87
+ });
71
88
  }
72
89
  if (args.statusCode === 404 && (args.code === "cart_not_found" || args.code === "not_found")) {
73
- return new CartNotFoundError({ message: args.message, statusCode: args.statusCode, details: args.details });
90
+ return new CartNotFoundError({
91
+ message: args.message,
92
+ statusCode: args.statusCode,
93
+ details: args.details,
94
+ responseHeaders: args.responseHeaders
95
+ });
74
96
  }
75
97
  return new ThrottleApiError(args);
76
98
  }
@@ -108,7 +130,8 @@ var CartClient = class {
108
130
  code: json?.error?.code ?? "unknown_error",
109
131
  message: json?.error?.message ?? `HTTP ${res.status}`,
110
132
  statusCode: res.status,
111
- details: json?.error?.details
133
+ details: json?.error?.details,
134
+ responseHeaders: res.headers
112
135
  });
113
136
  }
114
137
  return json.data;
@@ -215,7 +238,8 @@ var StorefrontQuoteClient = class {
215
238
  code: json?.error?.code ?? "unknown_error",
216
239
  message: json?.error?.message ?? `HTTP ${res.status}`,
217
240
  statusCode: res.status,
218
- details: json?.error?.details
241
+ details: json?.error?.details,
242
+ responseHeaders: res.headers
219
243
  });
220
244
  }
221
245
  return json.data;
@@ -385,7 +409,8 @@ var CartSessionClient = class _CartSessionClient {
385
409
  code: json?.error?.code ?? "unknown_error",
386
410
  message: json?.error?.message ?? `HTTP ${res.status}`,
387
411
  statusCode: res.status,
388
- details: json?.error?.details
412
+ details: json?.error?.details,
413
+ responseHeaders: res.headers
389
414
  });
390
415
  }
391
416
  return json.data;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ThrottleError } from '@usethrottle/errors';
1
+ import { ThrottleError, ThrottleErrorArgs } from '@usethrottle/errors';
2
2
  export { ThrottleError, isThrottleError } from '@usethrottle/errors';
3
3
 
4
4
  /**
@@ -92,9 +92,16 @@ interface LineItem {
92
92
  taxAmount: number;
93
93
  discountAmount: number;
94
94
  total: number;
95
+ /**
96
+ * Display metadata. `count` is the number of payments to show, and is not
97
+ * enforced. On the plan line Throttle writes for a recurring checkout,
98
+ * `intervalUnit`/`intervalCount` describe a custom cadence.
99
+ */
95
100
  recurring: {
96
101
  interval: string;
97
102
  count: number | null;
103
+ intervalUnit?: string | null;
104
+ intervalCount?: number | null;
98
105
  } | null;
99
106
  imageUrl: string | null;
100
107
  position: number;
@@ -173,9 +180,16 @@ interface AddLineItemInput {
173
180
  quantity?: number;
174
181
  taxAmount?: number;
175
182
  discountAmount?: number;
183
+ /**
184
+ * Display metadata. `count` is the number of payments to show, and is not
185
+ * enforced. On the plan line Throttle writes for a recurring checkout,
186
+ * `intervalUnit`/`intervalCount` describe a custom cadence.
187
+ */
176
188
  recurring?: {
177
189
  interval: string;
178
190
  count: number | null;
191
+ intervalUnit?: string | null;
192
+ intervalCount?: number | null;
179
193
  } | null;
180
194
  imageUrl?: string;
181
195
  /**
@@ -627,6 +641,7 @@ declare class ThrottleApiError extends ThrottleError {
627
641
  message: string;
628
642
  statusCode: number;
629
643
  details?: Record<string, unknown>;
644
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
630
645
  });
631
646
  }
632
647
  /**
@@ -644,6 +659,7 @@ declare class CartNotOpenError extends ThrottleApiError {
644
659
  message: string;
645
660
  statusCode?: number;
646
661
  details?: Record<string, unknown>;
662
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
647
663
  });
648
664
  }
649
665
  /**
@@ -655,6 +671,7 @@ declare class CartNotFoundError extends ThrottleApiError {
655
671
  message: string;
656
672
  statusCode?: number;
657
673
  details?: Record<string, unknown>;
674
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
658
675
  });
659
676
  }
660
677
  /**
@@ -685,6 +702,7 @@ declare function cartErrorFromResponse(args: {
685
702
  message: string;
686
703
  statusCode: number;
687
704
  details?: Record<string, unknown>;
705
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
688
706
  }): ThrottleApiError;
689
707
 
690
708
  export { type AddLineItemInput, type AppliedDiscount, type Cart, type CartAddress, type CartBranding, CartClient, type CartEvent, CartNotFoundError, CartNotOpenError, type CartSession, type CartSessionCart, CartSessionClient, type CartSessionClientOptions, type CartSessionSummary, CartTimeoutError, type CheckoutHandoff, type CheckoutHandoffInput, type CheckoutInput, type CreateCartInput, type CreateCartSessionInput, type ExternalShippingTaxSnapshotInput, type LineItem, type Order, type SelectShippingInput, type SelectedShipping, type ShippingTaxAddress, type ShippingTaxCalculationResponse, type ShippingTaxCartCalculateInput, type ShippingTaxMethod, type ShippingTaxQuoteInput, type ShippingTaxQuoteItem, StorefrontQuoteClient, type TaxLine, type TaxLineInput, ThrottleApiError, type UpdateCartInput, type UpdateCartSessionInput, type UpdateLineItemInput, cartErrorFromResponse };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ThrottleError } from '@usethrottle/errors';
1
+ import { ThrottleError, ThrottleErrorArgs } from '@usethrottle/errors';
2
2
  export { ThrottleError, isThrottleError } from '@usethrottle/errors';
3
3
 
4
4
  /**
@@ -92,9 +92,16 @@ interface LineItem {
92
92
  taxAmount: number;
93
93
  discountAmount: number;
94
94
  total: number;
95
+ /**
96
+ * Display metadata. `count` is the number of payments to show, and is not
97
+ * enforced. On the plan line Throttle writes for a recurring checkout,
98
+ * `intervalUnit`/`intervalCount` describe a custom cadence.
99
+ */
95
100
  recurring: {
96
101
  interval: string;
97
102
  count: number | null;
103
+ intervalUnit?: string | null;
104
+ intervalCount?: number | null;
98
105
  } | null;
99
106
  imageUrl: string | null;
100
107
  position: number;
@@ -173,9 +180,16 @@ interface AddLineItemInput {
173
180
  quantity?: number;
174
181
  taxAmount?: number;
175
182
  discountAmount?: number;
183
+ /**
184
+ * Display metadata. `count` is the number of payments to show, and is not
185
+ * enforced. On the plan line Throttle writes for a recurring checkout,
186
+ * `intervalUnit`/`intervalCount` describe a custom cadence.
187
+ */
176
188
  recurring?: {
177
189
  interval: string;
178
190
  count: number | null;
191
+ intervalUnit?: string | null;
192
+ intervalCount?: number | null;
179
193
  } | null;
180
194
  imageUrl?: string;
181
195
  /**
@@ -627,6 +641,7 @@ declare class ThrottleApiError extends ThrottleError {
627
641
  message: string;
628
642
  statusCode: number;
629
643
  details?: Record<string, unknown>;
644
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
630
645
  });
631
646
  }
632
647
  /**
@@ -644,6 +659,7 @@ declare class CartNotOpenError extends ThrottleApiError {
644
659
  message: string;
645
660
  statusCode?: number;
646
661
  details?: Record<string, unknown>;
662
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
647
663
  });
648
664
  }
649
665
  /**
@@ -655,6 +671,7 @@ declare class CartNotFoundError extends ThrottleApiError {
655
671
  message: string;
656
672
  statusCode?: number;
657
673
  details?: Record<string, unknown>;
674
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
658
675
  });
659
676
  }
660
677
  /**
@@ -685,6 +702,7 @@ declare function cartErrorFromResponse(args: {
685
702
  message: string;
686
703
  statusCode: number;
687
704
  details?: Record<string, unknown>;
705
+ responseHeaders?: ThrottleErrorArgs['responseHeaders'];
688
706
  }): ThrottleApiError;
689
707
 
690
708
  export { type AddLineItemInput, type AppliedDiscount, type Cart, type CartAddress, type CartBranding, CartClient, type CartEvent, CartNotFoundError, CartNotOpenError, type CartSession, type CartSessionCart, CartSessionClient, type CartSessionClientOptions, type CartSessionSummary, CartTimeoutError, type CheckoutHandoff, type CheckoutHandoffInput, type CheckoutInput, type CreateCartInput, type CreateCartSessionInput, type ExternalShippingTaxSnapshotInput, type LineItem, type Order, type SelectShippingInput, type SelectedShipping, type ShippingTaxAddress, type ShippingTaxCalculationResponse, type ShippingTaxCartCalculateInput, type ShippingTaxMethod, type ShippingTaxQuoteInput, type ShippingTaxQuoteItem, StorefrontQuoteClient, type TaxLine, type TaxLineInput, ThrottleApiError, type UpdateCartInput, type UpdateCartSessionInput, type UpdateLineItemInput, cartErrorFromResponse };
package/dist/index.js CHANGED
@@ -9,13 +9,25 @@ var ThrottleApiError = class extends ThrottleError {
9
9
  };
10
10
  var CartNotOpenError = class extends ThrottleApiError {
11
11
  constructor(args) {
12
- super({ code: "cart_not_open", statusCode: args.statusCode ?? 409, message: args.message, details: args.details });
12
+ super({
13
+ code: "cart_not_open",
14
+ statusCode: args.statusCode ?? 409,
15
+ message: args.message,
16
+ details: args.details,
17
+ responseHeaders: args.responseHeaders
18
+ });
13
19
  this.name = "CartNotOpenError";
14
20
  }
15
21
  };
16
22
  var CartNotFoundError = class extends ThrottleApiError {
17
23
  constructor(args) {
18
- super({ code: "cart_not_found", statusCode: args.statusCode ?? 404, message: args.message, details: args.details });
24
+ super({
25
+ code: "cart_not_found",
26
+ statusCode: args.statusCode ?? 404,
27
+ message: args.message,
28
+ details: args.details,
29
+ responseHeaders: args.responseHeaders
30
+ });
19
31
  this.name = "CartNotFoundError";
20
32
  }
21
33
  };
@@ -32,10 +44,20 @@ var CartTimeoutError = class extends ThrottleError {
32
44
  };
33
45
  function cartErrorFromResponse(args) {
34
46
  if (args.statusCode === 409 && args.code === "cart_not_open") {
35
- return new CartNotOpenError({ message: args.message, statusCode: args.statusCode, details: args.details });
47
+ return new CartNotOpenError({
48
+ message: args.message,
49
+ statusCode: args.statusCode,
50
+ details: args.details,
51
+ responseHeaders: args.responseHeaders
52
+ });
36
53
  }
37
54
  if (args.statusCode === 404 && (args.code === "cart_not_found" || args.code === "not_found")) {
38
- return new CartNotFoundError({ message: args.message, statusCode: args.statusCode, details: args.details });
55
+ return new CartNotFoundError({
56
+ message: args.message,
57
+ statusCode: args.statusCode,
58
+ details: args.details,
59
+ responseHeaders: args.responseHeaders
60
+ });
39
61
  }
40
62
  return new ThrottleApiError(args);
41
63
  }
@@ -73,7 +95,8 @@ var CartClient = class {
73
95
  code: json?.error?.code ?? "unknown_error",
74
96
  message: json?.error?.message ?? `HTTP ${res.status}`,
75
97
  statusCode: res.status,
76
- details: json?.error?.details
98
+ details: json?.error?.details,
99
+ responseHeaders: res.headers
77
100
  });
78
101
  }
79
102
  return json.data;
@@ -180,7 +203,8 @@ var StorefrontQuoteClient = class {
180
203
  code: json?.error?.code ?? "unknown_error",
181
204
  message: json?.error?.message ?? `HTTP ${res.status}`,
182
205
  statusCode: res.status,
183
- details: json?.error?.details
206
+ details: json?.error?.details,
207
+ responseHeaders: res.headers
184
208
  });
185
209
  }
186
210
  return json.data;
@@ -350,7 +374,8 @@ var CartSessionClient = class _CartSessionClient {
350
374
  code: json?.error?.code ?? "unknown_error",
351
375
  message: json?.error?.message ?? `HTTP ${res.status}`,
352
376
  statusCode: res.status,
353
- details: json?.error?.details
377
+ details: json?.error?.details,
378
+ responseHeaders: res.headers
354
379
  });
355
380
  }
356
381
  return json.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/cart",
3
- "version": "3.9.1",
3
+ "version": "3.10.1",
4
4
  "description": "Typed REST client for the Throttle Cart API.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -18,7 +18,7 @@
18
18
  "README.md"
19
19
  ],
20
20
  "dependencies": {
21
- "@usethrottle/errors": "^1.0.0"
21
+ "@usethrottle/errors": "^1.1.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "tsup": "^8.0.0",