@cimplify/sdk 0.20.1 → 0.21.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.
@@ -1,4 +1,4 @@
1
- export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, k as CheckoutOperations, k as CheckoutService, K as CimplifyElement, J as CimplifyElements, W as ELEMENT_TYPES, V as EVENT_TYPES, _ as ElementEventType, Y as ElementOptions, Z as ElementType, X as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, N as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, S as SchedulingService, M as createElements, l as generateIdempotencyKey } from './client-D4E9aJy7.mjs';
1
+ export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, M as CimplifyElement, K as CimplifyElements, X as ELEMENT_TYPES, W as EVENT_TYPES, $ as ElementEventType, Z as ElementOptions, _ as ElementType, Y as ElementsOptions, F as FetchQuoteInput, r as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, q as LiteService, V as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, S as SchedulingService, N as createElements, m as generateIdempotencyKey } from './client-B8PO4NKN.mjs';
2
2
  import './payment-CKqMU4xT.mjs';
3
3
 
4
4
  type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
@@ -1,4 +1,4 @@
1
- export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, k as CheckoutOperations, k as CheckoutService, K as CimplifyElement, J as CimplifyElements, W as ELEMENT_TYPES, V as EVENT_TYPES, _ as ElementEventType, Y as ElementOptions, Z as ElementType, X as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, N as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, S as SchedulingService, M as createElements, l as generateIdempotencyKey } from './client-VyO6Bqz2.js';
1
+ export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, M as CimplifyElement, K as CimplifyElements, X as ELEMENT_TYPES, W as EVENT_TYPES, $ as ElementEventType, Z as ElementOptions, _ as ElementType, Y as ElementsOptions, F as FetchQuoteInput, r as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, q as LiteService, V as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, S as SchedulingService, N as createElements, m as generateIdempotencyKey } from './client-DjrlvxW7.js';
2
2
  import './payment-CKqMU4xT.js';
3
3
 
4
4
  type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
package/dist/advanced.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkFLPI2VVJ_js = require('./chunk-FLPI2VVJ.js');
4
- var chunkKSN3RJFL_js = require('./chunk-KSN3RJFL.js');
5
- require('./chunk-2BSYTQAY.js');
4
+ var chunkVYSXEDBV_js = require('./chunk-VYSXEDBV.js');
5
+ require('./chunk-64OCG2TJ.js');
6
6
 
7
7
 
8
8
 
@@ -16,77 +16,77 @@ Object.defineProperty(exports, "query", {
16
16
  });
17
17
  Object.defineProperty(exports, "AuthService", {
18
18
  enumerable: true,
19
- get: function () { return chunkKSN3RJFL_js.AuthService; }
19
+ get: function () { return chunkVYSXEDBV_js.AuthService; }
20
20
  });
21
21
  Object.defineProperty(exports, "BusinessService", {
22
22
  enumerable: true,
23
- get: function () { return chunkKSN3RJFL_js.BusinessService; }
23
+ get: function () { return chunkVYSXEDBV_js.BusinessService; }
24
24
  });
25
25
  Object.defineProperty(exports, "CartOperations", {
26
26
  enumerable: true,
27
- get: function () { return chunkKSN3RJFL_js.CartOperations; }
27
+ get: function () { return chunkVYSXEDBV_js.CartOperations; }
28
28
  });
29
29
  Object.defineProperty(exports, "CatalogueQueries", {
30
30
  enumerable: true,
31
- get: function () { return chunkKSN3RJFL_js.CatalogueQueries; }
31
+ get: function () { return chunkVYSXEDBV_js.CatalogueQueries; }
32
32
  });
33
33
  Object.defineProperty(exports, "CheckoutOperations", {
34
34
  enumerable: true,
35
- get: function () { return chunkKSN3RJFL_js.CheckoutService; }
35
+ get: function () { return chunkVYSXEDBV_js.CheckoutService; }
36
36
  });
37
37
  Object.defineProperty(exports, "CheckoutService", {
38
38
  enumerable: true,
39
- get: function () { return chunkKSN3RJFL_js.CheckoutService; }
39
+ get: function () { return chunkVYSXEDBV_js.CheckoutService; }
40
40
  });
41
41
  Object.defineProperty(exports, "CimplifyElement", {
42
42
  enumerable: true,
43
- get: function () { return chunkKSN3RJFL_js.CimplifyElement; }
43
+ get: function () { return chunkVYSXEDBV_js.CimplifyElement; }
44
44
  });
45
45
  Object.defineProperty(exports, "CimplifyElements", {
46
46
  enumerable: true,
47
- get: function () { return chunkKSN3RJFL_js.CimplifyElements; }
47
+ get: function () { return chunkVYSXEDBV_js.CimplifyElements; }
48
48
  });
49
49
  Object.defineProperty(exports, "ELEMENT_TYPES", {
50
50
  enumerable: true,
51
- get: function () { return chunkKSN3RJFL_js.ELEMENT_TYPES; }
51
+ get: function () { return chunkVYSXEDBV_js.ELEMENT_TYPES; }
52
52
  });
53
53
  Object.defineProperty(exports, "EVENT_TYPES", {
54
54
  enumerable: true,
55
- get: function () { return chunkKSN3RJFL_js.EVENT_TYPES; }
55
+ get: function () { return chunkVYSXEDBV_js.EVENT_TYPES; }
56
56
  });
57
57
  Object.defineProperty(exports, "FxService", {
58
58
  enumerable: true,
59
- get: function () { return chunkKSN3RJFL_js.FxService; }
59
+ get: function () { return chunkVYSXEDBV_js.FxService; }
60
60
  });
61
61
  Object.defineProperty(exports, "InventoryService", {
62
62
  enumerable: true,
63
- get: function () { return chunkKSN3RJFL_js.InventoryService; }
63
+ get: function () { return chunkVYSXEDBV_js.InventoryService; }
64
64
  });
65
65
  Object.defineProperty(exports, "LinkService", {
66
66
  enumerable: true,
67
- get: function () { return chunkKSN3RJFL_js.LinkService; }
67
+ get: function () { return chunkVYSXEDBV_js.LinkService; }
68
68
  });
69
69
  Object.defineProperty(exports, "LiteService", {
70
70
  enumerable: true,
71
- get: function () { return chunkKSN3RJFL_js.LiteService; }
71
+ get: function () { return chunkVYSXEDBV_js.LiteService; }
72
72
  });
73
73
  Object.defineProperty(exports, "MESSAGE_TYPES", {
74
74
  enumerable: true,
75
- get: function () { return chunkKSN3RJFL_js.MESSAGE_TYPES; }
75
+ get: function () { return chunkVYSXEDBV_js.MESSAGE_TYPES; }
76
76
  });
77
77
  Object.defineProperty(exports, "OrderQueries", {
78
78
  enumerable: true,
79
- get: function () { return chunkKSN3RJFL_js.OrderQueries; }
79
+ get: function () { return chunkVYSXEDBV_js.OrderQueries; }
80
80
  });
81
81
  Object.defineProperty(exports, "SchedulingService", {
82
82
  enumerable: true,
83
- get: function () { return chunkKSN3RJFL_js.SchedulingService; }
83
+ get: function () { return chunkVYSXEDBV_js.SchedulingService; }
84
84
  });
85
85
  Object.defineProperty(exports, "createElements", {
86
86
  enumerable: true,
87
- get: function () { return chunkKSN3RJFL_js.createElements; }
87
+ get: function () { return chunkVYSXEDBV_js.createElements; }
88
88
  });
89
89
  Object.defineProperty(exports, "generateIdempotencyKey", {
90
90
  enumerable: true,
91
- get: function () { return chunkKSN3RJFL_js.generateIdempotencyKey; }
91
+ get: function () { return chunkVYSXEDBV_js.generateIdempotencyKey; }
92
92
  });
package/dist/advanced.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  export { QueryBuilder, query } from './chunk-LM3CJ4L7.mjs';
2
- export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-7KH2XJIW.mjs';
3
- import './chunk-HG7GG3TT.mjs';
2
+ export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-R4EYMPSN.mjs';
3
+ import './chunk-JFT63H34.mjs';
@@ -61,8 +61,16 @@ var SUPPORTED_CURRENCY_CODES = /* @__PURE__ */ new Set([
61
61
  function isSupportedCurrency(code) {
62
62
  return SUPPORTED_CURRENCY_CODES.has(code);
63
63
  }
64
+ var warnedCurrencies = /* @__PURE__ */ new Set();
64
65
  function currencyCode(value) {
65
- return value;
66
+ const normalized = value.trim().toUpperCase();
67
+ if (!isSupportedCurrency(normalized) && !warnedCurrencies.has(normalized)) {
68
+ warnedCurrencies.add(normalized);
69
+ console.warn(
70
+ `[Cimplify] Unrecognized currency code "${normalized}". It may not format correctly.`
71
+ );
72
+ }
73
+ return normalized;
66
74
  }
67
75
  var ErrorCode = {
68
76
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
@@ -185,22 +193,17 @@ function getErrorHint(code) {
185
193
  }
186
194
  function enrichError(error, options = {}) {
187
195
  const hint = getErrorHint(error.code);
188
- if (hint) {
189
- if (!error.docs_url) {
190
- error.docs_url = hint.docs_url;
191
- }
192
- if (!error.suggestion) {
193
- error.suggestion = hint.suggestion;
194
- }
195
- } else if (!error.docs_url) {
196
- error.docs_url = docsUrlForCode(error.code || ErrorCode.UNKNOWN_ERROR);
197
- }
198
- if (options.isTestMode && !error.message.includes("pk_test_")) {
199
- error.message = `${error.message}
196
+ const docsUrl = error.docs_url || hint?.docs_url || docsUrlForCode(error.code || ErrorCode.UNKNOWN_ERROR);
197
+ const suggestion = error.suggestion || hint?.suggestion;
198
+ let message = error.message;
199
+ if (options.isTestMode && !message.includes("pk_test_")) {
200
+ message = `${message}
200
201
 
201
202
  \u2139 Your API key is a test-mode key (pk_test_...). Verify test data/session before retrying.`;
202
203
  }
203
- return error;
204
+ const enriched = new CimplifyError(error.code, message, error.retryable, docsUrl, suggestion);
205
+ enriched.stack = error.stack;
206
+ return enriched;
204
207
  }
205
208
  function isRetryableError(error) {
206
209
  if (isCimplifyError(error)) {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkKSN3RJFL_js = require('./chunk-KSN3RJFL.js');
4
- var chunk2BSYTQAY_js = require('./chunk-2BSYTQAY.js');
3
+ var chunkVYSXEDBV_js = require('./chunk-VYSXEDBV.js');
4
+ var chunk64OCG2TJ_js = require('./chunk-64OCG2TJ.js');
5
5
 
6
6
  // src/activity.ts
7
7
  var ActivityService = class {
@@ -29,7 +29,7 @@ var ActivityService = class {
29
29
  this.sendEvents([event]);
30
30
  }
31
31
  async getState() {
32
- return chunkKSN3RJFL_js.safe(this.client.get("/api/v1/activity/state"));
32
+ return chunkVYSXEDBV_js.safe(this.client.get("/api/v1/activity/state"));
33
33
  }
34
34
  async getRecommendations(options) {
35
35
  const params = new URLSearchParams();
@@ -37,10 +37,10 @@ var ActivityService = class {
37
37
  if (options?.limit) params.set("limit", String(options.limit));
38
38
  const query = params.toString();
39
39
  const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
40
- return chunkKSN3RJFL_js.safe(this.client.get(path));
40
+ return chunkVYSXEDBV_js.safe(this.client.get(path));
41
41
  }
42
42
  async dismissMessage(code) {
43
- return chunkKSN3RJFL_js.safe(
43
+ return chunkVYSXEDBV_js.safe(
44
44
  this.client.post("/api/v1/activity/messages/dismiss", { code })
45
45
  );
46
46
  }
@@ -66,7 +66,7 @@ var DeliveryService = class {
66
66
  params.set("dropoff_lat", String(dropoffLat));
67
67
  params.set("dropoff_lng", String(dropoffLng));
68
68
  if (country) params.set("country", country);
69
- return chunkKSN3RJFL_js.safe(
69
+ return chunkVYSXEDBV_js.safe(
70
70
  this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
71
71
  );
72
72
  }
@@ -91,16 +91,16 @@ function isRetryable(error) {
91
91
  if (error instanceof DOMException && error.name === "AbortError") {
92
92
  return true;
93
93
  }
94
- if (error instanceof chunk2BSYTQAY_js.CimplifyError) {
94
+ if (error instanceof chunk64OCG2TJ_js.CimplifyError) {
95
95
  return error.retryable;
96
96
  }
97
97
  return false;
98
98
  }
99
99
  function toNetworkError(error, isTestMode) {
100
100
  if (error instanceof DOMException && error.name === "AbortError") {
101
- return chunk2BSYTQAY_js.enrichError(
102
- new chunk2BSYTQAY_js.CimplifyError(
103
- chunk2BSYTQAY_js.ErrorCode.TIMEOUT,
101
+ return chunk64OCG2TJ_js.enrichError(
102
+ new chunk64OCG2TJ_js.CimplifyError(
103
+ chunk64OCG2TJ_js.ErrorCode.TIMEOUT,
104
104
  "Request timed out. Please check your connection and try again.",
105
105
  true
106
106
  ),
@@ -108,21 +108,21 @@ function toNetworkError(error, isTestMode) {
108
108
  );
109
109
  }
110
110
  if (error instanceof TypeError && error.message.includes("fetch")) {
111
- return chunk2BSYTQAY_js.enrichError(
112
- new chunk2BSYTQAY_js.CimplifyError(
113
- chunk2BSYTQAY_js.ErrorCode.NETWORK_ERROR,
111
+ return chunk64OCG2TJ_js.enrichError(
112
+ new chunk64OCG2TJ_js.CimplifyError(
113
+ chunk64OCG2TJ_js.ErrorCode.NETWORK_ERROR,
114
114
  "Network error. Please check your internet connection.",
115
115
  true
116
116
  ),
117
117
  { isTestMode }
118
118
  );
119
119
  }
120
- if (error instanceof chunk2BSYTQAY_js.CimplifyError) {
121
- return chunk2BSYTQAY_js.enrichError(error, { isTestMode });
120
+ if (error instanceof chunk64OCG2TJ_js.CimplifyError) {
121
+ return chunk64OCG2TJ_js.enrichError(error, { isTestMode });
122
122
  }
123
- return chunk2BSYTQAY_js.enrichError(
124
- new chunk2BSYTQAY_js.CimplifyError(
125
- chunk2BSYTQAY_js.ErrorCode.UNKNOWN_ERROR,
123
+ return chunk64OCG2TJ_js.enrichError(
124
+ new chunk64OCG2TJ_js.CimplifyError(
125
+ chunk64OCG2TJ_js.ErrorCode.UNKNOWN_ERROR,
126
126
  error instanceof Error ? error.message : "An unknown error occurred",
127
127
  false
128
128
  ),
@@ -289,8 +289,8 @@ var CimplifyClient = class {
289
289
  this.businessIdResolvePromise = (async () => {
290
290
  const result = await this.business.getInfo();
291
291
  if (!result.ok || !result.value?.id) {
292
- throw new chunk2BSYTQAY_js.CimplifyError(
293
- chunk2BSYTQAY_js.ErrorCode.NOT_FOUND,
292
+ throw new chunk64OCG2TJ_js.CimplifyError(
293
+ chunk64OCG2TJ_js.ErrorCode.NOT_FOUND,
294
294
  "Unable to resolve business ID from the current public key.",
295
295
  true
296
296
  );
@@ -407,7 +407,7 @@ var CimplifyClient = class {
407
407
  if (response.status >= 400 && response.status < 500) {
408
408
  this.hooks.onRequestError?.({
409
409
  ...context,
410
- error: new chunk2BSYTQAY_js.CimplifyError(
410
+ error: new chunk64OCG2TJ_js.CimplifyError(
411
411
  `HTTP_${response.status}`,
412
412
  `Request failed with status ${response.status}`,
413
413
  false
@@ -433,7 +433,7 @@ var CimplifyClient = class {
433
433
  }
434
434
  this.hooks.onRequestError?.({
435
435
  ...context,
436
- error: new chunk2BSYTQAY_js.CimplifyError(
436
+ error: new chunk64OCG2TJ_js.CimplifyError(
437
437
  "SERVER_ERROR",
438
438
  `Server error ${response.status} after ${retryCount} retries`,
439
439
  false
@@ -564,15 +564,15 @@ var CimplifyClient = class {
564
564
  const errorCode = typeof json.error === "object" && json.error?.error_code || typeof json.error === "object" && json.error?.code || "API_ERROR";
565
565
  const errorMessage = typeof json.error === "object" && json.error?.error_message || typeof json.error === "object" && json.error?.message || typeof json.error === "string" && json.error || typeof json.message === "string" && json.message || "An error occurred";
566
566
  const retryable = typeof json.error === "object" && typeof json.error?.retryable === "boolean" ? json.error.retryable : false;
567
- const error = chunk2BSYTQAY_js.enrichError(
568
- new chunk2BSYTQAY_js.CimplifyError(
567
+ const error = chunk64OCG2TJ_js.enrichError(
568
+ new chunk64OCG2TJ_js.CimplifyError(
569
569
  errorCode,
570
570
  errorMessage,
571
571
  retryable
572
572
  ),
573
573
  { isTestMode: this.isTestMode() }
574
574
  );
575
- if (response.status === 401 || error.code === chunk2BSYTQAY_js.ErrorCode.UNAUTHORIZED) {
575
+ if (response.status === 401 || error.code === chunk64OCG2TJ_js.ErrorCode.UNAUTHORIZED) {
576
576
  console.warn(
577
577
  "[Cimplify] Received 401 Unauthorized. Access token may be missing/expired. Refresh authentication and retry the request."
578
578
  );
@@ -580,8 +580,8 @@ var CimplifyClient = class {
580
580
  throw error;
581
581
  }
582
582
  if (json?.success === false || json?.error?.code || json?.error?.message) {
583
- const error = chunk2BSYTQAY_js.enrichError(
584
- new chunk2BSYTQAY_js.CimplifyError(
583
+ const error = chunk64OCG2TJ_js.enrichError(
584
+ new chunk64OCG2TJ_js.CimplifyError(
585
585
  json.error?.code || "API_ERROR",
586
586
  json.error?.message || "An error occurred",
587
587
  json.error?.retryable || false
@@ -597,67 +597,67 @@ var CimplifyClient = class {
597
597
  }
598
598
  get catalogue() {
599
599
  if (!this._catalogue) {
600
- this._catalogue = new chunkKSN3RJFL_js.CatalogueQueries(this);
600
+ this._catalogue = new chunkVYSXEDBV_js.CatalogueQueries(this);
601
601
  }
602
602
  return this._catalogue;
603
603
  }
604
604
  get cart() {
605
605
  if (!this._cart) {
606
- this._cart = new chunkKSN3RJFL_js.CartOperations(this);
606
+ this._cart = new chunkVYSXEDBV_js.CartOperations(this);
607
607
  }
608
608
  return this._cart;
609
609
  }
610
610
  get checkout() {
611
611
  if (!this._checkout) {
612
- this._checkout = new chunkKSN3RJFL_js.CheckoutService(this);
612
+ this._checkout = new chunkVYSXEDBV_js.CheckoutService(this);
613
613
  }
614
614
  return this._checkout;
615
615
  }
616
616
  get orders() {
617
617
  if (!this._orders) {
618
- this._orders = new chunkKSN3RJFL_js.OrderQueries(this);
618
+ this._orders = new chunkVYSXEDBV_js.OrderQueries(this);
619
619
  }
620
620
  return this._orders;
621
621
  }
622
622
  get link() {
623
623
  if (!this._link) {
624
- this._link = new chunkKSN3RJFL_js.LinkService(this);
624
+ this._link = new chunkVYSXEDBV_js.LinkService(this);
625
625
  }
626
626
  return this._link;
627
627
  }
628
628
  get auth() {
629
629
  if (!this._auth) {
630
- this._auth = new chunkKSN3RJFL_js.AuthService(this);
630
+ this._auth = new chunkVYSXEDBV_js.AuthService(this);
631
631
  }
632
632
  return this._auth;
633
633
  }
634
634
  get business() {
635
635
  if (!this._business) {
636
- this._business = new chunkKSN3RJFL_js.BusinessService(this);
636
+ this._business = new chunkVYSXEDBV_js.BusinessService(this);
637
637
  }
638
638
  return this._business;
639
639
  }
640
640
  get inventory() {
641
641
  if (!this._inventory) {
642
- this._inventory = new chunkKSN3RJFL_js.InventoryService(this);
642
+ this._inventory = new chunkVYSXEDBV_js.InventoryService(this);
643
643
  }
644
644
  return this._inventory;
645
645
  }
646
646
  get scheduling() {
647
647
  if (!this._scheduling) {
648
- this._scheduling = new chunkKSN3RJFL_js.SchedulingService(this);
648
+ this._scheduling = new chunkVYSXEDBV_js.SchedulingService(this);
649
649
  }
650
650
  return this._scheduling;
651
651
  }
652
652
  get lite() {
653
653
  if (!this._lite) {
654
- this._lite = new chunkKSN3RJFL_js.LiteService(this);
654
+ this._lite = new chunkVYSXEDBV_js.LiteService(this);
655
655
  }
656
656
  return this._lite;
657
657
  }
658
658
  get fx() {
659
659
  if (!this._fx) {
660
- this._fx = new chunkKSN3RJFL_js.FxService(this);
660
+ this._fx = new chunkVYSXEDBV_js.FxService(this);
661
661
  }
662
662
  return this._fx;
663
663
  }
@@ -677,7 +677,7 @@ var CimplifyClient = class {
677
677
  if (businessId) {
678
678
  this.setBusinessId(businessId);
679
679
  }
680
- return chunkKSN3RJFL_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
680
+ return chunkVYSXEDBV_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
681
681
  }
682
682
  };
683
683
  function createCimplifyClient(config = {}) {
@@ -59,8 +59,16 @@ var SUPPORTED_CURRENCY_CODES = /* @__PURE__ */ new Set([
59
59
  function isSupportedCurrency(code) {
60
60
  return SUPPORTED_CURRENCY_CODES.has(code);
61
61
  }
62
+ var warnedCurrencies = /* @__PURE__ */ new Set();
62
63
  function currencyCode(value) {
63
- return value;
64
+ const normalized = value.trim().toUpperCase();
65
+ if (!isSupportedCurrency(normalized) && !warnedCurrencies.has(normalized)) {
66
+ warnedCurrencies.add(normalized);
67
+ console.warn(
68
+ `[Cimplify] Unrecognized currency code "${normalized}". It may not format correctly.`
69
+ );
70
+ }
71
+ return normalized;
64
72
  }
65
73
  var ErrorCode = {
66
74
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
@@ -183,22 +191,17 @@ function getErrorHint(code) {
183
191
  }
184
192
  function enrichError(error, options = {}) {
185
193
  const hint = getErrorHint(error.code);
186
- if (hint) {
187
- if (!error.docs_url) {
188
- error.docs_url = hint.docs_url;
189
- }
190
- if (!error.suggestion) {
191
- error.suggestion = hint.suggestion;
192
- }
193
- } else if (!error.docs_url) {
194
- error.docs_url = docsUrlForCode(error.code || ErrorCode.UNKNOWN_ERROR);
195
- }
196
- if (options.isTestMode && !error.message.includes("pk_test_")) {
197
- error.message = `${error.message}
194
+ const docsUrl = error.docs_url || hint?.docs_url || docsUrlForCode(error.code || ErrorCode.UNKNOWN_ERROR);
195
+ const suggestion = error.suggestion || hint?.suggestion;
196
+ let message = error.message;
197
+ if (options.isTestMode && !message.includes("pk_test_")) {
198
+ message = `${message}
198
199
 
199
200
  \u2139 Your API key is a test-mode key (pk_test_...). Verify test data/session before retrying.`;
200
201
  }
201
- return error;
202
+ const enriched = new CimplifyError(error.code, message, error.retryable, docsUrl, suggestion);
203
+ enriched.stack = error.stack;
204
+ return enriched;
202
205
  }
203
206
  function isRetryableError(error) {
204
207
  if (isCimplifyError(error)) {
@@ -1,4 +1,4 @@
1
- import { CimplifyError, currencyCode, ErrorCode, enrichError, isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure, getErrorHint } from './chunk-HG7GG3TT.mjs';
1
+ import { CimplifyError, currencyCode, ErrorCode, enrichError, isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure, getErrorHint } from './chunk-JFT63H34.mjs';
2
2
 
3
3
  // src/types/result.ts
4
4
  function ok(value) {
@@ -507,23 +507,26 @@ var CatalogueQueries = class {
507
507
  );
508
508
  }
509
509
  async getProductAttributes(productId) {
510
+ const encodedId = encodeURIComponent(productId);
510
511
  return safe(
511
512
  this.client.get(
512
- `/api/v1/catalogue/products/${productId}/attributes`
513
+ `/api/v1/catalogue/products/${encodedId}/attributes`
513
514
  )
514
515
  );
515
516
  }
516
517
  async getCategoryAttributes(categoryId) {
518
+ const encodedId = encodeURIComponent(categoryId);
517
519
  return safe(
518
520
  this.client.get(
519
- `/api/v1/catalogue/categories/${categoryId}/attributes`
521
+ `/api/v1/catalogue/categories/${encodedId}/attributes`
520
522
  )
521
523
  );
522
524
  }
523
525
  async getCollectionAttributes(collectionId) {
526
+ const encodedId = encodeURIComponent(collectionId);
524
527
  return safe(
525
528
  this.client.get(
526
- `/api/v1/catalogue/collections/${collectionId}/attributes`
529
+ `/api/v1/catalogue/collections/${encodedId}/attributes`
527
530
  )
528
531
  );
529
532
  }
@@ -557,6 +560,25 @@ var CatalogueQueries = class {
557
560
  };
558
561
 
559
562
  // src/cart.ts
563
+ function lineItemToCartInput(item) {
564
+ const config = item.configuration;
565
+ const input = {
566
+ item_id: item.product_id,
567
+ quantity: item.quantity
568
+ };
569
+ if (config.variant) {
570
+ input.variant_id = config.variant.variant_id;
571
+ }
572
+ if (config.add_ons && config.add_ons.selected_options.length > 0) {
573
+ input.add_on_options = config.add_ons.selected_options.map((o) => o.option_id);
574
+ }
575
+ if (config.type === "bundle") {
576
+ input.bundle_selections = config.input;
577
+ } else if (config.type === "composite") {
578
+ input.composite_selections = config.input;
579
+ }
580
+ return input;
581
+ }
560
582
  function isUICartResponse(value) {
561
583
  return "cart" in value;
562
584
  }
@@ -633,6 +655,26 @@ var CartOperations = class {
633
655
  async removeCoupon() {
634
656
  return safe(this.client.delete("/api/v1/cart/coupons/current"));
635
657
  }
658
+ async reorderFromOrder(orderId) {
659
+ const orderResult = await this.client.orders.get(orderId);
660
+ if (!orderResult.ok) return orderResult;
661
+ const order = orderResult.value;
662
+ if (!order.items || order.items.length === 0) {
663
+ return ok({ added: [], failed: [] });
664
+ }
665
+ const added = [];
666
+ const failed = [];
667
+ for (const item of order.items) {
668
+ const input = lineItemToCartInput(item);
669
+ const result = await this.addItem(input);
670
+ if (result.ok) {
671
+ added.push({ item_id: input.item_id });
672
+ } else {
673
+ failed.push({ item_id: input.item_id, error: result.error });
674
+ }
675
+ }
676
+ return ok({ added, failed });
677
+ }
636
678
  async isEmpty() {
637
679
  const countResult = await this.getCount();
638
680
  if (!countResult.ok) return countResult;