@cimplify/sdk 0.3.4 → 0.3.6

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.mjs CHANGED
@@ -153,9 +153,6 @@ var CatalogueQueries = class {
153
153
  constructor(client) {
154
154
  this.client = client;
155
155
  }
156
- // --------------------------------------------------------------------------
157
- // PRODUCTS
158
- // --------------------------------------------------------------------------
159
156
  async getProducts(options) {
160
157
  let query2 = "products";
161
158
  const filters = [];
@@ -204,9 +201,6 @@ var CatalogueQueries = class {
204
201
  }
205
202
  return ok(result.value[0]);
206
203
  }
207
- // --------------------------------------------------------------------------
208
- // VARIANTS
209
- // --------------------------------------------------------------------------
210
204
  async getVariants(productId) {
211
205
  return safe(this.client.query(`products.${productId}.variants`));
212
206
  }
@@ -230,15 +224,9 @@ var CatalogueQueries = class {
230
224
  async getVariantById(productId, variantId) {
231
225
  return safe(this.client.query(`products.${productId}.variant.${variantId}`));
232
226
  }
233
- // --------------------------------------------------------------------------
234
- // ADD-ONS
235
- // --------------------------------------------------------------------------
236
227
  async getAddOns(productId) {
237
228
  return safe(this.client.query(`products.${productId}.add_ons`));
238
229
  }
239
- // --------------------------------------------------------------------------
240
- // CATEGORIES
241
- // --------------------------------------------------------------------------
242
230
  async getCategories() {
243
231
  return safe(this.client.query("categories"));
244
232
  }
@@ -258,9 +246,6 @@ var CatalogueQueries = class {
258
246
  async getCategoryProducts(categoryId) {
259
247
  return safe(this.client.query(`products[?(@.category_id=='${categoryId}')]`));
260
248
  }
261
- // --------------------------------------------------------------------------
262
- // COLLECTIONS
263
- // --------------------------------------------------------------------------
264
249
  async getCollections() {
265
250
  return safe(this.client.query("collections"));
266
251
  }
@@ -285,9 +270,6 @@ var CatalogueQueries = class {
285
270
  this.client.query(`collections[?(@.name contains '${query2}')]#limit(${limit})`)
286
271
  );
287
272
  }
288
- // --------------------------------------------------------------------------
289
- // BUNDLES
290
- // --------------------------------------------------------------------------
291
273
  async getBundles() {
292
274
  return safe(this.client.query("bundles"));
293
275
  }
@@ -309,9 +291,6 @@ var CatalogueQueries = class {
309
291
  this.client.query(`bundles[?(@.name contains '${query2}')]#limit(${limit})`)
310
292
  );
311
293
  }
312
- // --------------------------------------------------------------------------
313
- // COMPOSITES (Build-Your-Own)
314
- // --------------------------------------------------------------------------
315
294
  async getComposites(options) {
316
295
  let query2 = "composites";
317
296
  if (options?.limit) {
@@ -334,9 +313,6 @@ var CatalogueQueries = class {
334
313
  })
335
314
  );
336
315
  }
337
- // --------------------------------------------------------------------------
338
- // SEARCH
339
- // --------------------------------------------------------------------------
340
316
  async search(query2, options) {
341
317
  const limit = options?.limit ?? 20;
342
318
  let searchQuery = `products[?(@.name contains '${query2}')]`;
@@ -355,9 +331,6 @@ var CatalogueQueries = class {
355
331
  })
356
332
  );
357
333
  }
358
- // --------------------------------------------------------------------------
359
- // MENU (Restaurant-specific)
360
- // --------------------------------------------------------------------------
361
334
  async getMenu(options) {
362
335
  let query2 = "menu";
363
336
  if (options?.category) {
@@ -395,13 +368,6 @@ var CartOperations = class {
395
368
  constructor(client) {
396
369
  this.client = client;
397
370
  }
398
- // --------------------------------------------------------------------------
399
- // CART QUERIES
400
- // --------------------------------------------------------------------------
401
- /**
402
- * Get the enriched cart with product names, images, and details.
403
- * This is the main method for storefront display.
404
- */
405
371
  async get() {
406
372
  return safe2(this.client.query("cart#enriched"));
407
373
  }
@@ -431,33 +397,6 @@ var CartOperations = class {
431
397
  currency: cart.pricing.currency
432
398
  });
433
399
  }
434
- // --------------------------------------------------------------------------
435
- // CART MUTATIONS
436
- // --------------------------------------------------------------------------
437
- /**
438
- * Add an item to the cart.
439
- *
440
- * @example
441
- * ```typescript
442
- * const result = await client.cart.addItem({
443
- * item_id: "prod_burger",
444
- * quantity: 2,
445
- * variant_id: "var_large",
446
- * add_on_options: ["addon_cheese", "addon_bacon"],
447
- * });
448
- *
449
- * if (!result.ok) {
450
- * switch (result.error.code) {
451
- * case ErrorCode.ITEM_UNAVAILABLE:
452
- * toast.error("Item no longer available");
453
- * break;
454
- * case ErrorCode.VARIANT_OUT_OF_STOCK:
455
- * toast.error("Selected option is out of stock");
456
- * break;
457
- * }
458
- * }
459
- * ```
460
- */
461
400
  async addItem(input) {
462
401
  return safe2(this.client.call("cart.addItem", input));
463
402
  }
@@ -487,9 +426,6 @@ var CartOperations = class {
487
426
  async clear() {
488
427
  return safe2(this.client.call("cart.clearCart"));
489
428
  }
490
- // --------------------------------------------------------------------------
491
- // COUPONS & DISCOUNTS
492
- // --------------------------------------------------------------------------
493
429
  async applyCoupon(code) {
494
430
  return safe2(
495
431
  this.client.call("cart.applyCoupon", {
@@ -500,9 +436,6 @@ var CartOperations = class {
500
436
  async removeCoupon() {
501
437
  return safe2(this.client.call("cart.removeCoupon"));
502
438
  }
503
- // --------------------------------------------------------------------------
504
- // CONVENIENCE METHODS
505
- // --------------------------------------------------------------------------
506
439
  async isEmpty() {
507
440
  const countResult = await this.getCount();
508
441
  if (!countResult.ok) return countResult;
@@ -655,35 +588,6 @@ var CheckoutService = class {
655
588
  constructor(client) {
656
589
  this.client = client;
657
590
  }
658
- /**
659
- * Process checkout with cart data.
660
- *
661
- * Automatically generates an idempotency key if not provided to ensure
662
- * payment safety. The same key is used across retries, preventing
663
- * duplicate charges if a network error occurs after payment processing.
664
- *
665
- * @example
666
- * ```typescript
667
- * const result = await client.checkout.process({
668
- * cart_id: cart.id,
669
- * customer: { name, email, phone, save_details: true },
670
- * order_type: "pickup",
671
- * payment_method: "mobile_money",
672
- * mobile_money_details: { phone_number, provider: "mtn" },
673
- * });
674
- *
675
- * if (!result.ok) {
676
- * switch (result.error.code) {
677
- * case ErrorCode.CART_EMPTY:
678
- * toast.error("Your cart is empty");
679
- * break;
680
- * case ErrorCode.PAYMENT_FAILED:
681
- * toast.error("Payment failed. Please try again.");
682
- * break;
683
- * }
684
- * }
685
- * ```
686
- */
687
591
  async process(data) {
688
592
  const checkoutData = {
689
593
  ...data,
@@ -801,9 +705,6 @@ var LinkService = class {
801
705
  constructor(client) {
802
706
  this.client = client;
803
707
  }
804
- // --------------------------------------------------------------------------
805
- // AUTHENTICATION
806
- // --------------------------------------------------------------------------
807
708
  async requestOtp(input) {
808
709
  return safe5(this.client.linkPost("/v1/link/auth/request-otp", input));
809
710
  }
@@ -823,9 +724,6 @@ var LinkService = class {
823
724
  }
824
725
  return result;
825
726
  }
826
- // --------------------------------------------------------------------------
827
- // STATUS & DATA
828
- // --------------------------------------------------------------------------
829
727
  async checkStatus(contact) {
830
728
  return safe5(
831
729
  this.client.call(LINK_MUTATION.CHECK_STATUS, {
@@ -845,9 +743,6 @@ var LinkService = class {
845
743
  async getPreferences() {
846
744
  return safe5(this.client.query(LINK_QUERY.PREFERENCES));
847
745
  }
848
- // --------------------------------------------------------------------------
849
- // ENROLLMENT
850
- // --------------------------------------------------------------------------
851
746
  async enroll(data) {
852
747
  return safe5(this.client.call(LINK_MUTATION.ENROLL, data));
853
748
  }
@@ -856,15 +751,9 @@ var LinkService = class {
856
751
  this.client.call(LINK_MUTATION.ENROLL_AND_LINK_ORDER, data)
857
752
  );
858
753
  }
859
- // --------------------------------------------------------------------------
860
- // PREFERENCES
861
- // --------------------------------------------------------------------------
862
754
  async updatePreferences(preferences) {
863
755
  return safe5(this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences));
864
756
  }
865
- // --------------------------------------------------------------------------
866
- // ADDRESSES
867
- // --------------------------------------------------------------------------
868
757
  async createAddress(input) {
869
758
  return safe5(this.client.call(LINK_MUTATION.CREATE_ADDRESS, input));
870
759
  }
@@ -884,9 +773,6 @@ var LinkService = class {
884
773
  })
885
774
  );
886
775
  }
887
- // --------------------------------------------------------------------------
888
- // MOBILE MONEY
889
- // --------------------------------------------------------------------------
890
776
  async createMobileMoney(input) {
891
777
  return safe5(this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input));
892
778
  }
@@ -910,9 +796,6 @@ var LinkService = class {
910
796
  this.client.call(LINK_MUTATION.VERIFY_MOBILE_MONEY, mobileMoneyId)
911
797
  );
912
798
  }
913
- // --------------------------------------------------------------------------
914
- // SESSIONS
915
- // --------------------------------------------------------------------------
916
799
  async getSessions() {
917
800
  return safe5(this.client.linkGet("/v1/link/sessions"));
918
801
  }
@@ -922,9 +805,6 @@ var LinkService = class {
922
805
  async revokeAllSessions() {
923
806
  return safe5(this.client.linkDelete("/v1/link/sessions"));
924
807
  }
925
- // --------------------------------------------------------------------------
926
- // REST ALTERNATIVES (for direct API access)
927
- // --------------------------------------------------------------------------
928
808
  async getAddressesRest() {
929
809
  return safe5(this.client.linkGet("/v1/link/addresses"));
930
810
  }
@@ -972,9 +852,6 @@ var AuthService = class {
972
852
  constructor(client) {
973
853
  this.client = client;
974
854
  }
975
- // --------------------------------------------------------------------------
976
- // STATUS & USER
977
- // --------------------------------------------------------------------------
978
855
  async getStatus() {
979
856
  return safe6(this.client.query("auth"));
980
857
  }
@@ -988,9 +865,6 @@ var AuthService = class {
988
865
  if (!result.ok) return result;
989
866
  return ok(result.value.is_authenticated);
990
867
  }
991
- // --------------------------------------------------------------------------
992
- // OTP AUTHENTICATION
993
- // --------------------------------------------------------------------------
994
868
  async requestOtp(contact, contactType) {
995
869
  return safe6(
996
870
  this.client.call(AUTH_MUTATION.REQUEST_OTP, {
@@ -1007,15 +881,9 @@ var AuthService = class {
1007
881
  })
1008
882
  );
1009
883
  }
1010
- // --------------------------------------------------------------------------
1011
- // SESSION MANAGEMENT
1012
- // --------------------------------------------------------------------------
1013
884
  async logout() {
1014
885
  return safe6(this.client.call("auth.logout"));
1015
886
  }
1016
- // --------------------------------------------------------------------------
1017
- // PROFILE MANAGEMENT
1018
- // --------------------------------------------------------------------------
1019
887
  async updateProfile(input) {
1020
888
  return safe6(this.client.call("auth.update_profile", input));
1021
889
  }
@@ -1046,9 +914,6 @@ var BusinessService = class {
1046
914
  constructor(client) {
1047
915
  this.client = client;
1048
916
  }
1049
- // --------------------------------------------------------------------------
1050
- // BUSINESS INFO
1051
- // --------------------------------------------------------------------------
1052
917
  async getInfo() {
1053
918
  return safe7(this.client.query("business.info"));
1054
919
  }
@@ -1064,27 +929,18 @@ var BusinessService = class {
1064
929
  async getTheme() {
1065
930
  return safe7(this.client.query("business.theme"));
1066
931
  }
1067
- // --------------------------------------------------------------------------
1068
- // LOCATIONS
1069
- // --------------------------------------------------------------------------
1070
932
  async getLocations() {
1071
933
  return safe7(this.client.query("business.locations"));
1072
934
  }
1073
935
  async getLocation(locationId) {
1074
936
  return safe7(this.client.query(`business.locations.${locationId}`));
1075
937
  }
1076
- // --------------------------------------------------------------------------
1077
- // HOURS
1078
- // --------------------------------------------------------------------------
1079
938
  async getHours() {
1080
939
  return safe7(this.client.query("business.hours"));
1081
940
  }
1082
941
  async getLocationHours(locationId) {
1083
942
  return safe7(this.client.query(`business.locations.${locationId}.hours`));
1084
943
  }
1085
- // --------------------------------------------------------------------------
1086
- // BOOTSTRAP (for storefront initialization)
1087
- // --------------------------------------------------------------------------
1088
944
  async getBootstrap() {
1089
945
  const [businessResult, locationsResult, categoriesResult] = await Promise.all([
1090
946
  this.getInfo(),
@@ -1129,9 +985,6 @@ var InventoryService = class {
1129
985
  constructor(client) {
1130
986
  this.client = client;
1131
987
  }
1132
- // --------------------------------------------------------------------------
1133
- // STOCK QUERIES
1134
- // --------------------------------------------------------------------------
1135
988
  async getStockLevels() {
1136
989
  return safe8(this.client.query("inventory.stock_levels"));
1137
990
  }
@@ -1158,9 +1011,6 @@ var InventoryService = class {
1158
1011
  })
1159
1012
  );
1160
1013
  }
1161
- // --------------------------------------------------------------------------
1162
- // AVAILABILITY CHECKS
1163
- // --------------------------------------------------------------------------
1164
1014
  async checkProductAvailability(productId, quantity, locationId) {
1165
1015
  return safe8(
1166
1016
  this.client.query("inventory.check_availability", {
@@ -1190,15 +1040,9 @@ var InventoryService = class {
1190
1040
  }
1191
1041
  return ok(results.map((r) => r.value));
1192
1042
  }
1193
- // --------------------------------------------------------------------------
1194
- // SUMMARY
1195
- // --------------------------------------------------------------------------
1196
1043
  async getSummary() {
1197
1044
  return safe8(this.client.query("inventory.summary"));
1198
1045
  }
1199
- // --------------------------------------------------------------------------
1200
- // CONVENIENCE METHODS
1201
- // --------------------------------------------------------------------------
1202
1046
  async isInStock(productId, locationId) {
1203
1047
  const result = await this.checkProductAvailability(productId, 1, locationId);
1204
1048
  if (!result.ok) return result;
@@ -1230,9 +1074,6 @@ var SchedulingService = class {
1230
1074
  constructor(client) {
1231
1075
  this.client = client;
1232
1076
  }
1233
- // --------------------------------------------------------------------------
1234
- // SERVICES
1235
- // --------------------------------------------------------------------------
1236
1077
  async getServices() {
1237
1078
  return safe9(this.client.query("scheduling.services"));
1238
1079
  }
@@ -1245,9 +1086,6 @@ var SchedulingService = class {
1245
1086
  if (!result.ok) return result;
1246
1087
  return ok(result.value.find((s) => s.id === serviceId) || null);
1247
1088
  }
1248
- // --------------------------------------------------------------------------
1249
- // AVAILABILITY
1250
- // --------------------------------------------------------------------------
1251
1089
  async getAvailableSlots(input) {
1252
1090
  return safe9(
1253
1091
  this.client.query(
@@ -1272,9 +1110,6 @@ var SchedulingService = class {
1272
1110
  )
1273
1111
  );
1274
1112
  }
1275
- // --------------------------------------------------------------------------
1276
- // BOOKINGS
1277
- // --------------------------------------------------------------------------
1278
1113
  async getBooking(bookingId) {
1279
1114
  return safe9(this.client.query(`scheduling.${bookingId}`));
1280
1115
  }
@@ -1295,18 +1130,12 @@ var SchedulingService = class {
1295
1130
  )
1296
1131
  );
1297
1132
  }
1298
- // --------------------------------------------------------------------------
1299
- // BOOKING MANAGEMENT
1300
- // --------------------------------------------------------------------------
1301
1133
  async cancelBooking(input) {
1302
1134
  return safe9(this.client.call("scheduling.cancel_booking", input));
1303
1135
  }
1304
1136
  async rescheduleBooking(input) {
1305
1137
  return safe9(this.client.call("scheduling.reschedule_booking", input));
1306
1138
  }
1307
- // --------------------------------------------------------------------------
1308
- // CONVENIENCE METHODS
1309
- // --------------------------------------------------------------------------
1310
1139
  async getNextAvailableSlot(serviceId, fromDate) {
1311
1140
  const date = fromDate || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
1312
1141
  const result = await this.getAvailableSlots({
@@ -1345,15 +1174,9 @@ var LiteService = class {
1345
1174
  constructor(client) {
1346
1175
  this.client = client;
1347
1176
  }
1348
- // --------------------------------------------------------------------------
1349
- // BOOTSTRAP
1350
- // --------------------------------------------------------------------------
1351
1177
  async getBootstrap() {
1352
1178
  return safe10(this.client.query("lite.bootstrap"));
1353
1179
  }
1354
- // --------------------------------------------------------------------------
1355
- // TABLE MANAGEMENT
1356
- // --------------------------------------------------------------------------
1357
1180
  async getTable(tableId) {
1358
1181
  return safe10(this.client.query(`lite.table.${tableId}`));
1359
1182
  }
@@ -1365,9 +1188,6 @@ var LiteService = class {
1365
1188
  })
1366
1189
  );
1367
1190
  }
1368
- // --------------------------------------------------------------------------
1369
- // KITCHEN ORDERS
1370
- // --------------------------------------------------------------------------
1371
1191
  async sendToKitchen(tableId, items) {
1372
1192
  return safe10(
1373
1193
  this.client.call("lite.send_to_kitchen", {
@@ -1391,9 +1211,6 @@ var LiteService = class {
1391
1211
  })
1392
1212
  );
1393
1213
  }
1394
- // --------------------------------------------------------------------------
1395
- // MENU (optimized for lite/QR experience)
1396
- // --------------------------------------------------------------------------
1397
1214
  async getMenu() {
1398
1215
  return safe10(this.client.query("lite.menu"));
1399
1216
  }
@@ -1467,7 +1284,6 @@ function deriveUrls() {
1467
1284
  var CimplifyClient = class {
1468
1285
  constructor(config = {}) {
1469
1286
  this.sessionToken = null;
1470
- /** In-flight request deduplication map */
1471
1287
  this.inflightRequests = /* @__PURE__ */ new Map();
1472
1288
  this.publicKey = config.publicKey || "";
1473
1289
  const urls = deriveUrls();
@@ -1477,18 +1293,31 @@ var CimplifyClient = class {
1477
1293
  this.timeout = config.timeout ?? DEFAULT_TIMEOUT_MS;
1478
1294
  this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
1479
1295
  this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY_MS;
1296
+ this.hooks = config.hooks ?? {};
1480
1297
  this.sessionToken = this.loadSessionToken();
1481
1298
  }
1482
1299
  getSessionToken() {
1483
1300
  return this.sessionToken;
1484
1301
  }
1485
1302
  setSessionToken(token) {
1303
+ const previous = this.sessionToken;
1486
1304
  this.sessionToken = token;
1487
1305
  this.saveSessionToken(token);
1306
+ this.hooks.onSessionChange?.({
1307
+ previousToken: previous,
1308
+ newToken: token,
1309
+ source: "manual"
1310
+ });
1488
1311
  }
1489
1312
  clearSession() {
1313
+ const previous = this.sessionToken;
1490
1314
  this.sessionToken = null;
1491
1315
  this.saveSessionToken(null);
1316
+ this.hooks.onSessionChange?.({
1317
+ previousToken: previous,
1318
+ newToken: null,
1319
+ source: "clear"
1320
+ });
1492
1321
  }
1493
1322
  loadSessionToken() {
1494
1323
  if (typeof window !== "undefined" && window.localStorage) {
@@ -1518,15 +1347,29 @@ var CimplifyClient = class {
1518
1347
  updateSessionFromResponse(response) {
1519
1348
  const newToken = response.headers.get(SESSION_TOKEN_HEADER);
1520
1349
  if (newToken && newToken !== this.sessionToken) {
1350
+ const previous = this.sessionToken;
1521
1351
  this.sessionToken = newToken;
1522
1352
  this.saveSessionToken(newToken);
1353
+ this.hooks.onSessionChange?.({
1354
+ previousToken: previous,
1355
+ newToken,
1356
+ source: "response"
1357
+ });
1523
1358
  }
1524
1359
  }
1525
- /**
1526
- * Resilient fetch with timeout and automatic retries for network errors.
1527
- * Uses exponential backoff: 1s, 2s, 4s between retries.
1528
- */
1529
1360
  async resilientFetch(url, options) {
1361
+ const method = options.method || "GET";
1362
+ const path = url.replace(this.baseUrl, "").replace(this.linkApiUrl, "");
1363
+ const startTime = Date.now();
1364
+ let retryCount = 0;
1365
+ const context = {
1366
+ method,
1367
+ path,
1368
+ url,
1369
+ body: options.body ? JSON.parse(options.body) : void 0,
1370
+ startTime
1371
+ };
1372
+ this.hooks.onRequestStart?.(context);
1530
1373
  let lastError;
1531
1374
  for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
1532
1375
  try {
@@ -1538,37 +1381,69 @@ var CimplifyClient = class {
1538
1381
  });
1539
1382
  clearTimeout(timeoutId);
1540
1383
  if (response.ok || response.status >= 400 && response.status < 500) {
1384
+ this.hooks.onRequestSuccess?.({
1385
+ ...context,
1386
+ status: response.status,
1387
+ durationMs: Date.now() - startTime
1388
+ });
1541
1389
  return response;
1542
1390
  }
1543
1391
  if (response.status >= 500 && attempt < this.maxRetries) {
1392
+ retryCount++;
1544
1393
  const delay = this.retryDelay * Math.pow(2, attempt);
1394
+ this.hooks.onRetry?.({
1395
+ ...context,
1396
+ attempt: retryCount,
1397
+ delayMs: delay,
1398
+ error: new Error(`Server error: ${response.status}`)
1399
+ });
1545
1400
  await sleep(delay);
1546
1401
  continue;
1547
1402
  }
1403
+ this.hooks.onRequestSuccess?.({
1404
+ ...context,
1405
+ status: response.status,
1406
+ durationMs: Date.now() - startTime
1407
+ });
1548
1408
  return response;
1549
1409
  } catch (error) {
1550
1410
  lastError = error;
1551
- if (!isRetryable(error) || attempt >= this.maxRetries) {
1552
- throw toNetworkError(error);
1411
+ const networkError = toNetworkError(error);
1412
+ const errorRetryable = isRetryable(error);
1413
+ if (!errorRetryable || attempt >= this.maxRetries) {
1414
+ this.hooks.onRequestError?.({
1415
+ ...context,
1416
+ error: networkError,
1417
+ durationMs: Date.now() - startTime,
1418
+ retryCount,
1419
+ retryable: errorRetryable
1420
+ });
1421
+ throw networkError;
1553
1422
  }
1423
+ retryCount++;
1554
1424
  const delay = this.retryDelay * Math.pow(2, attempt);
1425
+ this.hooks.onRetry?.({
1426
+ ...context,
1427
+ attempt: retryCount,
1428
+ delayMs: delay,
1429
+ error: networkError
1430
+ });
1555
1431
  await sleep(delay);
1556
1432
  }
1557
1433
  }
1558
- throw toNetworkError(lastError);
1434
+ const finalError = toNetworkError(lastError);
1435
+ this.hooks.onRequestError?.({
1436
+ ...context,
1437
+ error: finalError,
1438
+ durationMs: Date.now() - startTime,
1439
+ retryCount,
1440
+ retryable: false
1441
+ });
1442
+ throw finalError;
1559
1443
  }
1560
- /**
1561
- * Generate a deduplication key for a request.
1562
- * Same query + variables = same key = deduplicated.
1563
- */
1564
1444
  getDedupeKey(type, payload) {
1565
1445
  return `${type}:${JSON.stringify(payload)}`;
1566
1446
  }
1567
- /**
1568
- * Execute a request with deduplication.
1569
- * If an identical request is already in-flight, return the same promise.
1570
- * This prevents redundant network calls when multiple components request the same data.
1571
- */
1572
1447
  async deduplicatedRequest(key, requestFn) {
1573
1448
  const existing = this.inflightRequests.get(key);
1574
1449
  if (existing) {
@@ -1580,10 +1455,6 @@ var CimplifyClient = class {
1580
1455
  this.inflightRequests.set(key, request);
1581
1456
  return request;
1582
1457
  }
1583
- /**
1584
- * Execute a query with deduplication.
1585
- * Multiple identical queries made simultaneously will share a single network request.
1586
- */
1587
1458
  async query(query2, variables) {
1588
1459
  const body = { query: query2 };
1589
1460
  if (variables) {
@@ -1601,9 +1472,6 @@ var CimplifyClient = class {
1601
1472
  return this.handleResponse(response);
1602
1473
  });
1603
1474
  }
1604
- /**
1605
- * Execute a mutation. NOT deduplicated - mutations have side effects.
1606
- */
1607
1475
  async call(method, args) {
1608
1476
  const body = {
1609
1477
  method,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",