@cimplify/sdk 0.99.2 → 0.100.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.
Files changed (62) 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-R7FAU2ZF.js → chunk-BHQCSHIG.js} +78 -72
  6. package/dist/{chunk-KFLGQGMC.mjs → chunk-DLW3RWRK.mjs} +35 -15
  7. package/dist/{chunk-QYBGG3ZJ.mjs → chunk-KEC2CX4R.mjs} +2 -2
  8. package/dist/{chunk-FECGCIVV.js → chunk-NH3HYUC3.js} +3 -3
  9. package/dist/{chunk-AETVRBKI.js → chunk-NIOUSKQQ.js} +1 -0
  10. package/dist/{chunk-7TEMLVDT.mjs → chunk-NKZIXLKW.mjs} +1 -1
  11. package/dist/{chunk-J64F56EB.js → chunk-NR4Z2SFY.js} +4 -4
  12. package/dist/{chunk-K5EN2W2Q.mjs → chunk-O3YUHLZL.mjs} +1 -0
  13. package/dist/{chunk-ZFI2TKTO.mjs → chunk-PTKAN4SI.mjs} +25 -15
  14. package/dist/{chunk-4S5EMSF5.js → chunk-QGFKIAEM.js} +48 -38
  15. package/dist/{chunk-DOEGVGTM.mjs → chunk-T2B656RS.mjs} +8 -3
  16. package/dist/{chunk-PTPOQVXS.js → chunk-WMEC5JWN.js} +37 -16
  17. package/dist/{client-CX59ew7C.d.ts → client-B0Lku_lc.d.mts} +17 -16
  18. package/dist/{client-CCCOOaI3.d.ts → client-DRgEa78P.d.ts} +2 -2
  19. package/dist/{client-BNfVL2IL.d.mts → client-DxgC_lXU.d.ts} +17 -16
  20. package/dist/{client-BeMhSkRT.d.mts → client-T5c-Nxq-.d.mts} +2 -2
  21. package/dist/{index-D-w5h82t.d.ts → index-CzKN1hjf.d.ts} +3 -3
  22. package/dist/{index-BuNjyfaV.d.mts → index-DzuLT5wi.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/{payment-pKPpaORI.d.mts → payment-D8NEwCna.d.mts} +2 -2
  28. package/dist/{payment-By0JidTe.d.ts → payment-lZBP7h5M.d.ts} +2 -2
  29. package/dist/{price-BvRtp6ak.d.mts → price-DepWAmcL.d.mts} +1 -1
  30. package/dist/{price-23RNXftz.d.ts → price-ncQb-TC8.d.ts} +1 -1
  31. package/dist/{product-O8-wcHSe.d.ts → product-B384_Qm2.d.mts} +38 -49
  32. package/dist/{product-O8-wcHSe.d.mts → product-B384_Qm2.d.ts} +38 -49
  33. package/dist/react.d.mts +10 -5
  34. package/dist/react.d.ts +10 -5
  35. package/dist/react.js +830 -446
  36. package/dist/react.mjs +711 -327
  37. package/dist/{server-JBuTPY-j.d.ts → server-B7O4ttpv.d.ts} +1 -1
  38. package/dist/{server-HVDbbqR9.d.mts → server-oCGNIO_K.d.mts} +1 -1
  39. package/dist/server.d.mts +4 -4
  40. package/dist/server.d.ts +4 -4
  41. package/dist/server.js +10 -10
  42. package/dist/server.mjs +4 -4
  43. package/dist/testing/msw.d.mts +2 -2
  44. package/dist/testing/msw.d.ts +2 -2
  45. package/dist/testing/msw.js +3 -3
  46. package/dist/testing/msw.mjs +2 -2
  47. package/dist/testing/suite.d.mts +6 -6
  48. package/dist/testing/suite.d.ts +6 -6
  49. package/dist/testing/suite.js +25 -25
  50. package/dist/testing/suite.mjs +6 -6
  51. package/dist/testing.d.mts +5 -5
  52. package/dist/testing.d.ts +5 -5
  53. package/dist/testing.js +81 -81
  54. package/dist/testing.mjs +7 -7
  55. package/dist/utils.d.mts +4 -4
  56. package/dist/utils.d.ts +4 -4
  57. package/dist/utils.js +29 -29
  58. package/dist/utils.mjs +2 -2
  59. package/package.json +1 -1
  60. package/registry/cart-summary.json +1 -1
  61. package/registry/product-customizer.json +1 -1
  62. package/registry/sale-badge.json +1 -1
@@ -1,4 +1,4 @@
1
- import { moneyFromNumber, money } from './chunk-K5EN2W2Q.mjs';
1
+ import { moneyFromNumber, money } from './chunk-O3YUHLZL.mjs';
2
2
 
3
3
  // src/utils/price.ts
4
4
  var CURRENCY_SYMBOLS = {
@@ -15,6 +15,7 @@ var CURRENCY_SYMBOLS = {
15
15
  SGD: "S$",
16
16
  INR: "\u20B9",
17
17
  BRL: "R$",
18
+ COP: "COL$",
18
19
  MXN: "MX$",
19
20
  KRW: "\u20A9",
20
21
  RUB: "\u20BD",
@@ -143,6 +144,20 @@ function parsePrice(value) {
143
144
  const parsed = parseFloat(cleaned);
144
145
  return isNaN(parsed) ? 0 : parsed;
145
146
  }
147
+ function getVariantUnitPrice(product, variant) {
148
+ if (variant?.price_info) {
149
+ return parsePrice(variant.price_info.final_price);
150
+ }
151
+ const defaultPrice = parsePrice(product.default_price);
152
+ if (!variant) {
153
+ return defaultPrice;
154
+ }
155
+ const defaultVariant = product.variants?.find((candidate) => candidate.is_default);
156
+ if (!defaultVariant) {
157
+ return variant.is_default ? defaultPrice : defaultPrice + parsePrice(variant.price_adjustment);
158
+ }
159
+ return defaultPrice - parsePrice(defaultVariant.price_adjustment) + parsePrice(variant.price_adjustment);
160
+ }
146
161
  function hasTaxInfo(priceInfo) {
147
162
  return priceInfo.tax_info !== void 0 && priceInfo.tax_info !== null;
148
163
  }
@@ -163,6 +178,9 @@ function formatPriceWithTax(priceInfo, currency = "GHS") {
163
178
  return `${finalPrice} + ${formatPrice(getTaxAmount(priceInfo), currency)} tax`;
164
179
  }
165
180
  function getDisplayPrice(product) {
181
+ if (product.sale) {
182
+ return parsePrice(product.sale.price);
183
+ }
166
184
  if (product.price_info) {
167
185
  return parsePrice(product.price_info.final_price);
168
186
  }
@@ -175,6 +193,9 @@ function getDisplayPrice(product) {
175
193
  return 0;
176
194
  }
177
195
  function getBasePrice(product) {
196
+ if (product.sale) {
197
+ return parsePrice(product.sale.original);
198
+ }
178
199
  if (product.price_info) {
179
200
  return parsePrice(product.price_info.base_price);
180
201
  }
@@ -187,11 +208,17 @@ function getBasePrice(product) {
187
208
  return 0;
188
209
  }
189
210
  function isOnSale(product) {
211
+ if (product.sale) {
212
+ return true;
213
+ }
190
214
  const basePrice = getBasePrice(product);
191
215
  const finalPrice = getDisplayPrice(product);
192
216
  return basePrice > finalPrice && basePrice > 0;
193
217
  }
194
218
  function getDiscountPercentage(product) {
219
+ if (product.sale) {
220
+ return parsePrice(product.sale.percent_off);
221
+ }
195
222
  const basePrice = getBasePrice(product);
196
223
  const finalPrice = getDisplayPrice(product);
197
224
  if (basePrice > finalPrice && basePrice > 0) {
@@ -241,10 +268,7 @@ function getPriceRange(product) {
241
268
  }
242
269
  const variants = product.variants;
243
270
  if (variants && variants.length > 1) {
244
- const base = parsePrice(product.default_price);
245
- const prices = variants.map(
246
- (v) => base + parsePrice(v.price_adjustment ?? 0)
247
- );
271
+ const prices = variants.map((variant) => getVariantUnitPrice(product, variant));
248
272
  return { min: Math.min(...prices), max: Math.max(...prices) };
249
273
  }
250
274
  return null;
@@ -354,7 +378,8 @@ var PAYMENT_SUCCESS_STATUSES = /* @__PURE__ */ new Set([
354
378
  "paid",
355
379
  "captured",
356
380
  "completed",
357
- "authorized"
381
+ "authorized",
382
+ "not_required"
358
383
  ]);
359
384
  var PAYMENT_FAILURE_STATUSES = /* @__PURE__ */ new Set([
360
385
  "failed",
@@ -379,6 +404,7 @@ var PAYMENT_STATUS_ALIAS_MAP = {
379
404
  success: "captured",
380
405
  captured: "captured",
381
406
  completed: "captured",
407
+ not_required: "not_required",
382
408
  pending_confirmation: "pending",
383
409
  requires_authorization: "requires_action",
384
410
  requires_action: "requires_action",
@@ -400,6 +426,7 @@ var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
400
426
  "processing",
401
427
  "authorized",
402
428
  "captured",
429
+ "not_required",
403
430
  "failed",
404
431
  "cancelled",
405
432
  "refunded",
@@ -448,14 +475,7 @@ function normalizeStatusResponse(response) {
448
475
  const normalizedAmount = typeof res.amount === "string" ? money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? moneyFromNumber(res.amount) : moneyFromNumber(0);
449
476
  const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ? res.currency : "";
450
477
  const paidValue = res.paid === true;
451
- const derivedPaid = paidValue || [
452
- "success",
453
- "succeeded",
454
- "paid",
455
- "captured",
456
- "authorized",
457
- "completed"
458
- ].includes(normalizedStatus);
478
+ const derivedPaid = paidValue || PAYMENT_SUCCESS_STATUSES.has(normalizedStatus);
459
479
  return {
460
480
  status: normalizedStatus,
461
481
  paid: derivedPaid,
@@ -481,4 +501,4 @@ function detectMobileMoneyProvider(phoneNumber) {
481
501
  return null;
482
502
  }
483
503
 
484
- export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceRange, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getPriceRange, getProductCurrency, getTaxAmount, getUnitPriceAtQuantity, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, normalizePaymentResponse, normalizeStatusResponse, parsePrice };
504
+ export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceRange, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getPriceRange, getProductCurrency, getTaxAmount, getUnitPriceAtQuantity, getVariantUnitPrice, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, normalizePaymentResponse, normalizeStatusResponse, parsePrice };
@@ -1,5 +1,5 @@
1
- import { createMockApp } from './chunk-7TEMLVDT.mjs';
2
- import { createCimplifyClient } from './chunk-DOEGVGTM.mjs';
1
+ import { createMockApp } from './chunk-NKZIXLKW.mjs';
2
+ import { createCimplifyClient } from './chunk-T2B656RS.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  var cimplifyRegistry = z.registry();
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkXREIZ56K_js = require('./chunk-XREIZ56K.js');
4
- var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
4
+ var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
5
5
  var chunkOWW5GUSB_js = require('./chunk-OWW5GUSB.js');
6
6
 
7
7
  // ../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/compose.js
@@ -2077,8 +2077,8 @@ var MockError = class extends Error {
2077
2077
  };
2078
2078
  }
2079
2079
  };
2080
- var notFound = (msg) => new MockError(chunkAETVRBKI_js.ErrorCode.NOT_FOUND, msg, 404);
2081
- var validation = (msg, ctx) => new MockError(chunkAETVRBKI_js.ErrorCode.VALIDATION_ERROR, msg, 400, ctx);
2080
+ var notFound = (msg) => new MockError(chunkNIOUSKQQ_js.ErrorCode.NOT_FOUND, msg, 404);
2081
+ var validation = (msg, ctx) => new MockError(chunkNIOUSKQQ_js.ErrorCode.VALIDATION_ERROR, msg, 400, ctx);
2082
2082
 
2083
2083
  // src/mock/routes/_helpers.ts
2084
2084
  function authMiddleware(deps) {
@@ -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",
@@ -1,5 +1,5 @@
1
1
  import { messagePreview } from './chunk-U4MW6PYU.mjs';
2
- import { ErrorCode } from './chunk-K5EN2W2Q.mjs';
2
+ import { ErrorCode } from './chunk-O3YUHLZL.mjs';
3
3
  import { __publicField, __privateAdd, __privateSet, __privateGet, __privateMethod, __privateWrapper } from './chunk-3G6RQLXK.mjs';
4
4
 
5
5
  // ../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/compose.js
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkFECGCIVV_js = require('./chunk-FECGCIVV.js');
4
- var chunkR7FAU2ZF_js = require('./chunk-R7FAU2ZF.js');
3
+ var chunkNH3HYUC3_js = require('./chunk-NH3HYUC3.js');
4
+ var chunkBHQCSHIG_js = require('./chunk-BHQCSHIG.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 = chunkNH3HYUC3_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 = chunkR7FAU2ZF_js.createCimplifyClient({
622
+ const client = chunkBHQCSHIG_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.
@@ -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 { isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure } from './chunk-KFLGQGMC.mjs';
2
- import { CimplifyError, ErrorCode, currencyCode, enrichError, getErrorHint } from './chunk-K5EN2W2Q.mjs';
1
+ import { isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure } from './chunk-DLW3RWRK.mjs';
2
+ import { CimplifyError, ErrorCode, currencyCode, enrichError, getErrorHint } from './chunk-O3YUHLZL.mjs';
3
3
 
4
4
  // src/types/result.ts
5
5
  function ok(value) {
@@ -284,7 +284,9 @@ var CatalogueQueries = class {
284
284
  this.client = client;
285
285
  }
286
286
  async getCatalogue(opts) {
287
- const result = await safe(this.client.get("/api/v1/catalogue", opts));
287
+ const result = await safe(
288
+ this.client.get("/api/v1/catalogue", opts)
289
+ );
288
290
  if (!result.ok) return result;
289
291
  return ok(normalizeCatalogueSnapshot(result.value));
290
292
  }
@@ -312,7 +314,9 @@ var CatalogueQueries = class {
312
314
  }
313
315
  async getProduct(id, opts) {
314
316
  const encodedId = encodeURIComponent(id);
315
- const result = await safe(this.client.get(`/api/v1/catalogue/products/${encodedId}`, opts));
317
+ const result = await safe(
318
+ this.client.get(`/api/v1/catalogue/products/${encodedId}`, opts)
319
+ );
316
320
  if (!result.ok) return result;
317
321
  const payload = result.value;
318
322
  const rawProduct = isRecord(payload.item) ? payload.item : payload;
@@ -334,11 +338,15 @@ var CatalogueQueries = class {
334
338
  }
335
339
  async getVariants(productId) {
336
340
  const encodedId = encodeURIComponent(productId);
337
- return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/variants`));
341
+ return safe(
342
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/variants`)
343
+ );
338
344
  }
339
345
  async getVariantAxes(productId) {
340
346
  const encodedId = encodeURIComponent(productId);
341
- return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/variant-axes`));
347
+ return safe(
348
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/variant-axes`)
349
+ );
342
350
  }
343
351
  async getVariantByAxisSelections(productId, selections) {
344
352
  const encodedId = encodeURIComponent(productId);
@@ -469,7 +477,9 @@ var CatalogueQueries = class {
469
477
  }
470
478
  async getTaxonomyPath(id) {
471
479
  const encodedId = encodeURIComponent(id);
472
- return safe(this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}/path`));
480
+ return safe(
481
+ this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}/path`)
482
+ );
473
483
  }
474
484
  async searchTaxonomies(query, limit) {
475
485
  const path = withQuery("/api/v1/catalogue/taxonomies/search", { q: query, limit });
@@ -486,11 +496,15 @@ var CatalogueQueries = class {
486
496
  }
487
497
  async getProductSchedules(productId) {
488
498
  const encodedId = encodeURIComponent(productId);
489
- return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/schedules`));
499
+ return safe(
500
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/schedules`)
501
+ );
490
502
  }
491
503
  async checkProductAvailableNow(productId, locationId) {
492
504
  const encodedId = encodeURIComponent(productId);
493
- const path = withQuery(`/api/v1/catalogue/products/${encodedId}/available-now`, { location_id: locationId });
505
+ const path = withQuery(`/api/v1/catalogue/products/${encodedId}/available-now`, {
506
+ location_id: locationId
507
+ });
494
508
  return safe(this.client.get(path));
495
509
  }
496
510
  async getDeals(locationId) {
@@ -570,9 +584,7 @@ var CatalogueQueries = class {
570
584
  async getProductAttributes(productId) {
571
585
  const encodedId = encodeURIComponent(productId);
572
586
  return safe(
573
- this.client.get(
574
- `/api/v1/catalogue/products/${encodedId}/attributes`
575
- )
587
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/attributes`)
576
588
  );
577
589
  }
578
590
  async getCategoryAttributes(categoryId) {
@@ -614,9 +626,7 @@ var CatalogueQueries = class {
614
626
  return safe(this.client.get(path));
615
627
  }
616
628
  async getKnowledgeArticles() {
617
- return safe(
618
- this.client.get("/api/v1/catalogue/knowledge-base/articles")
619
- );
629
+ return safe(this.client.get("/api/v1/catalogue/knowledge-base/articles"));
620
630
  }
621
631
  };
622
632
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkPTPOQVXS_js = require('./chunk-PTPOQVXS.js');
4
- var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
3
+ var chunkWMEC5JWN_js = require('./chunk-WMEC5JWN.js');
4
+ var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
5
5
 
6
6
  // src/types/result.ts
7
7
  function ok(value) {
@@ -116,11 +116,11 @@ function clearIntentIdempotencyKey(scope, storage = sessionStorageOrNull()) {
116
116
 
117
117
  // src/internal/safe.ts
118
118
  function toCimplifyError(error) {
119
- if (error instanceof chunkAETVRBKI_js.CimplifyError) return chunkAETVRBKI_js.enrichError(error);
119
+ if (error instanceof chunkNIOUSKQQ_js.CimplifyError) return chunkNIOUSKQQ_js.enrichError(error);
120
120
  if (error instanceof Error) {
121
- return chunkAETVRBKI_js.enrichError(new chunkAETVRBKI_js.CimplifyError(chunkAETVRBKI_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
121
+ return chunkNIOUSKQQ_js.enrichError(new chunkNIOUSKQQ_js.CimplifyError(chunkNIOUSKQQ_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
122
122
  }
123
- return chunkAETVRBKI_js.enrichError(new chunkAETVRBKI_js.CimplifyError(chunkAETVRBKI_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
123
+ return chunkNIOUSKQQ_js.enrichError(new chunkNIOUSKQQ_js.CimplifyError(chunkNIOUSKQQ_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
124
124
  }
125
125
  async function safe(promise) {
126
126
  try {
@@ -286,7 +286,9 @@ var CatalogueQueries = class {
286
286
  this.client = client;
287
287
  }
288
288
  async getCatalogue(opts) {
289
- const result = await safe(this.client.get("/api/v1/catalogue", opts));
289
+ const result = await safe(
290
+ this.client.get("/api/v1/catalogue", opts)
291
+ );
290
292
  if (!result.ok) return result;
291
293
  return ok(normalizeCatalogueSnapshot(result.value));
292
294
  }
@@ -314,7 +316,9 @@ var CatalogueQueries = class {
314
316
  }
315
317
  async getProduct(id, opts) {
316
318
  const encodedId = encodeURIComponent(id);
317
- const result = await safe(this.client.get(`/api/v1/catalogue/products/${encodedId}`, opts));
319
+ const result = await safe(
320
+ this.client.get(`/api/v1/catalogue/products/${encodedId}`, opts)
321
+ );
318
322
  if (!result.ok) return result;
319
323
  const payload = result.value;
320
324
  const rawProduct = isRecord(payload.item) ? payload.item : payload;
@@ -336,11 +340,15 @@ var CatalogueQueries = class {
336
340
  }
337
341
  async getVariants(productId) {
338
342
  const encodedId = encodeURIComponent(productId);
339
- return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/variants`));
343
+ return safe(
344
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/variants`)
345
+ );
340
346
  }
341
347
  async getVariantAxes(productId) {
342
348
  const encodedId = encodeURIComponent(productId);
343
- return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/variant-axes`));
349
+ return safe(
350
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/variant-axes`)
351
+ );
344
352
  }
345
353
  async getVariantByAxisSelections(productId, selections) {
346
354
  const encodedId = encodeURIComponent(productId);
@@ -471,7 +479,9 @@ var CatalogueQueries = class {
471
479
  }
472
480
  async getTaxonomyPath(id) {
473
481
  const encodedId = encodeURIComponent(id);
474
- return safe(this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}/path`));
482
+ return safe(
483
+ this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}/path`)
484
+ );
475
485
  }
476
486
  async searchTaxonomies(query, limit) {
477
487
  const path = withQuery("/api/v1/catalogue/taxonomies/search", { q: query, limit });
@@ -488,11 +498,15 @@ var CatalogueQueries = class {
488
498
  }
489
499
  async getProductSchedules(productId) {
490
500
  const encodedId = encodeURIComponent(productId);
491
- return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/schedules`));
501
+ return safe(
502
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/schedules`)
503
+ );
492
504
  }
493
505
  async checkProductAvailableNow(productId, locationId) {
494
506
  const encodedId = encodeURIComponent(productId);
495
- const path = withQuery(`/api/v1/catalogue/products/${encodedId}/available-now`, { location_id: locationId });
507
+ const path = withQuery(`/api/v1/catalogue/products/${encodedId}/available-now`, {
508
+ location_id: locationId
509
+ });
496
510
  return safe(this.client.get(path));
497
511
  }
498
512
  async getDeals(locationId) {
@@ -572,9 +586,7 @@ var CatalogueQueries = class {
572
586
  async getProductAttributes(productId) {
573
587
  const encodedId = encodeURIComponent(productId);
574
588
  return safe(
575
- this.client.get(
576
- `/api/v1/catalogue/products/${encodedId}/attributes`
577
- )
589
+ this.client.get(`/api/v1/catalogue/products/${encodedId}/attributes`)
578
590
  );
579
591
  }
580
592
  async getCategoryAttributes(categoryId) {
@@ -616,9 +628,7 @@ var CatalogueQueries = class {
616
628
  return safe(this.client.get(path));
617
629
  }
618
630
  async getKnowledgeArticles() {
619
- return safe(
620
- this.client.get("/api/v1/catalogue/knowledge-base/articles")
621
- );
631
+ return safe(this.client.get("/api/v1/catalogue/knowledge-base/articles"));
622
632
  }
623
633
  };
624
634
 
@@ -682,7 +692,7 @@ var CartOperations = class {
682
692
  if (typeof updates.quantity !== "number") {
683
693
  return {
684
694
  ok: false,
685
- error: new chunkAETVRBKI_js.CimplifyError(
695
+ error: new chunkNIOUSKQQ_js.CimplifyError(
686
696
  "VALIDATION_ERROR",
687
697
  "updateItem requires a quantity; richer mid-cart edits are not supported"
688
698
  )
@@ -1128,7 +1138,7 @@ var CheckoutResolver = class {
1128
1138
  }
1129
1139
  }
1130
1140
  }
1131
- if (checkoutResult.requires_authorization || chunkPTPOQVXS_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
1141
+ if (checkoutResult.requires_authorization || chunkWMEC5JWN_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
1132
1142
  const authorization = await this.handleAuthorization({
1133
1143
  authorizationType,
1134
1144
  paymentReference,
@@ -1302,18 +1312,18 @@ var CheckoutResolver = class {
1302
1312
  if (statusResult.value.reference) {
1303
1313
  paymentReference = statusResult.value.reference;
1304
1314
  }
1305
- const normalized = chunkPTPOQVXS_js.normalizeStatusResponse(statusResult.value);
1306
- if (normalized.paid || chunkPTPOQVXS_js.isPaymentStatusSuccess(normalized.status)) {
1315
+ const normalized = chunkWMEC5JWN_js.normalizeStatusResponse(statusResult.value);
1316
+ if (normalized.paid || chunkWMEC5JWN_js.isPaymentStatusSuccess(normalized.status)) {
1307
1317
  return this.finalizeSuccess(latestCheckoutResult);
1308
1318
  }
1309
- if (chunkPTPOQVXS_js.isPaymentStatusFailure(normalized.status)) {
1319
+ if (chunkWMEC5JWN_js.isPaymentStatusFailure(normalized.status)) {
1310
1320
  return this.fail(
1311
1321
  normalized.status ? normalized.status.toUpperCase() : "PAYMENT_FAILED",
1312
1322
  normalized.message || "Payment failed during confirmation.",
1313
1323
  false
1314
1324
  );
1315
1325
  }
1316
- if (chunkPTPOQVXS_js.isPaymentStatusRequiresAction(normalized.status)) {
1326
+ if (chunkWMEC5JWN_js.isPaymentStatusRequiresAction(normalized.status)) {
1317
1327
  const authorization = await this.handleAuthorization({
1318
1328
  authorizationType,
1319
1329
  paymentReference,
@@ -1344,8 +1354,8 @@ var CheckoutResolver = class {
1344
1354
  try {
1345
1355
  const finalResult = await this.client.checkout.pollPaymentStatus(input.orderId);
1346
1356
  if (finalResult.ok) {
1347
- const normalized = chunkPTPOQVXS_js.normalizeStatusResponse(finalResult.value);
1348
- if (normalized.paid || chunkPTPOQVXS_js.isPaymentStatusSuccess(normalized.status)) {
1357
+ const normalized = chunkWMEC5JWN_js.normalizeStatusResponse(finalResult.value);
1358
+ if (normalized.paid || chunkWMEC5JWN_js.isPaymentStatusSuccess(normalized.status)) {
1349
1359
  return this.finalizeSuccess(latestCheckoutResult);
1350
1360
  }
1351
1361
  }
@@ -1541,12 +1551,12 @@ var CheckoutResolver = class {
1541
1551
  };
1542
1552
  }
1543
1553
  isSuccessfulStatus(status) {
1544
- const normalized = chunkPTPOQVXS_js.normalizeStatusResponse({ status, paid: false });
1545
- return normalized.paid || chunkPTPOQVXS_js.isPaymentStatusSuccess(normalized.status);
1554
+ const normalized = chunkWMEC5JWN_js.normalizeStatusResponse({ status, paid: false });
1555
+ return normalized.paid || chunkWMEC5JWN_js.isPaymentStatusSuccess(normalized.status);
1546
1556
  }
1547
1557
  isFailureStatus(status) {
1548
- const normalized = chunkPTPOQVXS_js.normalizeStatusResponse({ status, paid: false });
1549
- return chunkPTPOQVXS_js.isPaymentStatusFailure(normalized.status);
1558
+ const normalized = chunkWMEC5JWN_js.normalizeStatusResponse({ status, paid: false });
1559
+ return chunkWMEC5JWN_js.isPaymentStatusFailure(normalized.status);
1550
1560
  }
1551
1561
  ensureNotAborted() {
1552
1562
  if (this.signal?.aborted) {
@@ -1597,14 +1607,14 @@ var CheckoutService = class {
1597
1607
  }
1598
1608
  validateCheckoutData(data) {
1599
1609
  if (isOfflinePaymentMethod(data.payment_method)) {
1600
- return new chunkAETVRBKI_js.CimplifyError(
1610
+ return new chunkNIOUSKQQ_js.CimplifyError(
1601
1611
  "INVALID_PAYMENT_METHOD",
1602
1612
  "Offline payment isn't available for online checkout. Please pay by card or mobile money.",
1603
1613
  false
1604
1614
  );
1605
1615
  }
1606
1616
  if (!isValidCustomerName(data.customer?.name)) {
1607
- return new chunkAETVRBKI_js.CimplifyError(
1617
+ return new chunkNIOUSKQQ_js.CimplifyError(
1608
1618
  "INVALID_CUSTOMER_NAME",
1609
1619
  "Enter your name, not a phone number.",
1610
1620
  false
@@ -1639,14 +1649,14 @@ var CheckoutService = class {
1639
1649
  if (result.value.bill_token) {
1640
1650
  this.client.setOrderToken(result.value.order_id, result.value.bill_token);
1641
1651
  }
1642
- } else if (result.error.code !== chunkAETVRBKI_js.ErrorCode.NETWORK_ERROR && result.error.code !== chunkAETVRBKI_js.ErrorCode.TIMEOUT) {
1652
+ } else if (result.error.code !== chunkNIOUSKQQ_js.ErrorCode.NETWORK_ERROR && result.error.code !== chunkNIOUSKQQ_js.ErrorCode.TIMEOUT) {
1643
1653
  clearIntentIdempotencyKey(intentScope);
1644
1654
  }
1645
1655
  return result;
1646
1656
  }
1647
1657
  async initializePayment(_orderId, _method) {
1648
1658
  return err(
1649
- new chunkAETVRBKI_js.CimplifyError(
1659
+ new chunkNIOUSKQQ_js.CimplifyError(
1650
1660
  "NOT_IMPLEMENTED",
1651
1661
  "initializePayment is not available in REST mode.",
1652
1662
  false
@@ -1722,11 +1732,11 @@ var CheckoutService = class {
1722
1732
  voucher_code: data.voucher_code,
1723
1733
  pay_deposit: data.pay_deposit
1724
1734
  };
1725
- const baseCurrency = chunkAETVRBKI_js.currencyCode(
1735
+ const baseCurrency = chunkNIOUSKQQ_js.currencyCode(
1726
1736
  (cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
1727
1737
  );
1728
1738
  const payCurrency = data.pay_currency?.trim().toUpperCase();
1729
- const payCurrencyCode = payCurrency ? chunkAETVRBKI_js.currencyCode(payCurrency) : void 0;
1739
+ const payCurrencyCode = payCurrency ? chunkNIOUSKQQ_js.currencyCode(payCurrency) : void 0;
1730
1740
  const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
1731
1741
  if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
1732
1742
  const fxQuoteResult = await this.client.fx.lockQuote({
@@ -2088,7 +2098,7 @@ var BusinessService = class {
2088
2098
  if (!result.ok) return err(result.error);
2089
2099
  const location = result.value.find((item) => item.id === locationId);
2090
2100
  if (!location) {
2091
- return err(new chunkAETVRBKI_js.CimplifyError(chunkAETVRBKI_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
2101
+ return err(new chunkNIOUSKQQ_js.CimplifyError(chunkNIOUSKQQ_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
2092
2102
  }
2093
2103
  return ok(location);
2094
2104
  }
@@ -2707,7 +2717,7 @@ function startRedirectSignIn(opts, authorizeEndpoint, pkce, state) {
2707
2717
 
2708
2718
  // src/elements.ts
2709
2719
  function toCheckoutError(code, message, recoverable) {
2710
- const hint = chunkAETVRBKI_js.getErrorHint(code);
2720
+ const hint = chunkNIOUSKQQ_js.getErrorHint(code);
2711
2721
  return {
2712
2722
  success: false,
2713
2723
  error: {
@@ -1,5 +1,5 @@
1
- import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-ZFI2TKTO.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-PTKAN4SI.mjs';
2
+ import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-O3YUHLZL.mjs';
3
3
 
4
4
  // src/store-credit.ts
5
5
  var StoreCreditQueries = class {
@@ -724,6 +724,9 @@ var CimplifyClient = class {
724
724
  setAccessToken(token) {
725
725
  const previous = this.accessToken;
726
726
  this.accessToken = token;
727
+ if (previous !== token) {
728
+ this.sessionEpoch++;
729
+ }
727
730
  this.hooks.onSessionChange?.({
728
731
  previousToken: previous,
729
732
  newToken: token,
@@ -750,6 +753,7 @@ var CimplifyClient = class {
750
753
  adoptSessionToken(token) {
751
754
  if (!token || token === this.sessionToken) return;
752
755
  this.sessionToken = token;
756
+ this.sessionEpoch++;
753
757
  this.saveSessionToken(token);
754
758
  }
755
759
  clearSession() {
@@ -806,6 +810,7 @@ var CimplifyClient = class {
806
810
  if (!payload?.token || payload.token === this.sessionToken) return;
807
811
  if (payload.type === "claimed") {
808
812
  this.sessionToken = payload.token;
813
+ this.sessionEpoch++;
809
814
  this.events.emit(SESSION_CLAIMED, {
810
815
  sessionToken: payload.token,
811
816
  threadId: null,
@@ -1374,4 +1379,4 @@ function createCimplifyClient(config = {}) {
1374
1379
  return new CimplifyClient(config);
1375
1380
  }
1376
1381
 
1377
- export { ActivityService, CimplifyClient, DeliveryService, MUTATION_ERROR, PlacesService, SESSION_CLAIMED, SESSION_CLEARED, StoreCreditQueries, SubscriptionService, SupportService, UploadService, createCimplifyClient };
1382
+ export { AUTH_TOKEN_CHANGED, ActivityService, CimplifyClient, DeliveryService, MUTATION_ERROR, PlacesService, SESSION_CLAIMED, SESSION_CLEARED, StoreCreditQueries, SubscriptionService, SupportService, UploadService, createCimplifyClient };