@cimplify/sdk 0.100.0 → 0.100.2

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.
Files changed (67) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/advanced.js +22 -22
  4. package/dist/advanced.mjs +3 -3
  5. package/dist/{chunk-X6G6QERR.js → chunk-6JEKKL3M.js} +53 -38
  6. package/dist/{chunk-7TEMLVDT.mjs → chunk-B2YOCOLH.mjs} +2 -2
  7. package/dist/{chunk-V5TU5JKA.mjs → chunk-DLW3RWRK.mjs} +30 -6
  8. package/dist/{chunk-FECGCIVV.js → chunk-IFAQLFAJ.js} +4 -4
  9. package/dist/{chunk-J3UYIBKH.js → chunk-IJI7KMTG.js} +89 -82
  10. package/dist/{chunk-AETVRBKI.js → chunk-NIOUSKQQ.js} +1 -0
  11. package/dist/{chunk-K5EN2W2Q.mjs → chunk-O3YUHLZL.mjs} +1 -0
  12. package/dist/{chunk-GWKIDFN6.mjs → chunk-PJUXAUM2.mjs} +20 -14
  13. package/dist/{chunk-ZA5VKVUB.js → chunk-QRBBSIAY.js} +4 -4
  14. package/dist/{chunk-OX5L6XE7.mjs → chunk-TIQLOH2B.mjs} +30 -15
  15. package/dist/{chunk-64EDCDBR.js → chunk-WMEC5JWN.js} +32 -7
  16. package/dist/{chunk-I7L4VRHI.mjs → chunk-YWNJJO2U.mjs} +2 -2
  17. package/dist/{client-DQpvwf-p.d.mts → client-C6wb92AD.d.mts} +2 -2
  18. package/dist/{client-DmR3Z6pQ.d.ts → client-CgXkRu2o.d.ts} +2 -2
  19. package/dist/{client-C1vS5pf0.d.ts → client-D8XcrONA.d.mts} +38 -26
  20. package/dist/{client-B5MeD8da.d.mts → client-LPg_AUUr.d.ts} +38 -26
  21. package/dist/{index-Br-vFygC.d.ts → index-B_RYmvlF.d.ts} +3 -3
  22. package/dist/{index-DUOCn1Cs.d.mts → index-D-LUYk1Y.d.mts} +3 -3
  23. package/dist/index.d.mts +7 -7
  24. package/dist/index.d.ts +7 -7
  25. package/dist/index.js +117 -117
  26. package/dist/index.mjs +5 -5
  27. package/dist/mock/cli.mjs +1 -1
  28. package/dist/mock/library.js +1 -1
  29. package/dist/mock/library.mjs +1 -1
  30. package/dist/mock/msw.js +1 -1
  31. package/dist/mock/msw.mjs +1 -1
  32. package/dist/{payment-BIpS9oPG.d.mts → payment-BSzy7sly.d.mts} +1 -1
  33. package/dist/{payment-CsuBKHqg.d.ts → payment-jK8ztICx.d.ts} +1 -1
  34. package/dist/{price-Ml_uPoiY.d.ts → price-CJLfcYKd.d.ts} +1 -1
  35. package/dist/{price-IOOoVYS-.d.mts → price-D96h6c6L.d.mts} +1 -1
  36. package/dist/{product-BKV6TBj_.d.ts → product-CeV8euw4.d.mts} +23 -11
  37. package/dist/{product-BKV6TBj_.d.mts → product-CeV8euw4.d.ts} +23 -11
  38. package/dist/react.d.mts +10 -5
  39. package/dist/react.d.ts +10 -5
  40. package/dist/react.js +856 -450
  41. package/dist/react.mjs +737 -331
  42. package/dist/{server-C0iEk55_.d.mts → server--RyVAfPN.d.mts} +1 -1
  43. package/dist/{server-CfpYhSV_.d.ts → server-CNyy47HL.d.ts} +1 -1
  44. package/dist/server.d.mts +4 -4
  45. package/dist/server.d.ts +4 -4
  46. package/dist/server.js +10 -10
  47. package/dist/server.mjs +4 -4
  48. package/dist/testing/msw.d.mts +2 -2
  49. package/dist/testing/msw.d.ts +2 -2
  50. package/dist/testing/msw.js +3 -3
  51. package/dist/testing/msw.mjs +2 -2
  52. package/dist/testing/suite.d.mts +6 -6
  53. package/dist/testing/suite.d.ts +6 -6
  54. package/dist/testing/suite.js +25 -25
  55. package/dist/testing/suite.mjs +6 -6
  56. package/dist/testing.d.mts +5 -5
  57. package/dist/testing.d.ts +5 -5
  58. package/dist/testing.js +81 -81
  59. package/dist/testing.mjs +7 -7
  60. package/dist/utils.d.mts +4 -4
  61. package/dist/utils.d.ts +4 -4
  62. package/dist/utils.js +29 -29
  63. package/dist/utils.mjs +2 -2
  64. package/package.json +1 -1
  65. package/registry/cart-summary.json +1 -1
  66. package/registry/product-customizer.json +1 -1
  67. package/registry/sale-badge.json +1 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkX6G6QERR_js = require('./chunk-X6G6QERR.js');
4
- var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
3
+ var chunk6JEKKL3M_js = require('./chunk-6JEKKL3M.js');
4
+ var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
5
5
 
6
6
  // src/store-credit.ts
7
7
  var StoreCreditQueries = class {
@@ -13,7 +13,7 @@ var StoreCreditQueries = class {
13
13
  * currency. Requires a signed-in customer; returns an error otherwise.
14
14
  */
15
15
  async balance() {
16
- return chunkX6G6QERR_js.safe(this.client.get("/api/v1/store-credit/balance"));
16
+ return chunk6JEKKL3M_js.safe(this.client.get("/api/v1/store-credit/balance"));
17
17
  }
18
18
  };
19
19
 
@@ -105,7 +105,7 @@ var ActivityService = class {
105
105
  this.sendEvents([event]);
106
106
  }
107
107
  async getState() {
108
- return chunkX6G6QERR_js.safe(this.client.get("/api/v1/activity/state"));
108
+ return chunk6JEKKL3M_js.safe(this.client.get("/api/v1/activity/state"));
109
109
  }
110
110
  async getRecommendations(options) {
111
111
  const params = new URLSearchParams();
@@ -113,10 +113,10 @@ var ActivityService = class {
113
113
  if (options?.limit) params.set("limit", String(options.limit));
114
114
  const query = params.toString();
115
115
  const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
116
- return chunkX6G6QERR_js.safe(this.client.get(path));
116
+ return chunk6JEKKL3M_js.safe(this.client.get(path));
117
117
  }
118
118
  async dismissMessage(code) {
119
- return chunkX6G6QERR_js.safe(
119
+ return chunk6JEKKL3M_js.safe(
120
120
  this.client.post("/api/v1/activity/messages/dismiss", { code })
121
121
  );
122
122
  }
@@ -189,16 +189,16 @@ var SubscriptionService = class {
189
189
  this.client = client;
190
190
  }
191
191
  async list() {
192
- return chunkX6G6QERR_js.safe(this.client.get("/api/v1/subscriptions"));
192
+ return chunk6JEKKL3M_js.safe(this.client.get("/api/v1/subscriptions"));
193
193
  }
194
194
  async get(id) {
195
195
  const encodedId = encodeURIComponent(id);
196
- return chunkX6G6QERR_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
196
+ return chunk6JEKKL3M_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
197
197
  }
198
198
  async cancel(id, reason, opts) {
199
199
  const encodedId = encodeURIComponent(id);
200
- const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
201
- return chunkX6G6QERR_js.safe(
200
+ const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
201
+ return chunk6JEKKL3M_js.safe(
202
202
  this.client.post(
203
203
  `/api/v1/subscriptions/${encodedId}/cancel`,
204
204
  { reason },
@@ -208,20 +208,20 @@ var SubscriptionService = class {
208
208
  }
209
209
  async pause(id) {
210
210
  const encodedId = encodeURIComponent(id);
211
- return chunkX6G6QERR_js.safe(
211
+ return chunk6JEKKL3M_js.safe(
212
212
  this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
213
213
  );
214
214
  }
215
215
  async resume(id) {
216
216
  const encodedId = encodeURIComponent(id);
217
- return chunkX6G6QERR_js.safe(
217
+ return chunk6JEKKL3M_js.safe(
218
218
  this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
219
219
  );
220
220
  }
221
221
  async skipNextRenewal(id, opts) {
222
222
  const encodedId = encodeURIComponent(id);
223
- const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
224
- return chunkX6G6QERR_js.safe(
223
+ const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
224
+ return chunk6JEKKL3M_js.safe(
225
225
  this.client.post(
226
226
  `/api/v1/subscriptions/${encodedId}/skip`,
227
227
  void 0,
@@ -237,8 +237,8 @@ var UploadService = class {
237
237
  this.client = client;
238
238
  }
239
239
  async init(filename, contentType, sizeBytes, opts) {
240
- const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
241
- return chunkX6G6QERR_js.safe(
240
+ const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
241
+ return chunk6JEKKL3M_js.safe(
242
242
  this.client.post(
243
243
  "/api/v1/uploads/init",
244
244
  {
@@ -251,7 +251,7 @@ var UploadService = class {
251
251
  );
252
252
  }
253
253
  async confirm(uploadId) {
254
- return chunkX6G6QERR_js.safe(
254
+ return chunk6JEKKL3M_js.safe(
255
255
  this.client.post("/api/v1/uploads/confirm", {
256
256
  upload_id: uploadId
257
257
  })
@@ -270,7 +270,7 @@ var UploadService = class {
270
270
  if (!uploadResponse.ok) {
271
271
  return {
272
272
  ok: false,
273
- error: new chunkAETVRBKI_js.CimplifyError(
273
+ error: new chunkNIOUSKQQ_js.CimplifyError(
274
274
  "UPLOAD_FAILED",
275
275
  `Upload failed with status ${uploadResponse.status}`,
276
276
  true
@@ -280,7 +280,7 @@ var UploadService = class {
280
280
  } catch (error) {
281
281
  return {
282
282
  ok: false,
283
- error: new chunkAETVRBKI_js.CimplifyError(
283
+ error: new chunkNIOUSKQQ_js.CimplifyError(
284
284
  "UPLOAD_FAILED",
285
285
  error instanceof Error ? error.message : "Upload failed",
286
286
  true
@@ -297,7 +297,7 @@ var PlacesService = class {
297
297
  this.client = client;
298
298
  }
299
299
  async autocomplete(input, sessionToken) {
300
- return chunkX6G6QERR_js.safe(
300
+ return chunk6JEKKL3M_js.safe(
301
301
  this.client.post("/api/v1/places/autocomplete", {
302
302
  input,
303
303
  sessionToken
@@ -305,7 +305,7 @@ var PlacesService = class {
305
305
  );
306
306
  }
307
307
  async details(placeId, sessionToken) {
308
- return chunkX6G6QERR_js.safe(
308
+ return chunk6JEKKL3M_js.safe(
309
309
  this.client.post("/api/v1/places/details", {
310
310
  place_id: placeId,
311
311
  sessionToken
@@ -324,19 +324,20 @@ var DeliveryService = class {
324
324
  params.set("dropoff_lat", String(dropoffLat));
325
325
  params.set("dropoff_lng", String(dropoffLng));
326
326
  if (country) params.set("country", country);
327
- return chunkX6G6QERR_js.safe(
328
- this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
329
- );
330
- }
331
- /** The full delivery menu for an address. Pass the selected option's
332
- * `rate_id` as `delivery_rate_id` when processing checkout. */
333
- async getOptions(dropoffLat, dropoffLng, opts) {
327
+ return chunk6JEKKL3M_js.safe(this.client.get(`/api/v1/delivery/fee?${params.toString()}`));
328
+ }
329
+ async getOptions(queryOrLatitude, longitude, legacyOptions) {
330
+ const query = typeof queryOrLatitude === "number" ? {
331
+ ...legacyOptions,
332
+ dropoffLat: queryOrLatitude,
333
+ dropoffLng: longitude
334
+ } : queryOrLatitude ?? {};
334
335
  const params = new URLSearchParams();
335
- params.set("dropoff_lat", String(dropoffLat));
336
- params.set("dropoff_lng", String(dropoffLng));
337
- if (opts?.country) params.set("country", opts.country);
338
- if (opts?.orderValue != null) params.set("order_value", String(opts.orderValue));
339
- return chunkX6G6QERR_js.safe(
336
+ if (query.dropoffLat != null) params.set("dropoff_lat", String(query.dropoffLat));
337
+ if (query.dropoffLng != null) params.set("dropoff_lng", String(query.dropoffLng));
338
+ if (query.country) params.set("country", query.country);
339
+ if (query.orderValue != null) params.set("order_value", String(query.orderValue));
340
+ return chunk6JEKKL3M_js.safe(
340
341
  this.client.get(`/api/v1/delivery/options?${params.toString()}`)
341
342
  );
342
343
  }
@@ -413,7 +414,7 @@ var SupportService = class {
413
414
  async claimConversation() {
414
415
  const accessToken = this.client.getAccessToken();
415
416
  if (!accessToken) {
416
- return chunkX6G6QERR_js.err(new chunkAETVRBKI_js.CimplifyError("not_authenticated", "No access token to claim with"));
417
+ return chunk6JEKKL3M_js.err(new chunkNIOUSKQQ_js.CimplifyError("not_authenticated", "No access token to claim with"));
417
418
  }
418
419
  if (this.claimInFlight) {
419
420
  if (this.claimInFlightToken === accessToken) return this.claimInFlight;
@@ -421,12 +422,12 @@ var SupportService = class {
421
422
  return this.claimConversation();
422
423
  }
423
424
  if (this.lastClaimedAccessToken === accessToken) {
424
- return chunkX6G6QERR_js.err(new chunkAETVRBKI_js.CimplifyError("already_claimed", "Session already claimed for this token"));
425
+ return chunk6JEKKL3M_js.err(new chunkNIOUSKQQ_js.CimplifyError("already_claimed", "Session already claimed for this token"));
425
426
  }
426
427
  const epoch = this.client.getSessionEpoch();
427
428
  this.claimInFlightToken = accessToken;
428
429
  this.claimInFlight = (async () => {
429
- const result = await chunkX6G6QERR_js.safe(
430
+ const result = await chunk6JEKKL3M_js.safe(
430
431
  this.client.post(
431
432
  "/api/v1/support/conversation/claim",
432
433
  { access_token: accessToken },
@@ -435,8 +436,8 @@ var SupportService = class {
435
436
  );
436
437
  if (result.ok) {
437
438
  if (this.client.getSessionEpoch() !== epoch) {
438
- return chunkX6G6QERR_js.err(
439
- new chunkAETVRBKI_js.CimplifyError("session_cleared", "Session was cleared during the claim")
439
+ return chunk6JEKKL3M_js.err(
440
+ new chunkNIOUSKQQ_js.CimplifyError("session_cleared", "Session was cleared during the claim")
440
441
  );
441
442
  }
442
443
  this.lastClaimedAccessToken = accessToken;
@@ -464,20 +465,20 @@ var SupportService = class {
464
465
  * the inbox with empty threads.
465
466
  */
466
467
  async peekConversation() {
467
- const result = await chunkX6G6QERR_js.safe(
468
+ const result = await chunk6JEKKL3M_js.safe(
468
469
  this.client.get("/api/v1/support/conversation")
469
470
  );
470
471
  if (!result.ok) return result;
471
- if (!result.value.conversation) return chunkX6G6QERR_js.ok(null);
472
- return chunkX6G6QERR_js.ok({
472
+ if (!result.value.conversation) return chunk6JEKKL3M_js.ok(null);
473
+ return chunk6JEKKL3M_js.ok({
473
474
  conversation: result.value.conversation,
474
475
  messages: result.value.messages
475
476
  });
476
477
  }
477
478
  /** Open (or resume) the customer's widget conversation. */
478
479
  async openConversation(opts) {
479
- const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
480
- return chunkX6G6QERR_js.safe(
480
+ const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
481
+ return chunk6JEKKL3M_js.safe(
481
482
  this.client.post("/api/v1/support/conversation", void 0, {
482
483
  idempotencyKey
483
484
  })
@@ -492,8 +493,8 @@ var SupportService = class {
492
493
  * server resolves it thread-scoped and echoes the quote as `reply_to`.
493
494
  */
494
495
  async sendMessage(content, opts) {
495
- const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
496
- return chunkX6G6QERR_js.safe(
496
+ const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
497
+ return chunk6JEKKL3M_js.safe(
497
498
  this.client.post(
498
499
  "/api/v1/support/conversation/messages",
499
500
  {
@@ -517,11 +518,11 @@ var SupportService = class {
517
518
  if (options.limit) params.set("limit", String(options.limit));
518
519
  const query = params.toString();
519
520
  const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
520
- return chunkX6G6QERR_js.safe(this.client.get(path));
521
+ return chunk6JEKKL3M_js.safe(this.client.get(path));
521
522
  }
522
523
  /** React to a message in the active conversation by its `ChatMessage.id`. */
523
524
  async reactToMessage(messageId, emoji) {
524
- return chunkX6G6QERR_js.safe(
525
+ return chunk6JEKKL3M_js.safe(
525
526
  this.client.post(
526
527
  `/api/v1/support/conversation/messages/${messageId}/reactions`,
527
528
  { emoji }
@@ -530,8 +531,8 @@ var SupportService = class {
530
531
  }
531
532
  /** Ask for a person: flags the thread for the merchant's inbox. */
532
533
  async requestHuman(opts) {
533
- const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
534
- return chunkX6G6QERR_js.safe(
534
+ const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
535
+ return chunk6JEKKL3M_js.safe(
535
536
  this.client.post(
536
537
  "/api/v1/support/conversation/handoff",
537
538
  void 0,
@@ -591,16 +592,16 @@ function isRetryable(error) {
591
592
  if (error instanceof DOMException && error.name === "AbortError") {
592
593
  return true;
593
594
  }
594
- if (error instanceof chunkAETVRBKI_js.CimplifyError) {
595
+ if (error instanceof chunkNIOUSKQQ_js.CimplifyError) {
595
596
  return error.retryable;
596
597
  }
597
598
  return false;
598
599
  }
599
600
  function toNetworkError(error, isTestMode) {
600
601
  if (error instanceof DOMException && error.name === "AbortError") {
601
- return chunkAETVRBKI_js.enrichError(
602
- new chunkAETVRBKI_js.CimplifyError(
603
- chunkAETVRBKI_js.ErrorCode.TIMEOUT,
602
+ return chunkNIOUSKQQ_js.enrichError(
603
+ new chunkNIOUSKQQ_js.CimplifyError(
604
+ chunkNIOUSKQQ_js.ErrorCode.TIMEOUT,
604
605
  "Request timed out. Please check your connection and try again.",
605
606
  true
606
607
  ),
@@ -608,21 +609,21 @@ function toNetworkError(error, isTestMode) {
608
609
  );
609
610
  }
610
611
  if (error instanceof TypeError && error.message.includes("fetch")) {
611
- return chunkAETVRBKI_js.enrichError(
612
- new chunkAETVRBKI_js.CimplifyError(
613
- chunkAETVRBKI_js.ErrorCode.NETWORK_ERROR,
612
+ return chunkNIOUSKQQ_js.enrichError(
613
+ new chunkNIOUSKQQ_js.CimplifyError(
614
+ chunkNIOUSKQQ_js.ErrorCode.NETWORK_ERROR,
614
615
  "Network error. Please check your internet connection.",
615
616
  true
616
617
  ),
617
618
  { isTestMode }
618
619
  );
619
620
  }
620
- if (error instanceof chunkAETVRBKI_js.CimplifyError) {
621
- return chunkAETVRBKI_js.enrichError(error, { isTestMode });
621
+ if (error instanceof chunkNIOUSKQQ_js.CimplifyError) {
622
+ return chunkNIOUSKQQ_js.enrichError(error, { isTestMode });
622
623
  }
623
- return chunkAETVRBKI_js.enrichError(
624
- new chunkAETVRBKI_js.CimplifyError(
625
- chunkAETVRBKI_js.ErrorCode.UNKNOWN_ERROR,
624
+ return chunkNIOUSKQQ_js.enrichError(
625
+ new chunkNIOUSKQQ_js.CimplifyError(
626
+ chunkNIOUSKQQ_js.ErrorCode.UNKNOWN_ERROR,
626
627
  error instanceof Error ? error.message : "An unknown error occurred",
627
628
  false
628
629
  ),
@@ -726,6 +727,9 @@ var CimplifyClient = class {
726
727
  setAccessToken(token) {
727
728
  const previous = this.accessToken;
728
729
  this.accessToken = token;
730
+ if (previous !== token) {
731
+ this.sessionEpoch++;
732
+ }
729
733
  this.hooks.onSessionChange?.({
730
734
  previousToken: previous,
731
735
  newToken: token,
@@ -752,6 +756,7 @@ var CimplifyClient = class {
752
756
  adoptSessionToken(token) {
753
757
  if (!token || token === this.sessionToken) return;
754
758
  this.sessionToken = token;
759
+ this.sessionEpoch++;
755
760
  this.saveSessionToken(token);
756
761
  }
757
762
  clearSession() {
@@ -808,6 +813,7 @@ var CimplifyClient = class {
808
813
  if (!payload?.token || payload.token === this.sessionToken) return;
809
814
  if (payload.type === "claimed") {
810
815
  this.sessionToken = payload.token;
816
+ this.sessionEpoch++;
811
817
  this.events.emit(SESSION_CLAIMED, {
812
818
  sessionToken: payload.token,
813
819
  threadId: null,
@@ -901,8 +907,8 @@ var CimplifyClient = class {
901
907
  this.businessIdResolvePromise = (async () => {
902
908
  const result = await this.business.getInfo();
903
909
  if (!result.ok || !result.value?.id) {
904
- throw new chunkAETVRBKI_js.CimplifyError(
905
- chunkAETVRBKI_js.ErrorCode.NOT_FOUND,
910
+ throw new chunkNIOUSKQQ_js.CimplifyError(
911
+ chunkNIOUSKQQ_js.ErrorCode.NOT_FOUND,
906
912
  "Unable to resolve business ID from the current public key.",
907
913
  true
908
914
  );
@@ -1042,7 +1048,7 @@ var CimplifyClient = class {
1042
1048
  if (response.status >= 400 && response.status < 500) {
1043
1049
  this.hooks.onRequestError?.({
1044
1050
  ...context,
1045
- error: new chunkAETVRBKI_js.CimplifyError(
1051
+ error: new chunkNIOUSKQQ_js.CimplifyError(
1046
1052
  `HTTP_${response.status}`,
1047
1053
  `Request failed with status ${response.status}`,
1048
1054
  false
@@ -1068,7 +1074,7 @@ var CimplifyClient = class {
1068
1074
  }
1069
1075
  this.hooks.onRequestError?.({
1070
1076
  ...context,
1071
- error: new chunkAETVRBKI_js.CimplifyError(
1077
+ error: new chunkNIOUSKQQ_js.CimplifyError(
1072
1078
  "SERVER_ERROR",
1073
1079
  `Server error ${response.status} after ${retryCount} retries`,
1074
1080
  false
@@ -1220,12 +1226,12 @@ var CimplifyClient = class {
1220
1226
  const retryable = typeof json.error === "object" && typeof json.error?.retryable === "boolean" ? json.error.retryable : false;
1221
1227
  if (errorCode === "IDEMPOTENCY_MISMATCH") {
1222
1228
  const originalCreatedAt = typeof json.error === "object" && json.error?.original_created_at || "";
1223
- throw new chunkAETVRBKI_js.IdempotencyMismatchError(errorMessage, originalCreatedAt);
1229
+ throw new chunkNIOUSKQQ_js.IdempotencyMismatchError(errorMessage, originalCreatedAt);
1224
1230
  }
1225
- const error = chunkAETVRBKI_js.enrichError(new chunkAETVRBKI_js.CimplifyError(errorCode, errorMessage, retryable), {
1231
+ const error = chunkNIOUSKQQ_js.enrichError(new chunkNIOUSKQQ_js.CimplifyError(errorCode, errorMessage, retryable), {
1226
1232
  isTestMode: this.isTestMode()
1227
1233
  });
1228
- if ((response.status === 401 || error.code === chunkAETVRBKI_js.ErrorCode.UNAUTHORIZED) && this.accessToken) {
1234
+ if ((response.status === 401 || error.code === chunkNIOUSKQQ_js.ErrorCode.UNAUTHORIZED) && this.accessToken) {
1229
1235
  console.warn(
1230
1236
  "[Cimplify] Received 401 Unauthorized. Access token may be missing/expired. Refresh authentication and retry the request."
1231
1237
  );
@@ -1233,8 +1239,8 @@ var CimplifyClient = class {
1233
1239
  throw error;
1234
1240
  }
1235
1241
  if (json?.success === false || json?.error?.code || json?.error?.message) {
1236
- const error = chunkAETVRBKI_js.enrichError(
1237
- new chunkAETVRBKI_js.CimplifyError(
1242
+ const error = chunkNIOUSKQQ_js.enrichError(
1243
+ new chunkNIOUSKQQ_js.CimplifyError(
1238
1244
  json.error?.code || "API_ERROR",
1239
1245
  json.error?.message || "An error occurred",
1240
1246
  json.error?.retryable || false
@@ -1250,25 +1256,25 @@ var CimplifyClient = class {
1250
1256
  }
1251
1257
  get catalogue() {
1252
1258
  if (!this._catalogue) {
1253
- this._catalogue = new chunkX6G6QERR_js.CatalogueQueries(this);
1259
+ this._catalogue = new chunk6JEKKL3M_js.CatalogueQueries(this);
1254
1260
  }
1255
1261
  return this._catalogue;
1256
1262
  }
1257
1263
  get cart() {
1258
1264
  if (!this._cart) {
1259
- this._cart = new chunkX6G6QERR_js.CartOperations(this);
1265
+ this._cart = new chunk6JEKKL3M_js.CartOperations(this);
1260
1266
  }
1261
1267
  return this._cart;
1262
1268
  }
1263
1269
  get checkout() {
1264
1270
  if (!this._checkout) {
1265
- this._checkout = new chunkX6G6QERR_js.CheckoutService(this);
1271
+ this._checkout = new chunk6JEKKL3M_js.CheckoutService(this);
1266
1272
  }
1267
1273
  return this._checkout;
1268
1274
  }
1269
1275
  get orders() {
1270
1276
  if (!this._orders) {
1271
- this._orders = new chunkX6G6QERR_js.OrderQueries(this);
1277
+ this._orders = new chunk6JEKKL3M_js.OrderQueries(this);
1272
1278
  }
1273
1279
  return this._orders;
1274
1280
  }
@@ -1298,43 +1304,43 @@ var CimplifyClient = class {
1298
1304
  }
1299
1305
  get link() {
1300
1306
  if (!this._link) {
1301
- this._link = new chunkX6G6QERR_js.LinkService(this);
1307
+ this._link = new chunk6JEKKL3M_js.LinkService(this);
1302
1308
  }
1303
1309
  return this._link;
1304
1310
  }
1305
1311
  get auth() {
1306
1312
  if (!this._auth) {
1307
- this._auth = new chunkX6G6QERR_js.AuthService(this);
1313
+ this._auth = new chunk6JEKKL3M_js.AuthService(this);
1308
1314
  }
1309
1315
  return this._auth;
1310
1316
  }
1311
1317
  get business() {
1312
1318
  if (!this._business) {
1313
- this._business = new chunkX6G6QERR_js.BusinessService(this);
1319
+ this._business = new chunk6JEKKL3M_js.BusinessService(this);
1314
1320
  }
1315
1321
  return this._business;
1316
1322
  }
1317
1323
  get inventory() {
1318
1324
  if (!this._inventory) {
1319
- this._inventory = new chunkX6G6QERR_js.InventoryService(this);
1325
+ this._inventory = new chunk6JEKKL3M_js.InventoryService(this);
1320
1326
  }
1321
1327
  return this._inventory;
1322
1328
  }
1323
1329
  get scheduling() {
1324
1330
  if (!this._scheduling) {
1325
- this._scheduling = new chunkX6G6QERR_js.SchedulingService(this);
1331
+ this._scheduling = new chunk6JEKKL3M_js.SchedulingService(this);
1326
1332
  }
1327
1333
  return this._scheduling;
1328
1334
  }
1329
1335
  get lite() {
1330
1336
  if (!this._lite) {
1331
- this._lite = new chunkX6G6QERR_js.LiteService(this);
1337
+ this._lite = new chunk6JEKKL3M_js.LiteService(this);
1332
1338
  }
1333
1339
  return this._lite;
1334
1340
  }
1335
1341
  get fx() {
1336
1342
  if (!this._fx) {
1337
- this._fx = new chunkX6G6QERR_js.FxService(this);
1343
+ this._fx = new chunk6JEKKL3M_js.FxService(this);
1338
1344
  }
1339
1345
  return this._fx;
1340
1346
  }
@@ -1369,13 +1375,14 @@ var CimplifyClient = class {
1369
1375
  if (businessId) {
1370
1376
  this.setBusinessId(businessId);
1371
1377
  }
1372
- return chunkX6G6QERR_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
1378
+ return chunk6JEKKL3M_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
1373
1379
  }
1374
1380
  };
1375
1381
  function createCimplifyClient(config = {}) {
1376
1382
  return new CimplifyClient(config);
1377
1383
  }
1378
1384
 
1385
+ exports.AUTH_TOKEN_CHANGED = AUTH_TOKEN_CHANGED;
1379
1386
  exports.ActivityService = ActivityService;
1380
1387
  exports.CimplifyClient = CimplifyClient;
1381
1388
  exports.DeliveryService = DeliveryService;
@@ -43,6 +43,7 @@ var SUPPORTED_CURRENCY_CODES = /* @__PURE__ */ new Set([
43
43
  "BIF",
44
44
  "INR",
45
45
  "BRL",
46
+ "COP",
46
47
  "MXN",
47
48
  "KRW",
48
49
  "TRY",
@@ -41,6 +41,7 @@ var SUPPORTED_CURRENCY_CODES = /* @__PURE__ */ new Set([
41
41
  "BIF",
42
42
  "INR",
43
43
  "BRL",
44
+ "COP",
44
45
  "MXN",
45
46
  "KRW",
46
47
  "TRY",
@@ -1,5 +1,5 @@
1
- import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-OX5L6XE7.mjs';
2
- import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-K5EN2W2Q.mjs';
1
+ import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-TIQLOH2B.mjs';
2
+ import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-O3YUHLZL.mjs';
3
3
 
4
4
  // src/store-credit.ts
5
5
  var StoreCreditQueries = class {
@@ -322,18 +322,19 @@ var DeliveryService = class {
322
322
  params.set("dropoff_lat", String(dropoffLat));
323
323
  params.set("dropoff_lng", String(dropoffLng));
324
324
  if (country) params.set("country", country);
325
- return safe(
326
- this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
327
- );
328
- }
329
- /** The full delivery menu for an address. Pass the selected option's
330
- * `rate_id` as `delivery_rate_id` when processing checkout. */
331
- async getOptions(dropoffLat, dropoffLng, opts) {
325
+ return safe(this.client.get(`/api/v1/delivery/fee?${params.toString()}`));
326
+ }
327
+ async getOptions(queryOrLatitude, longitude, legacyOptions) {
328
+ const query = typeof queryOrLatitude === "number" ? {
329
+ ...legacyOptions,
330
+ dropoffLat: queryOrLatitude,
331
+ dropoffLng: longitude
332
+ } : queryOrLatitude ?? {};
332
333
  const params = new URLSearchParams();
333
- params.set("dropoff_lat", String(dropoffLat));
334
- params.set("dropoff_lng", String(dropoffLng));
335
- if (opts?.country) params.set("country", opts.country);
336
- if (opts?.orderValue != null) params.set("order_value", String(opts.orderValue));
334
+ if (query.dropoffLat != null) params.set("dropoff_lat", String(query.dropoffLat));
335
+ if (query.dropoffLng != null) params.set("dropoff_lng", String(query.dropoffLng));
336
+ if (query.country) params.set("country", query.country);
337
+ if (query.orderValue != null) params.set("order_value", String(query.orderValue));
337
338
  return safe(
338
339
  this.client.get(`/api/v1/delivery/options?${params.toString()}`)
339
340
  );
@@ -724,6 +725,9 @@ var CimplifyClient = class {
724
725
  setAccessToken(token) {
725
726
  const previous = this.accessToken;
726
727
  this.accessToken = token;
728
+ if (previous !== token) {
729
+ this.sessionEpoch++;
730
+ }
727
731
  this.hooks.onSessionChange?.({
728
732
  previousToken: previous,
729
733
  newToken: token,
@@ -750,6 +754,7 @@ var CimplifyClient = class {
750
754
  adoptSessionToken(token) {
751
755
  if (!token || token === this.sessionToken) return;
752
756
  this.sessionToken = token;
757
+ this.sessionEpoch++;
753
758
  this.saveSessionToken(token);
754
759
  }
755
760
  clearSession() {
@@ -806,6 +811,7 @@ var CimplifyClient = class {
806
811
  if (!payload?.token || payload.token === this.sessionToken) return;
807
812
  if (payload.type === "claimed") {
808
813
  this.sessionToken = payload.token;
814
+ this.sessionEpoch++;
809
815
  this.events.emit(SESSION_CLAIMED, {
810
816
  sessionToken: payload.token,
811
817
  threadId: null,
@@ -1374,4 +1380,4 @@ function createCimplifyClient(config = {}) {
1374
1380
  return new CimplifyClient(config);
1375
1381
  }
1376
1382
 
1377
- export { ActivityService, CimplifyClient, DeliveryService, MUTATION_ERROR, PlacesService, SESSION_CLAIMED, SESSION_CLEARED, StoreCreditQueries, SubscriptionService, SupportService, UploadService, createCimplifyClient };
1383
+ export { AUTH_TOKEN_CHANGED, ActivityService, CimplifyClient, DeliveryService, MUTATION_ERROR, PlacesService, SESSION_CLAIMED, SESSION_CLEARED, StoreCreditQueries, SubscriptionService, SupportService, UploadService, createCimplifyClient };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkFECGCIVV_js = require('./chunk-FECGCIVV.js');
4
- var chunkJ3UYIBKH_js = require('./chunk-J3UYIBKH.js');
3
+ var chunkIFAQLFAJ_js = require('./chunk-IFAQLFAJ.js');
4
+ var chunkIJI7KMTG_js = require('./chunk-IJI7KMTG.js');
5
5
  var zod = require('zod');
6
6
 
7
7
  var cimplifyRegistry = zod.z.registry();
@@ -600,7 +600,7 @@ async function toForwardedRequest(input, init) {
600
600
  };
601
601
  }
602
602
  function createTestClient(options = {}) {
603
- const mock = chunkFECGCIVV_js.createMockApp(options);
603
+ const mock = chunkIFAQLFAJ_js.createMockApp(options);
604
604
  let sessionToken;
605
605
  const fetchImpl = async (input, init) => {
606
606
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
@@ -619,7 +619,7 @@ function createTestClient(options = {}) {
619
619
  if (echoed) sessionToken = echoed;
620
620
  return res;
621
621
  };
622
- const client = chunkJ3UYIBKH_js.createCimplifyClient({
622
+ const client = chunkIJI7KMTG_js.createCimplifyClient({
623
623
  baseUrl: TEST_BASE_URL,
624
624
  // Link mock lives at /v1/link on the same Hono app, so point the SDK's
625
625
  // separate Link transport at the same TEST_BASE_URL.