arky-sdk 0.9.0 → 0.9.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.
@@ -175,7 +175,7 @@ var createActivityApi = (apiConfig) => ({
175
175
  }
176
176
  }
177
177
  });
178
- var createStorefrontApi = (apiConfig, updateCustomerSession) => {
178
+ var createStorefrontApi = (apiConfig, updateProfileSession) => {
179
179
  const base = (storeId = apiConfig.storeId) => `/v1/storefront/${storeId}`;
180
180
  return {
181
181
  store: {
@@ -496,11 +496,11 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
496
496
  }
497
497
  },
498
498
  crm: {
499
- customer: {
499
+ profile: {
500
500
  async identify(params, options) {
501
501
  const store_id = apiConfig.storeId;
502
502
  const result = await apiConfig.httpClient.post(
503
- `${base(store_id)}/customers/identify`,
503
+ `${base(store_id)}/profiles/identify`,
504
504
  {
505
505
  store_id,
506
506
  market: params?.market || apiConfig.market || null,
@@ -510,9 +510,9 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
510
510
  options
511
511
  );
512
512
  if (result?.token?.token) {
513
- updateCustomerSession(() => ({
513
+ updateProfileSession(() => ({
514
514
  access_token: result.token.token,
515
- customer: result.customer,
515
+ profile: result.profile,
516
516
  store: result.store,
517
517
  market: result.market
518
518
  }));
@@ -522,12 +522,12 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
522
522
  async verify(params, options) {
523
523
  const store_id = apiConfig.storeId;
524
524
  const result = await apiConfig.httpClient.post(
525
- `${base(store_id)}/customers/verify`,
525
+ `${base(store_id)}/profiles/verify`,
526
526
  { store_id, code: params.code },
527
527
  options
528
528
  );
529
529
  if (result?.token) {
530
- updateCustomerSession(
530
+ updateProfileSession(
531
531
  (prev) => prev ? { ...prev, access_token: result.token } : null
532
532
  );
533
533
  }
@@ -537,132 +537,63 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
537
537
  const store_id = apiConfig.storeId;
538
538
  try {
539
539
  await apiConfig.httpClient.post(
540
- `${base(store_id)}/customers/logout`,
540
+ `${base(store_id)}/profiles/logout`,
541
541
  {},
542
542
  options
543
543
  );
544
544
  } finally {
545
- updateCustomerSession(() => null);
545
+ updateProfileSession(() => null);
546
546
  }
547
547
  },
548
548
  getMe(options) {
549
- return apiConfig.httpClient.get(`${base()}/customers/me`, options);
549
+ return apiConfig.httpClient.get(`${base()}/profiles/me`, options);
550
550
  }
551
551
  },
552
- audience: {
552
+ profileList: {
553
553
  get(params, options) {
554
- let identifier;
555
- if (params.id) {
556
- identifier = params.id;
557
- } else if (params.key) {
558
- identifier = `${apiConfig.storeId}:${params.key}`;
559
- } else {
560
- throw new Error("GetAudienceParams requires id or key");
561
- }
554
+ const store_id = params.store_id || apiConfig.storeId;
562
555
  return apiConfig.httpClient.get(
563
- `${base(apiConfig.storeId)}/audiences/${identifier}`,
556
+ `${base(store_id)}/profile-lists/${params.id}`,
564
557
  options
565
558
  );
566
559
  },
567
560
  find(params, options) {
568
- return apiConfig.httpClient.get(`${base()}/audiences`, {
561
+ const { store_id, ...queryParams } = params || {};
562
+ return apiConfig.httpClient.get(`${base(store_id)}/profile-lists`, {
569
563
  ...options,
570
- params
564
+ params: queryParams
571
565
  });
572
566
  },
573
567
  subscribe(params, options) {
568
+ const { store_id, id, ...payload } = params;
574
569
  return apiConfig.httpClient.post(
575
- `${base()}/audiences/${params.id}/subscribe`,
576
- {
577
- customer_id: params.customer_id,
578
- price_id: params.price_id,
579
- success_url: params.success_url,
580
- cancel_url: params.cancel_url,
581
- confirm_url: params.confirm_url
582
- },
570
+ `${base(store_id)}/profile-lists/${id}/subscribe`,
571
+ payload,
583
572
  options
584
573
  );
585
574
  },
586
575
  checkAccess(params, options) {
576
+ const store_id = params.store_id || apiConfig.storeId;
587
577
  return apiConfig.httpClient.get(
588
- `${base()}/audiences/${params.id}/access`,
578
+ `${base(store_id)}/profile-lists/${params.id}/access`,
589
579
  options
590
580
  );
591
581
  },
592
582
  unsubscribe(token, options) {
593
- return apiConfig.httpClient.get(`${base()}/audiences/unsubscribe`, {
583
+ return apiConfig.httpClient.get(`${base()}/profile-lists/unsubscribe`, {
594
584
  ...options,
595
585
  params: { token }
596
586
  });
597
587
  },
598
588
  confirm(token, options) {
599
- return apiConfig.httpClient.get(`${base()}/audiences/confirm`, {
589
+ return apiConfig.httpClient.get(`${base()}/profile-lists/confirm`, {
600
590
  ...options,
601
591
  params: { token }
602
592
  });
603
593
  }
604
594
  }
605
595
  },
606
- activity: createActivityApi(apiConfig),
607
- automation: {
608
- agent: {
609
- getAgents(params, options) {
610
- const store_id = params?.store_id || apiConfig.storeId;
611
- const queryParams = { ...params || {} };
612
- delete queryParams.store_id;
613
- return apiConfig.httpClient.get(`${base(store_id)}/agents`, {
614
- ...options,
615
- params: Object.keys(queryParams).length > 0 ? queryParams : void 0
616
- });
617
- },
618
- getAgent(params, options) {
619
- const store_id = params.store_id || apiConfig.storeId;
620
- return apiConfig.httpClient.get(
621
- `${base(store_id)}/agents/${params.id}`,
622
- options
623
- );
624
- },
625
- sendMessage(params, options) {
626
- const store_id = params.store_id || apiConfig.storeId;
627
- const body = { message: params.message };
628
- if (params.chat_id) body.chat_id = params.chat_id;
629
- return apiConfig.httpClient.post(
630
- `${base(store_id)}/agents/${params.id}/chats/messages`,
631
- body,
632
- options
633
- );
634
- },
635
- getChat(params, options) {
636
- const store_id = params.store_id || apiConfig.storeId;
637
- return apiConfig.httpClient.get(
638
- `${base(store_id)}/agents/${params.id}/chats/${params.chat_id}`,
639
- options
640
- );
641
- },
642
- getChatMessages(params, options) {
643
- const store_id = params.store_id || apiConfig.storeId;
644
- const queryParams = {};
645
- if (params.limit) queryParams.limit = String(params.limit);
646
- return apiConfig.httpClient.get(
647
- `${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/messages`,
648
- {
649
- ...options,
650
- params: Object.keys(queryParams).length > 0 ? queryParams : void 0
651
- }
652
- );
653
- },
654
- rateChat(params, options) {
655
- const store_id = params.store_id || apiConfig.storeId;
656
- const body = { rating: params.rating };
657
- if (params.comment) body.comment = params.comment;
658
- return apiConfig.httpClient.post(
659
- `${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/rate`,
660
- body,
661
- options
662
- );
663
- }
664
- }
665
- }
596
+ activity: createActivityApi(apiConfig)
666
597
  };
667
598
  };
668
599
 
@@ -997,6 +928,41 @@ function createHttpClient(cfg) {
997
928
  };
998
929
  }
999
930
 
931
+ // src/api/support.ts
932
+ function supportConversationQuery(params) {
933
+ const qs = new URLSearchParams({ store_id: params.store_id });
934
+ if (params.message_limit) qs.set("message_limit", String(params.message_limit));
935
+ if (typeof params.after_created_at === "number") qs.set("after_created_at", String(params.after_created_at));
936
+ if (params.after_id) qs.set("after_id", params.after_id);
937
+ return qs.toString();
938
+ }
939
+ function createStorefrontSupportApi(config) {
940
+ const { httpClient, storeId } = config;
941
+ return {
942
+ async startConversation(params = {}, opts) {
943
+ return httpClient.post(
944
+ `/v1/storefront/${storeId}/support/conversations`,
945
+ { store_id: storeId, ...params },
946
+ opts
947
+ );
948
+ },
949
+ async sendMessage(params, opts) {
950
+ return httpClient.post(
951
+ `/v1/storefront/${storeId}/support/conversations/${params.conversation_id}/messages`,
952
+ { store_id: storeId, ...params },
953
+ opts
954
+ );
955
+ },
956
+ async getConversation(params, opts) {
957
+ const qs = supportConversationQuery({ store_id: storeId, ...params });
958
+ return httpClient.get(
959
+ `/v1/storefront/${storeId}/support/conversations/${params.conversation_id}?${qs}`,
960
+ opts
961
+ );
962
+ }
963
+ };
964
+ }
965
+
1000
966
  // src/utils/price.ts
1001
967
  function formatCurrency(amount, currencyCode, locale = "en") {
1002
968
  if (!currencyCode) return "";
@@ -1286,22 +1252,22 @@ function createUtilitySurface(apiConfig) {
1286
1252
  getFirstAvailableFCId
1287
1253
  };
1288
1254
  }
1289
- var CUSTOMER_STORAGE_KEY = "arky_customer_session";
1290
- function readCustomerSession() {
1255
+ var PROFILE_STORAGE_KEY = "arky_profile_session";
1256
+ function readProfileSession() {
1291
1257
  if (typeof window === "undefined") return null;
1292
1258
  try {
1293
- const raw = localStorage.getItem(CUSTOMER_STORAGE_KEY);
1259
+ const raw = localStorage.getItem(PROFILE_STORAGE_KEY);
1294
1260
  return raw ? JSON.parse(raw) : null;
1295
1261
  } catch {
1296
1262
  return null;
1297
1263
  }
1298
1264
  }
1299
- function writeCustomerSession(s) {
1265
+ function writeProfileSession(s) {
1300
1266
  if (typeof window === "undefined") return;
1301
1267
  if (s) {
1302
- localStorage.setItem(CUSTOMER_STORAGE_KEY, JSON.stringify(s));
1268
+ localStorage.setItem(PROFILE_STORAGE_KEY, JSON.stringify(s));
1303
1269
  } else {
1304
- localStorage.removeItem(CUSTOMER_STORAGE_KEY);
1270
+ localStorage.removeItem(PROFILE_STORAGE_KEY);
1305
1271
  }
1306
1272
  }
1307
1273
  function createStorefront(config) {
@@ -1310,10 +1276,10 @@ function createStorefront(config) {
1310
1276
  const listeners = /* @__PURE__ */ new Set();
1311
1277
  let bareIdentifyPromise = null;
1312
1278
  function toPublic(s) {
1313
- return s ? { customer: s.customer, store: s.store, market: s.market } : null;
1279
+ return s ? { profile: s.profile, store: s.store, market: s.market } : null;
1314
1280
  }
1315
1281
  function emit() {
1316
- const pub = toPublic(readCustomerSession());
1282
+ const pub = toPublic(readProfileSession());
1317
1283
  for (const l of listeners) {
1318
1284
  Promise.resolve().then(() => l(pub)).catch(() => {
1319
1285
  });
@@ -1321,9 +1287,9 @@ function createStorefront(config) {
1321
1287
  }
1322
1288
  const updateSession = (updater) => {
1323
1289
  if (config.apiToken) return;
1324
- const prev = readCustomerSession();
1290
+ const prev = readProfileSession();
1325
1291
  const next = updater(prev);
1326
- writeCustomerSession(next);
1292
+ writeProfileSession(next);
1327
1293
  emit();
1328
1294
  };
1329
1295
  const authStorage = config.apiToken ? {
@@ -1334,7 +1300,7 @@ function createStorefront(config) {
1334
1300
  }
1335
1301
  } : {
1336
1302
  getTokens() {
1337
- const s = readCustomerSession();
1303
+ const s = readProfileSession();
1338
1304
  return s ? { access_token: s.access_token } : null;
1339
1305
  },
1340
1306
  onTokensRefreshed() {
@@ -1361,20 +1327,20 @@ function createStorefront(config) {
1361
1327
  authStorage
1362
1328
  };
1363
1329
  const storefrontApi = createStorefrontApi(apiConfig, updateSession);
1364
- const customerApi = storefrontApi.crm.customer;
1330
+ const profileApi = storefrontApi.crm.profile;
1365
1331
  function identify(params) {
1366
1332
  if (params?.market !== void 0) apiConfig.market = params.market;
1367
1333
  const isBareCall = !params?.email && !params?.verify;
1368
1334
  if (isBareCall && bareIdentifyPromise) return bareIdentifyPromise;
1369
1335
  const promise = (async () => {
1370
1336
  try {
1371
- const result = await customerApi.identify({
1337
+ const result = await profileApi.identify({
1372
1338
  market: apiConfig.market,
1373
1339
  email: params?.email,
1374
1340
  verify: params?.verify
1375
1341
  });
1376
1342
  return {
1377
- customer: result.customer,
1343
+ profile: result.profile,
1378
1344
  store: result.store,
1379
1345
  market: result.market
1380
1346
  };
@@ -1383,9 +1349,9 @@ function createStorefront(config) {
1383
1349
  const status = e?.statusCode || e?.status || e?.response?.status;
1384
1350
  if (isBareCall && status === 401) {
1385
1351
  updateSession(() => null);
1386
- const result = await customerApi.identify({ market: apiConfig.market });
1352
+ const result = await profileApi.identify({ market: apiConfig.market });
1387
1353
  return {
1388
- customer: result.customer,
1354
+ profile: result.profile,
1389
1355
  store: result.store,
1390
1356
  market: result.market
1391
1357
  };
@@ -1400,7 +1366,7 @@ function createStorefront(config) {
1400
1366
  return promise;
1401
1367
  }
1402
1368
  async function verify(params) {
1403
- const result = await customerApi.verify(params);
1369
+ const result = await profileApi.verify(params);
1404
1370
  bareIdentifyPromise = null;
1405
1371
  return result;
1406
1372
  }
@@ -1408,7 +1374,7 @@ function createStorefront(config) {
1408
1374
  if (config.apiToken) return;
1409
1375
  bareIdentifyPromise = null;
1410
1376
  try {
1411
- await customerApi.logout();
1377
+ await profileApi.logout();
1412
1378
  } catch {
1413
1379
  updateSession(() => null);
1414
1380
  }
@@ -1417,19 +1383,19 @@ function createStorefront(config) {
1417
1383
  identify,
1418
1384
  verify,
1419
1385
  logout,
1420
- me: () => customerApi.getMe(),
1386
+ me: () => profileApi.getMe(),
1421
1387
  get session() {
1422
1388
  if (config.apiToken) return null;
1423
- return toPublic(readCustomerSession());
1389
+ return toPublic(readProfileSession());
1424
1390
  },
1425
1391
  get isAuthenticated() {
1426
1392
  if (config.apiToken) return true;
1427
- const s = readCustomerSession();
1393
+ const s = readProfileSession();
1428
1394
  return s !== null && !!s.access_token;
1429
1395
  },
1430
1396
  onAuthStateChanged(listener) {
1431
1397
  listeners.add(listener);
1432
- const current = toPublic(readCustomerSession());
1398
+ const current = toPublic(readProfileSession());
1433
1399
  if (current) {
1434
1400
  Promise.resolve().then(() => listener(current)).catch(() => {
1435
1401
  });
@@ -1444,7 +1410,7 @@ function createStorefront(config) {
1444
1410
  eshop: storefrontApi.eshop,
1445
1411
  crm: storefrontApi.crm,
1446
1412
  activity: storefrontApi.activity,
1447
- automation: storefrontApi.automation,
1413
+ support: createStorefrontSupportApi(apiConfig),
1448
1414
  setStoreId: (storeId) => {
1449
1415
  apiConfig.storeId = storeId;
1450
1416
  bareIdentifyPromise = null;
@@ -1515,7 +1481,7 @@ function priceForMarket(prices, market, fallbackCurrency) {
1515
1481
  market: price?.market || market,
1516
1482
  currency: price?.currency || fallbackCurrency || "",
1517
1483
  compare_at: price?.compare_at,
1518
- audience_id: price?.audience_id
1484
+ profile_list_id: price?.profile_list_id
1519
1485
  };
1520
1486
  }
1521
1487
  function availableStock(client, variant) {
@@ -1710,18 +1676,46 @@ function createArkyStore(config) {
1710
1676
  selected_shipping_method_id: null,
1711
1677
  user_token: null
1712
1678
  });
1679
+ function rawProductItemCount(value) {
1680
+ return (value?.items || []).reduce((total, item) => {
1681
+ if (item.type !== "product") return total;
1682
+ return total + (item.quantity || 0);
1683
+ }, 0);
1684
+ }
1685
+ function rawServiceItemCount(value) {
1686
+ return (value?.items || []).reduce((total, item) => {
1687
+ if (item.type !== "service") return total;
1688
+ return total + Math.max(1, item.slots?.length || 0);
1689
+ }, 0);
1690
+ }
1713
1691
  const product_item_count = computed(
1714
- product_items,
1715
- (items) => items.reduce((total, item) => total + (item.quantity || 0), 0)
1692
+ [cart, product_items],
1693
+ (cartValue, items) => Math.max(
1694
+ rawProductItemCount(cartValue),
1695
+ items.reduce((total, item) => total + (item.quantity || 0), 0)
1696
+ )
1697
+ );
1698
+ const service_item_count = computed(
1699
+ [cart, service_items],
1700
+ (cartValue, items) => Math.max(rawServiceItemCount(cartValue), items.length)
1701
+ );
1702
+ const item_count = computed(
1703
+ [cart, product_item_count, service_item_count],
1704
+ (cartValue, products, services) => Math.max(cartValue?.item_count || 0, products + services)
1716
1705
  );
1717
- const service_item_count = computed(service_items, (items) => items.length);
1718
- const item_count = computed([product_item_count, service_item_count], (products, services) => products + services);
1719
1706
  const snapshot = computed([cart, product_items, service_items, item_count], (cartValue, products, services, count) => ({
1720
1707
  cart: cartValue,
1721
1708
  product_items: products,
1722
1709
  service_items: services,
1723
1710
  item_count: count
1724
1711
  }));
1712
+ let cartWriteRevision = 0;
1713
+ let sessionRequest = null;
1714
+ let cartRequest = null;
1715
+ function nextCartWriteRevision() {
1716
+ cartWriteRevision += 1;
1717
+ return cartWriteRevision;
1718
+ }
1725
1719
  const cms_state = map({
1726
1720
  nodes: {},
1727
1721
  forms: {},
@@ -1769,7 +1763,12 @@ function createArkyStore(config) {
1769
1763
  const current = session.get();
1770
1764
  const marketKey = currentMarketKey();
1771
1765
  if (current && (!marketKey || current.market?.key === marketKey)) return current;
1772
- return identify({ market: marketKey });
1766
+ if (!sessionRequest) {
1767
+ sessionRequest = identify({ market: marketKey }).finally(() => {
1768
+ sessionRequest = null;
1769
+ });
1770
+ }
1771
+ return sessionRequest;
1773
1772
  }
1774
1773
  async function identify(params = {}) {
1775
1774
  if (params.market) setMarket(params.market);
@@ -1795,17 +1794,23 @@ function createArkyStore(config) {
1795
1794
  if (context.market) setMarket(context.market);
1796
1795
  }
1797
1796
  async function ensureCart() {
1797
+ if (cartRequest) return cartRequest;
1798
1798
  cart_status.setKey("loading", true);
1799
1799
  cart_status.setKey("error", null);
1800
- try {
1800
+ const refreshRevision = cartWriteRevision;
1801
+ cartRequest = (async () => {
1801
1802
  await ensureSession();
1802
1803
  const response = await client.cart.refresh({ market: currentMarketKey() });
1803
- await hydrateCart(response);
1804
+ await hydrateCart(response, { ifRevision: refreshRevision });
1804
1805
  return response;
1806
+ })();
1807
+ try {
1808
+ return await cartRequest;
1805
1809
  } catch (error) {
1806
1810
  cart_status.setKey("error", readErrorMessage(error, "Failed to load cart."));
1807
1811
  throw error;
1808
1812
  } finally {
1813
+ cartRequest = null;
1809
1814
  cart_status.setKey("loading", false);
1810
1815
  }
1811
1816
  }
@@ -1858,7 +1863,10 @@ function createArkyStore(config) {
1858
1863
  }
1859
1864
  return rows;
1860
1865
  }
1861
- async function hydrateCart(response) {
1866
+ async function hydrateCart(response, options = {}) {
1867
+ if (options.ifRevision !== void 0 && options.ifRevision !== cartWriteRevision) {
1868
+ return cart.get() || response;
1869
+ }
1862
1870
  cart.set(response);
1863
1871
  cart_status.setKey("user_token", response.token || null);
1864
1872
  cart_status.setKey("selected_shipping_method_id", response.shipping_method_id || null);
@@ -1881,7 +1889,7 @@ function createArkyStore(config) {
1881
1889
  ...toServiceCheckoutItems(input.service_items || service_items.get())
1882
1890
  ];
1883
1891
  }
1884
- async function syncCart(input = {}) {
1892
+ async function syncCart(input = {}, writeRevision = nextCartWriteRevision()) {
1885
1893
  cart_status.setKey("syncing", true);
1886
1894
  cart_status.setKey("error", null);
1887
1895
  try {
@@ -1901,7 +1909,7 @@ function createArkyStore(config) {
1901
1909
  if (input.shipping_method_id !== void 0) {
1902
1910
  cart_status.setKey("selected_shipping_method_id", input.shipping_method_id);
1903
1911
  }
1904
- await hydrateCart(response);
1912
+ await hydrateCart(response, { ifRevision: writeRevision });
1905
1913
  return response;
1906
1914
  } catch (error) {
1907
1915
  cart_status.setKey("error", readErrorMessage(error, "Failed to sync cart."));
@@ -1912,6 +1920,7 @@ function createArkyStore(config) {
1912
1920
  }
1913
1921
  async function addProduct(product, variant, quantity = 1) {
1914
1922
  cart_status.setKey("error", null);
1923
+ const writeRevision = nextCartWriteRevision();
1915
1924
  try {
1916
1925
  const current = cart.get() || await ensureCart();
1917
1926
  const response = await client.cart.addItem({
@@ -1923,7 +1932,7 @@ function createArkyStore(config) {
1923
1932
  quantity
1924
1933
  }
1925
1934
  });
1926
- await hydrateCart(response);
1935
+ await hydrateCart(response, { ifRevision: writeRevision });
1927
1936
  await client.activity.track({ type: "cart_added", payload: { product_id: product.id, variant_id: variant.id, quantity } });
1928
1937
  return response;
1929
1938
  } catch (error) {
@@ -1932,15 +1941,17 @@ function createArkyStore(config) {
1932
1941
  }
1933
1942
  }
1934
1943
  async function setProductQuantity(itemId, quantity) {
1944
+ const writeRevision = nextCartWriteRevision();
1935
1945
  const next = product_items.get().map((item) => {
1936
1946
  if (item.id !== itemId) return item;
1937
1947
  const bounded = item.max_stock ? Math.min(Math.max(1, quantity), item.max_stock) : Math.max(1, quantity);
1938
1948
  return { ...item, quantity: bounded };
1939
1949
  });
1940
1950
  product_items.set(next);
1941
- return syncCart({ product_items: next });
1951
+ return syncCart({ product_items: next }, writeRevision);
1942
1952
  }
1943
1953
  async function removeProduct(itemId) {
1954
+ const writeRevision = nextCartWriteRevision();
1944
1955
  const item = product_items.get().find((candidate) => candidate.id === itemId);
1945
1956
  product_items.set(product_items.get().filter((candidate) => candidate.id !== itemId));
1946
1957
  const current = cart.get();
@@ -1951,21 +1962,24 @@ function createArkyStore(config) {
1951
1962
  product_id: item.product_id,
1952
1963
  variant_id: item.variant_id
1953
1964
  });
1954
- await hydrateCart(response);
1965
+ await hydrateCart(response, { ifRevision: writeRevision });
1955
1966
  await client.activity.track({ type: "cart_removed", payload: { product_id: item.product_id, variant_id: item.variant_id } });
1956
1967
  return response;
1957
1968
  }
1958
1969
  async function addServiceItem(item) {
1970
+ const writeRevision = nextCartWriteRevision();
1959
1971
  const next = [...service_items.get(), item];
1960
1972
  service_items.set(next);
1961
- return syncCart({ service_items: next });
1973
+ return syncCart({ service_items: next }, writeRevision);
1962
1974
  }
1963
1975
  async function removeServiceItem(itemId) {
1976
+ const writeRevision = nextCartWriteRevision();
1964
1977
  const next = service_items.get().filter((item) => item.id !== itemId);
1965
1978
  service_items.set(next);
1966
- return syncCart({ service_items: next });
1979
+ return syncCart({ service_items: next }, writeRevision);
1967
1980
  }
1968
1981
  async function clearCart() {
1982
+ const writeRevision = nextCartWriteRevision();
1969
1983
  product_items.set([]);
1970
1984
  service_items.set([]);
1971
1985
  quote.set(null);
@@ -1974,7 +1988,7 @@ function createArkyStore(config) {
1974
1988
  const current = cart.get();
1975
1989
  if (!current) return null;
1976
1990
  const response = await client.cart.clear({ id: current.id });
1977
- await hydrateCart(response);
1991
+ await hydrateCart(response, { ifRevision: writeRevision });
1978
1992
  return response;
1979
1993
  }
1980
1994
  async function fetchQuote(input = {}) {
@@ -2742,6 +2756,7 @@ function createArkyStore(config) {
2742
2756
  setMarket,
2743
2757
  setLocale,
2744
2758
  setContext,
2759
+ getStoreId: client.getStoreId,
2745
2760
  getMarket: currentMarketKey,
2746
2761
  getLocale: currentLocale,
2747
2762
  cms: {
@@ -2779,8 +2794,8 @@ function createArkyStore(config) {
2779
2794
  },
2780
2795
  state: atom(null)
2781
2796
  },
2797
+ support: client.support,
2782
2798
  store: client.store,
2783
- automation: client.automation,
2784
2799
  utils: client.utils
2785
2800
  };
2786
2801
  }