@cimplify/sdk 0.46.2 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT } from './chunk-NRDRVZ62.mjs';
3
3
  export { getVariantDisplayName } from './chunk-NRDRVZ62.mjs';
4
- import { createCimplifyClient } from './chunk-WUIERJ6J.mjs';
5
- import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-CKRMA5F7.mjs';
4
+ import { createCimplifyClient } from './chunk-MBR2DBEN.mjs';
5
+ import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-OFNVLUH4.mjs';
6
6
  import { formatPrice, parsePrice, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-XY2DFX5K.mjs';
7
7
  import { isSupportedCurrency } from './chunk-Z2AYLZDF.mjs';
8
8
  import React10, { createContext, useRef, useState, useCallback, useEffect, useContext, useMemo, useId, useSyncExternalStore } from 'react';
@@ -621,7 +621,8 @@ function useCollectionStore(collection) {
621
621
  }
622
622
 
623
623
  // src/react/hooks/use-cart.ts
624
- var CART_STORAGE_PREFIX = "cimplify:cart:v3";
624
+ var LEGACY_CART_STORAGE_PREFIX = "cimplify:cart:v3";
625
+ var legacyCachesPurged = false;
625
626
  var cartStores = /* @__PURE__ */ new Map();
626
627
  var ROLLBACK_VISIBLE_DELAY_MS = 3e3;
627
628
  function clearAllCartStores() {
@@ -631,34 +632,35 @@ function clearAllCartStores() {
631
632
  clearTimeout(handle);
632
633
  }
633
634
  entry.failedOpRemovers.clear();
634
- if (entry.persistTimer) {
635
- clearTimeout(entry.persistTimer);
636
- entry.persistTimer = null;
637
- }
638
635
  }
639
636
  cartStores.clear();
640
637
  }
641
638
  function emptyBase(currency, isLoading = true) {
642
639
  return { items: [], subtotal: 0, tax: 0, total: 0, currency, isLoading };
643
640
  }
644
- function advanceBaseWithPatch(entry, patch) {
645
- const current = entry.collection.getBase() ?? emptyBase(entry.currency, false);
646
- entry.collection.setBase({ ...applyCartPatch(current, patch), isLoading: false });
647
- persistBase(entry);
648
- }
649
- function buildStoreKey(client, locationId, isDemoMode) {
641
+ function buildStoreKey(client, locationId) {
650
642
  return [
651
- client.getPublicKey() || "__demo__",
652
- locationId || "__no_location__",
653
- isDemoMode ? "demo" : "live"
643
+ client.getPublicKey() || "__no_public_key__",
644
+ locationId || "__no_location__"
654
645
  ].join(":");
655
646
  }
656
- function buildStorageKey(storeKey) {
657
- return `${CART_STORAGE_PREFIX}:${storeKey}`;
658
- }
659
- function stripInternalItemMetadata(item) {
660
- const { _lineKey, isOptimistic, ...rest } = item;
661
- return rest;
647
+ function purgeLegacyCartCachesOnce() {
648
+ if (legacyCachesPurged) return;
649
+ legacyCachesPurged = true;
650
+ if (typeof window === "undefined" || !window.localStorage) return;
651
+ try {
652
+ const keys = [];
653
+ for (let i = 0; i < window.localStorage.length; i += 1) {
654
+ const key = window.localStorage.key(i);
655
+ if (key && key.startsWith(LEGACY_CART_STORAGE_PREFIX)) {
656
+ keys.push(key);
657
+ }
658
+ }
659
+ for (const key of keys) {
660
+ window.localStorage.removeItem(key);
661
+ }
662
+ } catch {
663
+ }
662
664
  }
663
665
  function toProductFromServerItem(item, businessId) {
664
666
  return {
@@ -753,61 +755,13 @@ function deriveView(base, ops) {
753
755
  pendingOpCount: ops.length
754
756
  };
755
757
  }
756
- function persistBase(entry) {
757
- if (typeof window === "undefined" || !window.localStorage) return;
758
- if (entry.persistTimer) return;
759
- entry.persistTimer = setTimeout(() => {
760
- entry.persistTimer = null;
761
- if (typeof window === "undefined" || !window.localStorage) return;
762
- const base = entry.collection.getBase();
763
- if (!base) return;
764
- try {
765
- window.localStorage.setItem(
766
- entry.storageKey,
767
- JSON.stringify({
768
- items: base.items.map((item) => stripInternalItemMetadata(item)),
769
- subtotal: base.subtotal,
770
- tax: base.tax,
771
- total: base.total,
772
- currency: base.currency
773
- })
774
- );
775
- } catch {
776
- }
777
- }, 100);
778
- }
779
- function hydrateFromStorage(entry) {
780
- if (typeof window === "undefined" || !window.localStorage) return;
781
- try {
782
- const raw = window.localStorage.getItem(entry.storageKey);
783
- if (!raw) return;
784
- const parsed = JSON.parse(raw);
785
- if (!parsed || !Array.isArray(parsed.items)) return;
786
- const items = parsed.items.map((item) => attachInternalItemMetadata(item));
787
- entry.collection.setBase({
788
- items,
789
- subtotal: toNumber(parsed.subtotal),
790
- tax: toNumber(parsed.tax),
791
- total: toNumber(parsed.total),
792
- currency: typeof parsed.currency === "string" && parsed.currency ? parsed.currency : entry.currency,
793
- isLoading: !entry.isDemoMode
794
- });
795
- } catch {
796
- }
797
- }
798
758
  async function syncFromServer(entry) {
799
- if (entry.isDemoMode) {
800
- const base = entry.collection.getBase() ?? emptyBase(entry.currency);
801
- entry.collection.setBase({ ...base, isLoading: false });
802
- return;
803
- }
804
759
  if (entry.syncing) return;
805
760
  entry.syncing = true;
806
761
  try {
807
762
  const result = await entry.client.cart.get();
808
763
  if (!result.ok) throw result.error;
809
764
  entry.collection.setBase(mapServerCart(result.value, entry.currency));
810
- persistBase(entry);
811
765
  } finally {
812
766
  entry.syncing = false;
813
767
  }
@@ -829,8 +783,9 @@ function scheduleFailedOpRemoval(entry, opId) {
829
783
  entry.failedOpRemovers.add(handle);
830
784
  }
831
785
  function getOrCreateStore(params) {
832
- const { client, locationId, isDemoMode, currency, optimisticEnabled } = params;
833
- const storeKey = buildStoreKey(client, locationId, isDemoMode);
786
+ const { client, locationId, currency, optimisticEnabled } = params;
787
+ purgeLegacyCartCachesOnce();
788
+ const storeKey = buildStoreKey(client, locationId);
834
789
  const existing = cartStores.get(storeKey);
835
790
  if (existing) {
836
791
  existing.optimisticEnabled = optimisticEnabled;
@@ -844,14 +799,11 @@ function getOrCreateStore(params) {
844
799
  const entry = {
845
800
  collection,
846
801
  client,
847
- storageKey: buildStorageKey(storeKey),
848
802
  locationId,
849
803
  currency,
850
- isDemoMode,
851
804
  optimisticEnabled,
852
805
  initialized: false,
853
806
  initializePromise: null,
854
- persistTimer: null,
855
807
  syncing: false,
856
808
  failedOpRemovers: /* @__PURE__ */ new Set()
857
809
  };
@@ -864,12 +816,6 @@ async function ensureInitialized(entry) {
864
816
  return;
865
817
  }
866
818
  entry.initialized = true;
867
- hydrateFromStorage(entry);
868
- if (entry.isDemoMode) {
869
- const base = entry.collection.getBase() ?? emptyBase(entry.currency);
870
- entry.collection.setBase({ ...base, isLoading: false });
871
- return;
872
- }
873
819
  entry.initializePromise = syncFromServer(entry).catch(() => {
874
820
  const base = entry.collection.getBase() ?? emptyBase(entry.currency);
875
821
  entry.collection.setBase({ ...base, isLoading: false });
@@ -883,7 +829,7 @@ async function maybeResolveQuoteId(entry, product, quantity, options) {
883
829
  const requiresQuote = Boolean(
884
830
  options.variantId || addOnOptionIds && addOnOptionIds.length > 0 || options.bundleSelections && options.bundleSelections.length > 0 || options.compositeSelections && options.compositeSelections.length > 0
885
831
  );
886
- if (!requiresQuote || entry.isDemoMode) return void 0;
832
+ if (!requiresQuote) return void 0;
887
833
  const quoteResult = await entry.client.catalogue.fetchQuote({
888
834
  product_id: product.id,
889
835
  quantity,
@@ -923,10 +869,6 @@ async function performAddItem(entry, product, quantity, options) {
923
869
  });
924
870
  const idempotencyKey = `idem_${typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}_${Math.random().toString(36).slice(2, 10)}`}`;
925
871
  const patch = { kind: "add_item", tempItem, lineKey };
926
- if (entry.isDemoMode) {
927
- advanceBaseWithPatch(entry, patch);
928
- return;
929
- }
930
872
  const useOptimistic = entry.optimisticEnabled;
931
873
  const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
932
874
  try {
@@ -965,10 +907,6 @@ async function performAddItem(entry, product, quantity, options) {
965
907
  async function performRemoveItem(entry, itemId) {
966
908
  const idempotencyKey = "";
967
909
  const patch = { kind: "remove_item", itemId };
968
- if (entry.isDemoMode) {
969
- advanceBaseWithPatch(entry, patch);
970
- return;
971
- }
972
910
  const useOptimistic = entry.optimisticEnabled;
973
911
  const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
974
912
  try {
@@ -993,10 +931,6 @@ async function performUpdateQuantity(entry, itemId, quantity) {
993
931
  const resolved = clampQuantity(quantity);
994
932
  const idempotencyKey = "";
995
933
  const patch = { kind: "set_quantity", itemId, quantity: resolved };
996
- if (entry.isDemoMode) {
997
- advanceBaseWithPatch(entry, patch);
998
- return;
999
- }
1000
934
  const useOptimistic = entry.optimisticEnabled;
1001
935
  const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
1002
936
  try {
@@ -1017,10 +951,6 @@ async function performUpdateQuantity(entry, itemId, quantity) {
1017
951
  async function performClear(entry) {
1018
952
  const idempotencyKey = "";
1019
953
  const patch = { kind: "clear" };
1020
- if (entry.isDemoMode) {
1021
- advanceBaseWithPatch(entry, patch);
1022
- return;
1023
- }
1024
954
  const useOptimistic = entry.optimisticEnabled;
1025
955
  const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
1026
956
  try {
@@ -1051,18 +981,16 @@ function useCart(options = {}) {
1051
981
  throw new Error("useCart must be used within CimplifyProvider or passed { client }.");
1052
982
  }
1053
983
  const locationId = options.locationId ?? client.getLocationId();
1054
- const isDemoMode = options.demoMode ?? context?.isDemoMode ?? client.getPublicKey().trim().length === 0;
1055
984
  const currency = options.currency ?? context?.currency ?? "USD";
1056
985
  const optimisticEnabled = context?.optimistic ?? true;
1057
986
  const entry = useMemo(
1058
987
  () => getOrCreateStore({
1059
988
  client,
1060
989
  locationId,
1061
- isDemoMode,
1062
990
  currency,
1063
991
  optimisticEnabled
1064
992
  }),
1065
- [client, currency, isDemoMode, locationId, optimisticEnabled]
993
+ [client, currency, locationId, optimisticEnabled]
1066
994
  );
1067
995
  const view = useCollectionStore(entry.collection);
1068
996
  useEffect(() => {
@@ -1222,7 +1150,6 @@ function CimplifyProvider({
1222
1150
  useEffect(() => {
1223
1151
  onLocationChangeRef.current = onLocationChange;
1224
1152
  }, [onLocationChange]);
1225
- const isDemoMode = resolvedClient.getPublicKey().trim().length === 0;
1226
1153
  const baseCurrency = business?.default_currency || DEFAULT_CURRENCY;
1227
1154
  const [displayCurrencyOverride, setDisplayCurrencyOverride] = useState(
1228
1155
  () => getStoredDisplayCurrency()
@@ -1244,7 +1171,7 @@ function CimplifyProvider({
1244
1171
  [baseCurrency]
1245
1172
  );
1246
1173
  useEffect(() => {
1247
- if (displayCurrency === baseCurrency || isDemoMode) {
1174
+ if (displayCurrency === baseCurrency) {
1248
1175
  setFxRate(null);
1249
1176
  return;
1250
1177
  }
@@ -1267,7 +1194,7 @@ function CimplifyProvider({
1267
1194
  cancelled = true;
1268
1195
  clearInterval(intervalId);
1269
1196
  };
1270
- }, [resolvedClient, baseCurrency, displayCurrency, isDemoMode]);
1197
+ }, [resolvedClient, baseCurrency, displayCurrency]);
1271
1198
  const convertPrice = useCallback(
1272
1199
  (amount) => {
1273
1200
  const num = typeof amount === "string" ? parseFloat(amount) : amount;
@@ -1294,17 +1221,6 @@ function CimplifyProvider({
1294
1221
  let cancelled = false;
1295
1222
  async function bootstrap() {
1296
1223
  setIsReady(false);
1297
- if (isDemoMode) {
1298
- if (!cancelled) {
1299
- setBusiness(null);
1300
- setLocations([]);
1301
- setCurrentLocationState(null);
1302
- resolvedClient.setLocationId(null);
1303
- setStoredLocationId(null);
1304
- setIsReady(true);
1305
- }
1306
- return;
1307
- }
1308
1224
  const [businessResult, locationsResult] = await Promise.all([
1309
1225
  resolvedClient.business.getInfo(),
1310
1226
  resolvedClient.business.getLocations()
@@ -1345,7 +1261,7 @@ function CimplifyProvider({
1345
1261
  return () => {
1346
1262
  cancelled = true;
1347
1263
  };
1348
- }, [resolvedClient, isDemoMode]);
1264
+ }, [resolvedClient]);
1349
1265
  const clientContextValue = useMemo(
1350
1266
  () => ({
1351
1267
  client: resolvedClient,
@@ -1354,7 +1270,6 @@ function CimplifyProvider({
1354
1270
  country: business?.country_code || DEFAULT_COUNTRY,
1355
1271
  locations,
1356
1272
  isReady,
1357
- isDemoMode,
1358
1273
  baseCurrency,
1359
1274
  optimistic
1360
1275
  }),
@@ -1364,7 +1279,6 @@ function CimplifyProvider({
1364
1279
  baseCurrency,
1365
1280
  locations,
1366
1281
  isReady,
1367
- isDemoMode,
1368
1282
  optimistic
1369
1283
  ]
1370
1284
  );
@@ -1472,7 +1386,6 @@ function CimplifyCheckout({
1472
1386
  onError,
1473
1387
  onStatusChange,
1474
1388
  appearance,
1475
- demoMode,
1476
1389
  className
1477
1390
  }) {
1478
1391
  const resolvedOrderTypes = useMemo(
@@ -1500,8 +1413,6 @@ function CimplifyCheckout({
1500
1413
  const initialAppearanceRef = useRef(appearance);
1501
1414
  const hasWarnedInlineAppearanceRef = useRef(false);
1502
1415
  const isMountedRef = useRef(true);
1503
- const demoRunRef = useRef(0);
1504
- const isDemoCheckout = demoMode ?? client.getPublicKey().trim().length === 0;
1505
1416
  const isTestMode = client.isTestMode();
1506
1417
  const cimplifyCtx = useOptionalCimplify();
1507
1418
  const fxOptions = useMemo(() => {
@@ -1546,15 +1457,6 @@ function CimplifyCheckout({
1546
1457
  useEffect(() => {
1547
1458
  let cancelled = false;
1548
1459
  async function bootstrap() {
1549
- if (isDemoCheckout) {
1550
- if (!cancelled) {
1551
- setResolvedBusinessId(businessId ?? null);
1552
- setResolvedCartId(cartId ?? "cart_demo");
1553
- setIsInitializing(false);
1554
- setErrorMessage(null);
1555
- }
1556
- return;
1557
- }
1558
1460
  const needsBusinessResolve = !businessId;
1559
1461
  const needsCartResolve = !cartId;
1560
1462
  if (!needsBusinessResolve && !needsCartResolve) {
@@ -1622,11 +1524,10 @@ function CimplifyCheckout({
1622
1524
  return () => {
1623
1525
  cancelled = true;
1624
1526
  };
1625
- }, [businessId, cartId, client, isDemoCheckout]);
1527
+ }, [businessId, cartId, client]);
1626
1528
  useEffect(() => {
1627
1529
  return () => {
1628
1530
  isMountedRef.current = false;
1629
- demoRunRef.current += 1;
1630
1531
  activeCheckoutRef.current?.abort();
1631
1532
  activeCheckoutRef.current = null;
1632
1533
  };
@@ -1643,42 +1544,6 @@ function CimplifyCheckout({
1643
1544
  setErrorMessage(null);
1644
1545
  setIsSubmitting(true);
1645
1546
  emitStatus("preparing", { display_text: statusToLabel("preparing") });
1646
- if (isDemoCheckout) {
1647
- const runId = demoRunRef.current + 1;
1648
- demoRunRef.current = runId;
1649
- const wait = async (ms) => {
1650
- await new Promise((resolve) => setTimeout(resolve, ms));
1651
- return isMountedRef.current && runId === demoRunRef.current;
1652
- };
1653
- try {
1654
- if (!await wait(400)) return;
1655
- emitStatus("processing", { display_text: statusToLabel("processing") });
1656
- if (!await wait(900)) return;
1657
- emitStatus("polling", { display_text: statusToLabel("polling") });
1658
- if (!await wait(1200)) return;
1659
- const result = {
1660
- success: true,
1661
- order: {
1662
- id: `ord_demo_${Date.now()}`,
1663
- order_number: `DEMO-${Math.random().toString(36).slice(2, 8).toUpperCase()}`,
1664
- status: "confirmed",
1665
- total: "0.00",
1666
- currency: "USD"
1667
- }
1668
- };
1669
- emitStatus("success", {
1670
- order_id: result.order?.id,
1671
- order_number: result.order?.order_number,
1672
- display_text: statusToLabel("success")
1673
- });
1674
- onComplete(result);
1675
- } finally {
1676
- if (isMountedRef.current && runId === demoRunRef.current) {
1677
- setIsSubmitting(false);
1678
- }
1679
- }
1680
- return;
1681
- }
1682
1547
  if (!elementsRef.current) {
1683
1548
  const message = "Checkout is still initializing. Please try again.";
1684
1549
  setErrorMessage(message);
@@ -1713,7 +1578,7 @@ function CimplifyCheckout({
1713
1578
  }
1714
1579
  });
1715
1580
  useEffect(() => {
1716
- if (isDemoCheckout || !resolvedBusinessId) {
1581
+ if (!resolvedBusinessId) {
1717
1582
  elementsRef.current = null;
1718
1583
  return;
1719
1584
  }
@@ -1754,7 +1619,6 @@ function CimplifyCheckout({
1754
1619
  }, [
1755
1620
  client,
1756
1621
  resolvedBusinessId,
1757
- isDemoCheckout,
1758
1622
  resolvedOrderTypes,
1759
1623
  resolvedDefaultOrderType,
1760
1624
  submitLabel
@@ -1770,11 +1634,11 @@ function CimplifyCheckout({
1770
1634
  if (isInitializing) {
1771
1635
  return /* @__PURE__ */ jsx("div", { className, "data-cimplify-checkout": "", children: /* @__PURE__ */ jsx("p", { "data-cimplify-status": "", style: { fontSize: 13, color: colors.textSecondary }, children: "Preparing checkout..." }) });
1772
1636
  }
1773
- if (!isDemoCheckout && (!resolvedBusinessId || !resolvedCartId)) {
1637
+ if (!resolvedBusinessId || !resolvedCartId) {
1774
1638
  return /* @__PURE__ */ jsx("div", { className, "data-cimplify-checkout": "", children: /* @__PURE__ */ jsx("p", { "data-cimplify-error": "", style: { fontSize: 13, color: colors.error }, children: errorMessage || "Unable to initialize checkout. Please refresh and try again." }) });
1775
1639
  }
1776
1640
  return /* @__PURE__ */ jsxs("div", { className, "data-cimplify-checkout": "", children: [
1777
- isTestMode && !isDemoCheckout && /* @__PURE__ */ jsx(
1641
+ isTestMode && /* @__PURE__ */ jsx(
1778
1642
  "p",
1779
1643
  {
1780
1644
  "data-cimplify-test-mode": "",
@@ -1787,7 +1651,7 @@ function CimplifyCheckout({
1787
1651
  children: "Test mode - no real charges"
1788
1652
  }
1789
1653
  ),
1790
- /* @__PURE__ */ jsx("div", { "data-cimplify-section": "checkout", children: /* @__PURE__ */ jsx("div", { ref: isDemoCheckout ? void 0 : checkoutMountRef }) }),
1654
+ /* @__PURE__ */ jsx("div", { "data-cimplify-section": "checkout", children: /* @__PURE__ */ jsx("div", { ref: checkoutMountRef }) }),
1791
1655
  status && /* @__PURE__ */ jsx("p", { "data-cimplify-status": "", style: { marginTop: SPACE.sm, fontSize: 13, color: colors.textSecondary }, children: statusText || statusToLabel(status) }),
1792
1656
  errorMessage && /* @__PURE__ */ jsx("p", { "data-cimplify-error": "", style: { marginTop: SPACE.sm, fontSize: 13, color: colors.error }, children: errorMessage })
1793
1657
  ] });
package/dist/server.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CimplifyClient } from './client-G2WCoxv2.mjs';
2
- export { aN as Result } from './client-G2WCoxv2.mjs';
1
+ import { C as CimplifyClient } from './client-BZZK1txR.mjs';
2
+ export { aN as Result } from './client-BZZK1txR.mjs';
3
3
  export { ap as Category, h as CimplifyError, ar as Collection, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.mjs';
4
4
  import './payment-9L_-GWqQ.mjs';
5
5
 
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CimplifyClient } from './client-QVINYu1X.js';
2
- export { aN as Result } from './client-QVINYu1X.js';
1
+ import { C as CimplifyClient } from './client-B8tJnOde.js';
2
+ export { aN as Result } from './client-B8tJnOde.js';
3
3
  export { ap as Category, h as CimplifyError, ar as Collection, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.js';
4
4
  import './payment-_e99nSRj.js';
5
5
 
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkZ2MLAIID_js = require('./chunk-Z2MLAIID.js');
4
- require('./chunk-7ZACMER7.js');
3
+ var chunkCYGLTD7D_js = require('./chunk-CYGLTD7D.js');
4
+ require('./chunk-DR4UPU6P.js');
5
5
  require('./chunk-6RP6OPYO.js');
6
6
  var chunkTKOTACKZ_js = require('./chunk-TKOTACKZ.js');
7
7
  var react = require('react');
@@ -19,7 +19,7 @@ function readEnv(...keys) {
19
19
  var getServerClient = react.cache((opts = {}) => {
20
20
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? DEFAULT_DEV_URL;
21
21
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
22
- const client = chunkZ2MLAIID_js.createCimplifyClient({
22
+ const client = chunkCYGLTD7D_js.createCimplifyClient({
23
23
  baseUrl,
24
24
  publicKey,
25
25
  suppressPublicKeyWarning: true
package/dist/server.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { createCimplifyClient } from './chunk-WUIERJ6J.mjs';
2
- import './chunk-CKRMA5F7.mjs';
1
+ import { createCimplifyClient } from './chunk-MBR2DBEN.mjs';
2
+ import './chunk-OFNVLUH4.mjs';
3
3
  import './chunk-XY2DFX5K.mjs';
4
4
  export { CimplifyError } from './chunk-Z2AYLZDF.mjs';
5
5
  import { cache } from 'react';
@@ -1,8 +1,8 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-CT9NwIDX.mjs';
2
+ import { T as TestClientHandle } from '../client-BqCAm5vI.mjs';
3
3
  import { C as CreateAppOptions } from '../server-BgccqOLT.mjs';
4
4
  export { S as SeedName } from '../server-BgccqOLT.mjs';
5
- import '../client-G2WCoxv2.mjs';
5
+ import '../client-BZZK1txR.mjs';
6
6
  import '../product-C-xLzh7Q.mjs';
7
7
  import '../payment-9L_-GWqQ.mjs';
8
8
  import 'hono';
@@ -1,8 +1,8 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-B76ZNW5r.js';
2
+ import { T as TestClientHandle } from '../client-BdbvMtOU.js';
3
3
  import { C as CreateAppOptions } from '../server-72rzvJ4Y.js';
4
4
  export { S as SeedName } from '../server-72rzvJ4Y.js';
5
- import '../client-QVINYu1X.js';
5
+ import '../client-B8tJnOde.js';
6
6
  import '../product-C-xLzh7Q.js';
7
7
  import '../payment-_e99nSRj.js';
8
8
  import 'hono';
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkTW4OFRWV_js = require('../chunk-TW4OFRWV.js');
4
- require('../chunk-Z2MLAIID.js');
5
- require('../chunk-7ZACMER7.js');
3
+ var chunkD22UVSFN_js = require('../chunk-D22UVSFN.js');
4
+ require('../chunk-CYGLTD7D.js');
5
+ require('../chunk-DR4UPU6P.js');
6
6
  require('../chunk-6RP6OPYO.js');
7
7
  require('../chunk-GEWFWQYK.js');
8
8
  require('../chunk-TKOTACKZ.js');
@@ -19,11 +19,11 @@ var PLACEHOLDER_PHRASES = [
19
19
  function createBrandSuite(opts) {
20
20
  vitest.describe(opts.label ?? "brand schema", () => {
21
21
  vitest.it("conforms to the Cimplify brand contract", () => {
22
- vitest.expect(() => chunkTW4OFRWV_js.assertBrand(opts.brand)).not.toThrow();
22
+ vitest.expect(() => chunkD22UVSFN_js.assertBrand(opts.brand)).not.toThrow();
23
23
  });
24
24
  vitest.it("declares a known mock seed", () => {
25
25
  const b = opts.brand;
26
- vitest.expect(chunkTW4OFRWV_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
26
+ vitest.expect(chunkD22UVSFN_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
27
27
  });
28
28
  vitest.it("has no placeholder copy left in", () => {
29
29
  const offenders = [];
@@ -55,7 +55,7 @@ ${msg}`);
55
55
  vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
56
56
  });
57
57
  vitest.it("zod-parses cleanly", () => {
58
- const result = chunkTW4OFRWV_js.BrandSchema.safeParse(opts.brand);
58
+ const result = chunkD22UVSFN_js.BrandSchema.safeParse(opts.brand);
59
59
  if (!result.success) {
60
60
  throw new Error(
61
61
  "Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
@@ -70,23 +70,23 @@ function createCartFlowSuite(opts = {}) {
70
70
  vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
71
71
  let h;
72
72
  vitest.beforeEach(() => {
73
- h = chunkTW4OFRWV_js.createTestClient(opts);
73
+ h = chunkD22UVSFN_js.createTestClient(opts);
74
74
  });
75
75
  vitest.afterEach(() => h.dispose());
76
76
  vitest.it("starts with an empty cart matching the canonical shape", async () => {
77
77
  const res = await h.client.cart.get();
78
78
  vitest.expect(res.ok).toBe(true);
79
79
  if (!res.ok) return;
80
- vitest.expect(() => chunkTW4OFRWV_js.assertCart(res.value)).not.toThrow();
80
+ vitest.expect(() => chunkD22UVSFN_js.assertCart(res.value)).not.toThrow();
81
81
  vitest.expect(res.value.items).toHaveLength(0);
82
82
  });
83
83
  vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
84
- const { product, variantId } = await chunkTW4OFRWV_js.fixtures.addFirstProduct(h.client);
84
+ const { product, variantId } = await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
85
85
  vitest.expect(product.id).toBeTruthy();
86
86
  const get = await h.client.cart.get();
87
87
  vitest.expect(get.ok).toBe(true);
88
88
  if (!get.ok) return;
89
- vitest.expect(() => chunkTW4OFRWV_js.assertCart(get.value)).not.toThrow();
89
+ vitest.expect(() => chunkD22UVSFN_js.assertCart(get.value)).not.toThrow();
90
90
  vitest.expect(get.value.items).toHaveLength(1);
91
91
  vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
92
92
  if (variantId) {
@@ -97,8 +97,8 @@ function createCartFlowSuite(opts = {}) {
97
97
  vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
98
98
  });
99
99
  vitest.it("dedupes by line_key when adding the same product twice", async () => {
100
- await chunkTW4OFRWV_js.fixtures.addFirstProduct(h.client);
101
- await chunkTW4OFRWV_js.fixtures.addFirstProduct(h.client);
100
+ await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
101
+ await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
102
102
  const res = await h.client.cart.get();
103
103
  vitest.expect(res.ok).toBe(true);
104
104
  if (!res.ok) return;
@@ -106,7 +106,7 @@ function createCartFlowSuite(opts = {}) {
106
106
  vitest.expect(res.value.items[0]?.quantity).toBe(2);
107
107
  });
108
108
  vitest.it("removes items and zeroes the subtotal", async () => {
109
- await chunkTW4OFRWV_js.fixtures.addFirstProduct(h.client);
109
+ await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
110
110
  const before = await h.client.cart.get();
111
111
  if (!before.ok) throw before.error;
112
112
  const itemId = before.value.items[0]?.id;
@@ -132,28 +132,28 @@ function createContractSuite(opts = {}) {
132
132
  vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
133
133
  let h;
134
134
  vitest.beforeEach(() => {
135
- h = chunkTW4OFRWV_js.createTestClient(opts);
135
+ h = chunkD22UVSFN_js.createTestClient(opts);
136
136
  });
137
137
  vitest.afterEach(() => h.dispose());
138
138
  vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
139
- const result = chunkTW4OFRWV_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
139
+ const result = chunkD22UVSFN_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
140
140
  vitest.expect(result.success).toBe(true);
141
141
  });
142
142
  vitest.it("AddItemPayload schema rejects negative quantity", () => {
143
- const result = chunkTW4OFRWV_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
143
+ const result = chunkD22UVSFN_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
144
144
  vitest.expect(result.success).toBe(false);
145
145
  });
146
146
  vitest.it("AddItemPayload schema rejects empty item_id", () => {
147
- const result = chunkTW4OFRWV_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
147
+ const result = chunkD22UVSFN_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
148
148
  vitest.expect(result.success).toBe(false);
149
149
  });
150
150
  vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
151
- const { product } = await chunkTW4OFRWV_js.fixtures.addFirstProduct(h.client);
151
+ const { product } = await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
152
152
  const get = await h.client.cart.get();
153
153
  if (!get.ok) throw get.error;
154
154
  vitest.expect(get.value.items.length).toBeGreaterThan(0);
155
155
  for (const item of get.value.items) {
156
- const result = chunkTW4OFRWV_js.CartItemSchema.safeParse(item);
156
+ const result = chunkD22UVSFN_js.CartItemSchema.safeParse(item);
157
157
  if (!result.success) {
158
158
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
159
159
  throw new Error(`Cart item shape mismatch for ${product.name}:
@@ -163,19 +163,19 @@ ${issues}`);
163
163
  }
164
164
  });
165
165
  vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
166
- await chunkTW4OFRWV_js.fixtures.addFirstProduct(h.client);
166
+ await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
167
167
  const cartRes = await h.client.cart.get();
168
168
  if (!cartRes.ok) throw cartRes.error;
169
169
  const checkout = await h.client.checkout.process({
170
170
  cart_id: cartRes.value.id,
171
- customer: chunkTW4OFRWV_js.fixtures.customer(),
171
+ customer: chunkD22UVSFN_js.fixtures.customer(),
172
172
  order_type: "delivery",
173
173
  payment_method: "mobile_money",
174
174
  mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
175
175
  });
176
176
  vitest.expect(checkout.ok).toBe(true);
177
177
  if (!checkout.ok) return;
178
- const result = chunkTW4OFRWV_js.CheckoutResponseSchema.safeParse(checkout.value);
178
+ const result = chunkD22UVSFN_js.CheckoutResponseSchema.safeParse(checkout.value);
179
179
  if (!result.success) {
180
180
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
181
181
  throw new Error(`CheckoutResponse shape mismatch:
@@ -1,6 +1,6 @@
1
- import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-6HYKWYUF.mjs';
2
- import '../chunk-WUIERJ6J.mjs';
3
- import '../chunk-CKRMA5F7.mjs';
1
+ import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-24FK7VFL.mjs';
2
+ import '../chunk-MBR2DBEN.mjs';
3
+ import '../chunk-OFNVLUH4.mjs';
4
4
  import '../chunk-XY2DFX5K.mjs';
5
5
  import '../chunk-632JEJUS.mjs';
6
6
  import '../chunk-Z2AYLZDF.mjs';
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { $ZodType } from 'zod/v4/core';
3
- export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-CT9NwIDX.mjs';
4
- import './client-G2WCoxv2.mjs';
3
+ export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-BqCAm5vI.mjs';
4
+ import './client-BZZK1txR.mjs';
5
5
  import './product-C-xLzh7Q.mjs';
6
6
  import './payment-9L_-GWqQ.mjs';
7
7
  import './server-BgccqOLT.mjs';