@cimplify/sdk 0.53.0 → 0.55.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.
Files changed (43) hide show
  1. package/dist/advanced.d.mts +1 -1
  2. package/dist/advanced.d.ts +1 -1
  3. package/dist/advanced.js +20 -20
  4. package/dist/advanced.mjs +1 -1
  5. package/dist/{chunk-EJUKGJTZ.js → chunk-6W3AH4QW.js} +2 -2
  6. package/dist/{chunk-NEK7CVE2.mjs → chunk-F4WS3OIF.mjs} +1 -1
  7. package/dist/{chunk-B3Y4C4A7.mjs → chunk-I4IXPQIX.mjs} +7 -4
  8. package/dist/{chunk-YJLOOC3L.js → chunk-JGBDWEPJ.js} +7 -4
  9. package/dist/chunk-JYPLT56O.js +272 -0
  10. package/dist/{chunk-IJ32BXKZ.js → chunk-MW7ICTVK.js} +35 -35
  11. package/dist/{chunk-6QZQQRBB.mjs → chunk-SQ7U3BWY.mjs} +1 -1
  12. package/dist/chunk-XYI4NXWG.mjs +259 -0
  13. package/dist/{client-D1Gknspz.d.mts → client-Bhvlelij.d.mts} +1 -1
  14. package/dist/{client-Bj2apl_y.d.mts → client-DKg-5OWu.d.mts} +16 -1
  15. package/dist/{client-306peWZ0.d.ts → client-Dfg_hmkP.d.ts} +16 -1
  16. package/dist/{client-C2bKMy5g.d.ts → client-DlGJqSDd.d.ts} +1 -1
  17. package/dist/index.d.mts +18 -3
  18. package/dist/index.d.ts +18 -3
  19. package/dist/index.js +160 -72
  20. package/dist/index.mjs +91 -3
  21. package/dist/react.d.mts +52 -5
  22. package/dist/react.d.ts +52 -5
  23. package/dist/react.js +592 -512
  24. package/dist/react.mjs +136 -58
  25. package/dist/server.d.mts +59 -35
  26. package/dist/server.d.ts +59 -35
  27. package/dist/server.js +160 -79
  28. package/dist/server.mjs +153 -78
  29. package/dist/{ads-C2c2Aald.d.mts → sign-in-TL01-awQ.d.mts} +17 -1
  30. package/dist/{ads-C2c2Aald.d.ts → sign-in-TL01-awQ.d.ts} +17 -1
  31. package/dist/styles.css +1 -1
  32. package/dist/testing/suite.d.mts +2 -2
  33. package/dist/testing/suite.d.ts +2 -2
  34. package/dist/testing/suite.js +22 -22
  35. package/dist/testing/suite.mjs +3 -3
  36. package/dist/testing.d.mts +2 -2
  37. package/dist/testing.d.ts +2 -2
  38. package/dist/testing.js +78 -78
  39. package/dist/testing.mjs +4 -4
  40. package/package.json +2 -1
  41. package/registry/account.json +1 -1
  42. package/dist/chunk-MN4PNKJA.js +0 -129
  43. package/dist/chunk-NRDRVZ62.mjs +0 -119
package/dist/react.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT } from './chunk-NRDRVZ62.mjs';
3
- export { getVariantDisplayName } from './chunk-NRDRVZ62.mjs';
4
- import { createCimplifyClient } from './chunk-6QZQQRBB.mjs';
5
- import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-B3Y4C4A7.mjs';
2
+ import { DURATION_UNIT, startSignIn, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT } from './chunk-XYI4NXWG.mjs';
3
+ export { getVariantDisplayName } from './chunk-XYI4NXWG.mjs';
4
+ import { createCimplifyClient } from './chunk-SQ7U3BWY.mjs';
5
+ import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-I4IXPQIX.mjs';
6
6
  import { formatPrice, parsePrice, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-TD3AY34U.mjs';
7
7
  import { isSupportedCurrency } from './chunk-AMZXALF6.mjs';
8
8
  import './chunk-3G6RQLXK.mjs';
9
- import React10, { createContext, useRef, useState, useCallback, useEffect, useContext, useMemo, useId, useSyncExternalStore } from 'react';
9
+ import React11, { createContext, useRef, useState, useCallback, useEffect, useContext, useMemo, useId, useSyncExternalStore } from 'react';
10
10
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
11
11
  import { clsx } from 'clsx';
12
12
  import { twMerge } from 'tailwind-merge';
@@ -1426,14 +1426,14 @@ function CimplifyCheckout({
1426
1426
  const resolvedCartRef = useRef(resolvedCart);
1427
1427
  resolvedCartRef.current = resolvedCart;
1428
1428
  const isDark = appearance?.theme === "dark";
1429
- const emitStatus = React10.useEffectEvent(
1429
+ const emitStatus = React11.useEffectEvent(
1430
1430
  (nextStatus, context = {}) => {
1431
1431
  setStatus(nextStatus);
1432
1432
  setStatusText(context.display_text || "");
1433
1433
  onStatusChange?.(nextStatus, context);
1434
1434
  }
1435
1435
  );
1436
- const fireError = React10.useEffectEvent(
1436
+ const fireError = React11.useEffectEvent(
1437
1437
  (error) => {
1438
1438
  onError?.(error);
1439
1439
  }
@@ -1529,7 +1529,7 @@ function CimplifyCheckout({
1529
1529
  activeCheckoutRef.current = null;
1530
1530
  };
1531
1531
  }, []);
1532
- const handleSubmit = React10.useEffectEvent(async () => {
1532
+ const handleSubmit = React11.useEffectEvent(async () => {
1533
1533
  if (isSubmitting || isInitializing || !resolvedCartId) {
1534
1534
  if (!resolvedCartId && !isInitializing) {
1535
1535
  const message = "Your cart is empty. Add items before checkout.";
@@ -1661,6 +1661,8 @@ function CimplifyAccount({
1661
1661
  client: clientProp,
1662
1662
  linkUrl,
1663
1663
  section,
1664
+ businessId: businessIdProp,
1665
+ merchantName,
1664
1666
  appearance,
1665
1667
  onLogout,
1666
1668
  className
@@ -1668,18 +1670,16 @@ function CimplifyAccount({
1668
1670
  const context = useOptionalCimplify();
1669
1671
  const client = clientProp ?? context?.client;
1670
1672
  const resolvedLinkUrl = linkUrl || DEFAULT_LINK_URL;
1673
+ const resolvedBusinessId = businessIdProp || client?.getBusinessId?.() || "";
1671
1674
  const iframeRef = useRef(null);
1672
1675
  const [height, setHeight] = useState(400);
1673
1676
  const [isReady, setIsReady] = useState(false);
1674
1677
  const iframeSrc = useMemo(() => {
1675
1678
  const path = section ? `/elements/account/${section}` : "/elements/account";
1676
1679
  const url = new URL(path, resolvedLinkUrl);
1677
- if (client) {
1678
- const businessId = client.getBusinessId?.() ?? "";
1679
- if (businessId) url.searchParams.set("businessId", businessId);
1680
- }
1680
+ if (resolvedBusinessId) url.searchParams.set("businessId", resolvedBusinessId);
1681
1681
  return url.toString();
1682
- }, [resolvedLinkUrl, section, client]);
1682
+ }, [resolvedLinkUrl, section, resolvedBusinessId]);
1683
1683
  useEffect(() => {
1684
1684
  function handleMessage(event) {
1685
1685
  if (!event.data || typeof event.data !== "object") return;
@@ -1715,7 +1715,9 @@ function CimplifyAccount({
1715
1715
  {
1716
1716
  type: "init",
1717
1717
  token: token ?? void 0,
1718
- appearance: appearance ?? void 0
1718
+ appearance: appearance ?? void 0,
1719
+ businessId: resolvedBusinessId || void 0,
1720
+ merchantName: merchantName ?? void 0
1719
1721
  },
1720
1722
  resolvedLinkUrl
1721
1723
  );
@@ -1748,6 +1750,82 @@ function CimplifyAccount({
1748
1750
  }
1749
1751
  );
1750
1752
  }
1753
+ var BASE_CLASSES = "inline-flex items-center justify-center gap-2 font-medium text-sm rounded-md transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed";
1754
+ var VARIANT_CLASSES = {
1755
+ primary: "bg-emerald-600 text-white hover:bg-emerald-700 px-4 py-2.5 border border-transparent",
1756
+ outline: "bg-white text-zinc-900 hover:bg-zinc-50 px-4 py-2.5 border border-zinc-300",
1757
+ dark: "bg-zinc-900 text-white hover:bg-zinc-800 px-4 py-2.5 border border-zinc-800",
1758
+ text: "bg-transparent text-emerald-700 hover:text-emerald-800 px-2 py-1"
1759
+ };
1760
+ function CimplifySignInButton({
1761
+ variant = "primary",
1762
+ label,
1763
+ className,
1764
+ disabled,
1765
+ fullWidth,
1766
+ onSuccess,
1767
+ onError,
1768
+ ...signInOpts
1769
+ }) {
1770
+ const [busy, setBusy] = useState(false);
1771
+ const onClick = useCallback(async () => {
1772
+ if (busy || disabled) return;
1773
+ setBusy(true);
1774
+ await startSignIn({
1775
+ ...signInOpts,
1776
+ onSuccess: () => {
1777
+ setBusy(false);
1778
+ onSuccess?.();
1779
+ },
1780
+ onError: (e) => {
1781
+ setBusy(false);
1782
+ onError?.(e);
1783
+ }
1784
+ });
1785
+ }, [busy, disabled, signInOpts, onSuccess, onError]);
1786
+ return /* @__PURE__ */ jsxs(
1787
+ "button",
1788
+ {
1789
+ type: "button",
1790
+ onClick,
1791
+ disabled: disabled || busy,
1792
+ className: cn(BASE_CLASSES, VARIANT_CLASSES[variant], fullWidth && "w-full", className),
1793
+ "data-cimplify-signin": true,
1794
+ children: [
1795
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-flex", style: { width: 16, height: 16 }, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.4, strokeLinecap: "round", strokeLinejoin: "round", children: [
1796
+ /* @__PURE__ */ jsx("path", { d: "M10 13.5a4 4 0 0 0 5.6 0l3-3a4 4 0 0 0-5.6-5.6L11.5 6.4" }),
1797
+ /* @__PURE__ */ jsx("path", { d: "M14 10.5a4 4 0 0 0-5.6 0l-3 3a4 4 0 0 0 5.6 5.6l1.5-1.5" })
1798
+ ] }) }),
1799
+ label ?? (busy ? "Signing in\u2026" : "Continue with Cimplify")
1800
+ ]
1801
+ }
1802
+ );
1803
+ }
1804
+ function useCimplifySession(options) {
1805
+ const sessionUri = options?.sessionUri ?? "/auth/session";
1806
+ const [session, setSession] = useState(null);
1807
+ const [loading, setLoading] = useState(true);
1808
+ const fetchSession = useCallback(async () => {
1809
+ setLoading(true);
1810
+ try {
1811
+ const res = await fetch(sessionUri, { credentials: "include" });
1812
+ if (!res.ok) {
1813
+ setSession(null);
1814
+ return;
1815
+ }
1816
+ const body = await res.json().catch(() => null);
1817
+ setSession(body?.sub ? body : null);
1818
+ } catch {
1819
+ setSession(null);
1820
+ } finally {
1821
+ setLoading(false);
1822
+ }
1823
+ }, [sessionUri]);
1824
+ useEffect(() => {
1825
+ void fetchSession();
1826
+ }, [fetchSession]);
1827
+ return { session, loading, refresh: fetchSession };
1828
+ }
1751
1829
  function Price({ amount, currency, className, prefix }) {
1752
1830
  const context = useOptionalCimplify();
1753
1831
  const resolvedCurrency = currency ?? context?.displayCurrency ?? "USD";
@@ -5606,7 +5684,7 @@ function FileUploadInput({
5606
5684
  onFileUpload,
5607
5685
  classNames
5608
5686
  }) {
5609
- const [isUploading, setIsUploading] = React10.useState(false);
5687
+ const [isUploading, setIsUploading] = React11.useState(false);
5610
5688
  const fileUrl = typeof value === "string" ? value : void 0;
5611
5689
  const acceptedFormats = field.validation?.accepted_formats;
5612
5690
  const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type === INPUT_FIELD_TYPE.Image ? "image/*" : void 0;
@@ -5756,22 +5834,22 @@ function AddressInput({
5756
5834
  }) {
5757
5835
  const clientContext = useOptionalCimplifyClient();
5758
5836
  const addr = value && typeof value === "object" ? value : null;
5759
- const [inputText, setInputText] = React10.useState(addr?.formatted_address ?? "");
5760
- const [suggestions, setSuggestions] = React10.useState([]);
5761
- const [isOpen, setIsOpen] = React10.useState(false);
5762
- const [highlightedIndex, setHighlightedIndex] = React10.useState(-1);
5763
- const debounceRef = React10.useRef(null);
5764
- const seqRef = React10.useRef(0);
5765
- const sessionTokenRef = React10.useRef(createSessionToken());
5766
- const blurTimeoutRef = React10.useRef(null);
5767
- React10.useEffect(() => {
5837
+ const [inputText, setInputText] = React11.useState(addr?.formatted_address ?? "");
5838
+ const [suggestions, setSuggestions] = React11.useState([]);
5839
+ const [isOpen, setIsOpen] = React11.useState(false);
5840
+ const [highlightedIndex, setHighlightedIndex] = React11.useState(-1);
5841
+ const debounceRef = React11.useRef(null);
5842
+ const seqRef = React11.useRef(0);
5843
+ const sessionTokenRef = React11.useRef(createSessionToken());
5844
+ const blurTimeoutRef = React11.useRef(null);
5845
+ React11.useEffect(() => {
5768
5846
  return () => {
5769
5847
  if (debounceRef.current) clearTimeout(debounceRef.current);
5770
5848
  if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
5771
5849
  seqRef.current += 1;
5772
5850
  };
5773
5851
  }, []);
5774
- const fetchSuggestions = React10.useCallback(async (query) => {
5852
+ const fetchSuggestions = React11.useCallback(async (query) => {
5775
5853
  const client = clientContext?.client;
5776
5854
  if (!client || query.length < 3) {
5777
5855
  setSuggestions([]);
@@ -5795,7 +5873,7 @@ function AddressInput({
5795
5873
  if (debounceRef.current) clearTimeout(debounceRef.current);
5796
5874
  debounceRef.current = setTimeout(() => void fetchSuggestions(nextValue.trim()), 300);
5797
5875
  };
5798
- const selectSuggestion = React10.useCallback(async (suggestion) => {
5876
+ const selectSuggestion = React11.useCallback(async (suggestion) => {
5799
5877
  if (debounceRef.current) clearTimeout(debounceRef.current);
5800
5878
  if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
5801
5879
  const fallback = suggestion.description.split(",")[0]?.trim() || suggestion.description;
@@ -5898,22 +5976,22 @@ function LocationInput({
5898
5976
  }) {
5899
5977
  const clientContext = useOptionalCimplifyClient();
5900
5978
  const loc = value && typeof value === "object" ? value : null;
5901
- const [inputText, setInputText] = React10.useState(loc?.label ?? "");
5902
- const [suggestions, setSuggestions] = React10.useState([]);
5903
- const [isOpen, setIsOpen] = React10.useState(false);
5904
- const [highlightedIndex, setHighlightedIndex] = React10.useState(-1);
5905
- const debounceRef = React10.useRef(null);
5906
- const seqRef = React10.useRef(0);
5907
- const sessionTokenRef = React10.useRef(createSessionToken());
5908
- const blurTimeoutRef = React10.useRef(null);
5909
- React10.useEffect(() => {
5979
+ const [inputText, setInputText] = React11.useState(loc?.label ?? "");
5980
+ const [suggestions, setSuggestions] = React11.useState([]);
5981
+ const [isOpen, setIsOpen] = React11.useState(false);
5982
+ const [highlightedIndex, setHighlightedIndex] = React11.useState(-1);
5983
+ const debounceRef = React11.useRef(null);
5984
+ const seqRef = React11.useRef(0);
5985
+ const sessionTokenRef = React11.useRef(createSessionToken());
5986
+ const blurTimeoutRef = React11.useRef(null);
5987
+ React11.useEffect(() => {
5910
5988
  return () => {
5911
5989
  if (debounceRef.current) clearTimeout(debounceRef.current);
5912
5990
  if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
5913
5991
  seqRef.current += 1;
5914
5992
  };
5915
5993
  }, []);
5916
- const fetchSuggestions = React10.useCallback(async (query) => {
5994
+ const fetchSuggestions = React11.useCallback(async (query) => {
5917
5995
  const client = clientContext?.client;
5918
5996
  if (!client || query.length < 3) {
5919
5997
  setSuggestions([]);
@@ -5937,7 +6015,7 @@ function LocationInput({
5937
6015
  if (debounceRef.current) clearTimeout(debounceRef.current);
5938
6016
  debounceRef.current = setTimeout(() => void fetchSuggestions(nextValue.trim()), 300);
5939
6017
  };
5940
- const selectSuggestion = React10.useCallback(async (suggestion) => {
6018
+ const selectSuggestion = React11.useCallback(async (suggestion) => {
5941
6019
  if (debounceRef.current) clearTimeout(debounceRef.current);
5942
6020
  if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
5943
6021
  const label = suggestion.description.split(",")[0]?.trim() || suggestion.description;
@@ -6026,8 +6104,8 @@ function PhoneInput({
6026
6104
  inputClass
6027
6105
  }) {
6028
6106
  const phone = value && typeof value === "object" ? value : null;
6029
- const [code, setCode] = React10.useState(phone?.country_code ?? "+1");
6030
- const [number, setNumber] = React10.useState(phone?.number ?? "");
6107
+ const [code, setCode] = React11.useState(phone?.country_code ?? "+1");
6108
+ const [number, setNumber] = React11.useState(phone?.number ?? "");
6031
6109
  const update = (nextCode, nextNumber) => {
6032
6110
  setCode(nextCode);
6033
6111
  setNumber(nextNumber);
@@ -6072,8 +6150,8 @@ function SignatureInput({
6072
6150
  classNames
6073
6151
  }) {
6074
6152
  const sig = value && typeof value === "object" ? value : null;
6075
- const canvasRef = React10.useRef(null);
6076
- const isDrawing = React10.useRef(false);
6153
+ const canvasRef = React11.useRef(null);
6154
+ const isDrawing = React11.useRef(false);
6077
6155
  const getCtx = () => canvasRef.current?.getContext("2d") ?? null;
6078
6156
  const startDraw = (e) => {
6079
6157
  const ctx = getCtx();
@@ -7105,7 +7183,7 @@ function ProductModel3D({
7105
7183
  "data-cimplify-product-model-3d": true,
7106
7184
  className,
7107
7185
  style: { position: "relative", overflow: "hidden", ...ASPECT_STYLES3[aspectRatio] },
7108
- children: ready ? React10.createElement("model-viewer", {
7186
+ children: ready ? React11.createElement("model-viewer", {
7109
7187
  src,
7110
7188
  "ios-src": iosSrc,
7111
7189
  alt,
@@ -7116,12 +7194,12 @@ function ProductModel3D({
7116
7194
  "auto-rotate": autoRotate || void 0,
7117
7195
  "shadow-intensity": "1",
7118
7196
  style: { width: "100%", height: "100%", backgroundColor: "transparent" }
7119
- }) : poster ? React10.createElement("img", {
7197
+ }) : poster ? React11.createElement("img", {
7120
7198
  src: poster,
7121
7199
  alt: alt ?? "",
7122
7200
  "data-cimplify-product-model-3d-loading": true,
7123
7201
  style: { width: "100%", height: "100%", objectFit: "cover" }
7124
- }) : React10.createElement("div", {
7202
+ }) : React11.createElement("div", {
7125
7203
  "data-cimplify-product-model-3d-loading": true,
7126
7204
  style: { width: "100%", height: "100%", backgroundColor: "var(--muted, #f3f4f6)" }
7127
7205
  })
@@ -8882,13 +8960,13 @@ function ProductGrid({
8882
8960
  className,
8883
8961
  classNames
8884
8962
  }) {
8885
- const rawId = React10.useId();
8963
+ const rawId = React11.useId();
8886
8964
  const gridId = `cimplify-grid-${rawId.replace(/:/g, "")}`;
8887
8965
  const sm = columns?.sm ?? 1;
8888
8966
  const md = columns?.md ?? 2;
8889
8967
  const lg = columns?.lg ?? 3;
8890
8968
  const xl = columns?.xl ?? 4;
8891
- const css = React10.useMemo(
8969
+ const css = React11.useMemo(
8892
8970
  () => [
8893
8971
  `#${gridId}{display:grid;grid-template-columns:repeat(${sm},1fr);gap:1rem}`,
8894
8972
  `@media(min-width:768px){#${gridId}{grid-template-columns:repeat(${md},1fr)}}`,
@@ -9249,7 +9327,7 @@ function CategoryGrid({
9249
9327
  enabled: categoriesProp === void 0
9250
9328
  });
9251
9329
  const categories = categoriesProp ?? fetched;
9252
- const rawId = React10.useId();
9330
+ const rawId = React11.useId();
9253
9331
  const gridId = `cimplify-cat-grid-${rawId.replace(/:/g, "")}`;
9254
9332
  const sm = columns?.sm ?? 2;
9255
9333
  const md = columns?.md ?? 3;
@@ -9475,7 +9553,7 @@ function OrderSummary({
9475
9553
  /* @__PURE__ */ jsx("p", { children: order.delivery_address })
9476
9554
  ] }),
9477
9555
  /* @__PURE__ */ jsx("div", { "data-cimplify-order-items": true, className: classNames?.items, children: order.items.map(
9478
- (item) => renderLineItem ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderLineItem(item) }, item.id) : /* @__PURE__ */ jsxs("div", { "data-cimplify-order-line-item": true, className: classNames?.lineItem, children: [
9556
+ (item) => renderLineItem ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderLineItem(item) }, item.id) : /* @__PURE__ */ jsxs("div", { "data-cimplify-order-line-item": true, className: classNames?.lineItem, children: [
9479
9557
  /* @__PURE__ */ jsxs("div", { "data-cimplify-order-line-info": true, children: [
9480
9558
  /* @__PURE__ */ jsxs("span", { "data-cimplify-order-line-qty": true, children: [
9481
9559
  item.quantity,
@@ -10635,7 +10713,7 @@ function DefaultCatalogueLayout({
10635
10713
  /* @__PURE__ */ jsx("p", { className: "text-lg font-medium", children: "No products found" }),
10636
10714
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try adjusting your filters" })
10637
10715
  ] }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 gap-4", children: products.map(
10638
- (product) => renderCard ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
10716
+ (product) => renderCard ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
10639
10717
  ProductCard,
10640
10718
  {
10641
10719
  product,
@@ -10742,7 +10820,7 @@ function CompactCatalogueLayout({
10742
10820
  /* @__PURE__ */ jsx("p", { className: "text-lg font-medium", children: "No items found" }),
10743
10821
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try a different category or search" })
10744
10822
  ] }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 lg:grid-cols-3 gap-5", children: products.map(
10745
- (product) => renderCard ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
10823
+ (product) => renderCard ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
10746
10824
  ProductCard,
10747
10825
  {
10748
10826
  product,
@@ -10765,8 +10843,8 @@ var BUILT_IN_LAYOUTS = {
10765
10843
  ["compact" /* Compact */]: CompactCatalogueLayout
10766
10844
  };
10767
10845
  function useDebounce(value, delay) {
10768
- const [debounced, setDebounced] = React10.useState(value);
10769
- React10.useEffect(() => {
10846
+ const [debounced, setDebounced] = React11.useState(value);
10847
+ React11.useEffect(() => {
10770
10848
  const timer = setTimeout(() => setDebounced(value), delay);
10771
10849
  return () => clearTimeout(timer);
10772
10850
  }, [value, delay]);
@@ -12286,7 +12364,7 @@ function DefaultCollectionLayout({
12286
12364
  ] })
12287
12365
  ] }),
12288
12366
  filtered.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4", children: filtered.map(
12289
- (product) => renderCard ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12367
+ (product) => renderCard ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12290
12368
  ProductCard,
12291
12369
  {
12292
12370
  product,
@@ -12339,7 +12417,7 @@ function FeaturedCollectionLayout({
12339
12417
  ] })
12340
12418
  ] }),
12341
12419
  /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6", children: products.map(
12342
- (product) => renderCard ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12420
+ (product) => renderCard ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12343
12421
  ProductCard,
12344
12422
  {
12345
12423
  product,
@@ -12463,7 +12541,7 @@ function CatalogueCollectionLayout({
12463
12541
  ] })
12464
12542
  ] }),
12465
12543
  filtered.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4", children: filtered.map(
12466
- (product) => renderCard ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12544
+ (product) => renderCard ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12467
12545
  ProductCard,
12468
12546
  {
12469
12547
  product,
@@ -12843,7 +12921,7 @@ function DefaultSearchLayout({
12843
12921
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try a different search term" }),
12844
12922
  /* @__PURE__ */ jsx("button", { onClick: clear, className: "text-sm font-medium text-primary mt-4 hover:underline", children: "Clear search" })
12845
12923
  ] }) : results.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 gap-4", children: results.map(
12846
- (product) => renderCard ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12924
+ (product) => renderCard ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12847
12925
  ProductCard,
12848
12926
  {
12849
12927
  product,
@@ -12945,7 +13023,7 @@ function CompactSearchLayout({
12945
13023
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try a different search term" }),
12946
13024
  /* @__PURE__ */ jsx("button", { onClick: clear, className: "text-sm font-medium text-primary mt-4 hover:underline", children: "Clear search" })
12947
13025
  ] }) : results.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 lg:grid-cols-3 gap-5", children: results.map(
12948
- (product) => renderCard ? /* @__PURE__ */ jsx(React10.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
13026
+ (product) => renderCard ? /* @__PURE__ */ jsx(React11.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsx(
12949
13027
  ProductCard,
12950
13028
  {
12951
13029
  product,
@@ -13899,4 +13977,4 @@ function SparkleIcon({ className }) {
13899
13977
  );
13900
13978
  }
13901
13979
 
13902
- export { AccommodationCard, Ad, AdProvider, AddOnSelector, AddressElement, AuthElement, AvailabilityBadge, BillingPlanSelector, BookingCard, BookingList, BookingPage, BookingsPage, BundleProductCard, BundleProductLayout, BundleSelector, CardImage, CardShell, CardVariant, CartDrawer, CartDrawerProvider, CartPage, CartSummary, CartTemplate, CatalogueCollectionLayout, CataloguePage, CatalogueTemplate, CategoryFilter, CategoryGrid, ChatWidget, CheckoutPage, CimplifyAccount, CimplifyCheckout, CimplifyProvider, CollectionPage, CollectionTemplate, CompactCartLayout, CompactCatalogueLayout, CompactSearchLayout, CompactServiceCard, CompositeProductCard, CompositeProductLayout, CompositeSelector, CurrencySelector, CustomAttributesTable, CustomerInputFields, DatePicker, DateSlotPicker, DealBanner, DealsPage, DefaultCartLayout, DefaultCatalogueLayout, DefaultCollectionLayout, DefaultProductLayout, DefaultSearchLayout, DeliveryEstimate, DigitalProductCard, DigitalProductLayout, DiscountInput, ElementsProvider, FeaturedCollectionLayout, FoodProductCard, FoodProductLayout, InventoryBadge, LeaseServiceCard, LocationPicker, MediaGallery, MetadataStringList, OrderDetailPage, OrderHistory, OrderHistoryPage, OrderSummary, PaymentElement, Price, PriceRange, ProductCard, ProductCustomizer, ProductGrid, ProductImageGallery, ProductModel3D, ProductPage, ProductSheet, ProductTemplate, PropertiesTable, QuantitySelector, QuickAddButton, RecentlyViewed, RecommendationCarousel, RelatedProductsSection, RentalServiceCard, ResourcePicker, RetailProductCard, SaleBadge, ScheduleServiceCard, SearchInput, SearchPage, SearchTemplate, ServiceProductLayout, SessionMessageBanner, SlotPicker, SoldOutOverlay, StaffPicker, StandardServiceCard, StoreNav, StoreVideo, SubscriptionCard, TagPills, TimePicker, TwoColumnGrid, VariantSelector, VolumePricing, WholesaleProductCard, WholesaleProductLayout, WishlistButton, cn, roomToResource, useActivityState, useAds, useAttributeDefinitions, useAvailableSlots, useBillingPlans, useBookings, useBootstrap, useBundles, useCart, useCartDrawer, useCategories, useChat, useCheckout, useCimplify, useCimplifyClient, useCollection, useCollections, useDeals, useDeliveryFee, useElements, useElementsReady, useFxRate, useLocations, useOptionalCimplify, useOrder, useOrders, useProduct, useProductAvailability, useProductDeals, useProductPrice, useProductSchedules, useProducts, useProductsOnSale, usePropertyFacets, useQuote, useRecommendations, useSearch, useServiceAvailability, useServices, useSubscription, useSubscriptions, useTaxonomies, useTaxonomy, useTaxonomyPath, useValidateDiscount, useVariantSelector };
13980
+ export { AccommodationCard, Ad, AdProvider, AddOnSelector, AddressElement, AuthElement, AvailabilityBadge, BillingPlanSelector, BookingCard, BookingList, BookingPage, BookingsPage, BundleProductCard, BundleProductLayout, BundleSelector, CardImage, CardShell, CardVariant, CartDrawer, CartDrawerProvider, CartPage, CartSummary, CartTemplate, CatalogueCollectionLayout, CataloguePage, CatalogueTemplate, CategoryFilter, CategoryGrid, ChatWidget, CheckoutPage, CimplifyAccount, CimplifyCheckout, CimplifyProvider, CimplifySignInButton, CollectionPage, CollectionTemplate, CompactCartLayout, CompactCatalogueLayout, CompactSearchLayout, CompactServiceCard, CompositeProductCard, CompositeProductLayout, CompositeSelector, CurrencySelector, CustomAttributesTable, CustomerInputFields, DatePicker, DateSlotPicker, DealBanner, DealsPage, DefaultCartLayout, DefaultCatalogueLayout, DefaultCollectionLayout, DefaultProductLayout, DefaultSearchLayout, DeliveryEstimate, DigitalProductCard, DigitalProductLayout, DiscountInput, ElementsProvider, FeaturedCollectionLayout, FoodProductCard, FoodProductLayout, InventoryBadge, LeaseServiceCard, LocationPicker, MediaGallery, MetadataStringList, OrderDetailPage, OrderHistory, OrderHistoryPage, OrderSummary, PaymentElement, Price, PriceRange, ProductCard, ProductCustomizer, ProductGrid, ProductImageGallery, ProductModel3D, ProductPage, ProductSheet, ProductTemplate, PropertiesTable, QuantitySelector, QuickAddButton, RecentlyViewed, RecommendationCarousel, RelatedProductsSection, RentalServiceCard, ResourcePicker, RetailProductCard, SaleBadge, ScheduleServiceCard, SearchInput, SearchPage, SearchTemplate, ServiceProductLayout, SessionMessageBanner, SlotPicker, SoldOutOverlay, StaffPicker, StandardServiceCard, StoreNav, StoreVideo, SubscriptionCard, TagPills, TimePicker, TwoColumnGrid, VariantSelector, VolumePricing, WholesaleProductCard, WholesaleProductLayout, WishlistButton, cn, roomToResource, useActivityState, useAds, useAttributeDefinitions, useAvailableSlots, useBillingPlans, useBookings, useBootstrap, useBundles, useCart, useCartDrawer, useCategories, useChat, useCheckout, useCimplify, useCimplifyClient, useCimplifySession, useCollection, useCollections, useDeals, useDeliveryFee, useElements, useElementsReady, useFxRate, useLocations, useOptionalCimplify, useOrder, useOrders, useProduct, useProductAvailability, useProductDeals, useProductPrice, useProductSchedules, useProducts, useProductsOnSale, usePropertyFacets, useQuote, useRecommendations, useSearch, useServiceAvailability, useServices, useSubscription, useSubscriptions, useTaxonomies, useTaxonomy, useTaxonomyPath, useValidateDiscount, useVariantSelector };
package/dist/server.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import { ac as CimplifyClient } from './client-Bj2apl_y.mjs';
2
- export { J as CacheOptions, c7 as ReadRequestOptions, ct as Result } from './client-Bj2apl_y.mjs';
1
+ import { ac as CimplifyClient } from './client-DKg-5OWu.mjs';
2
+ export { J as CacheOptions, c7 as ReadRequestOptions, ct as Result } from './client-DKg-5OWu.mjs';
3
3
  export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-B_kS4Oxa.mjs';
4
+ import { JWTVerifyResult } from 'jose';
4
5
  import './payment-DVS7ZUEp.mjs';
5
6
 
6
7
  interface ServerClientOptions {
@@ -145,26 +146,26 @@ type CacheLifeDefault = typeof CACHE_LIFE_DEFAULT;
145
146
  type CacheLifeProbe = typeof CACHE_LIFE_PROBE;
146
147
 
147
148
  /** Next 16 cacheLife profile — a built-in name (`'max'`/`'hours'`/…) or `{expire: secs}`. */
148
- type RevalidateProfile$1 = string | {
149
+ type RevalidateProfile = string | {
149
150
  expire: number;
150
151
  };
151
- declare function revalidateProducts(profile?: RevalidateProfile$1): Promise<void>;
152
- declare function revalidateProduct(id: string, profile?: RevalidateProfile$1): Promise<void>;
153
- declare function revalidateCategories(profile?: RevalidateProfile$1): Promise<void>;
154
- declare function revalidateCategory(id: string, profile?: RevalidateProfile$1): Promise<void>;
155
- declare function revalidateCollections(profile?: RevalidateProfile$1): Promise<void>;
156
- declare function revalidateCollection(id: string, profile?: RevalidateProfile$1): Promise<void>;
157
- declare function revalidateBusiness(profile?: RevalidateProfile$1): Promise<void>;
158
- declare function revalidateBrand(profile?: RevalidateProfile$1): Promise<void>;
159
- declare function revalidateLocations(profile?: RevalidateProfile$1): Promise<void>;
160
- declare function revalidateLocation(id: string, profile?: RevalidateProfile$1): Promise<void>;
161
- declare function revalidatePricing(profile?: RevalidateProfile$1): Promise<void>;
162
- declare function revalidateAddOns(profile?: RevalidateProfile$1): Promise<void>;
163
- declare function revalidateAddOn(id: string, profile?: RevalidateProfile$1): Promise<void>;
164
- declare function revalidateSubscriptions(profile?: RevalidateProfile$1): Promise<void>;
165
- declare function revalidateSubscription(id: string, profile?: RevalidateProfile$1): Promise<void>;
166
- declare function revalidateStock(productId?: string, profile?: RevalidateProfile$1): Promise<void>;
167
- declare function revalidateByTag(tag: string, profile?: RevalidateProfile$1): Promise<void>;
152
+ declare function revalidateProducts(profile?: RevalidateProfile): Promise<void>;
153
+ declare function revalidateProduct(id: string, profile?: RevalidateProfile): Promise<void>;
154
+ declare function revalidateCategories(profile?: RevalidateProfile): Promise<void>;
155
+ declare function revalidateCategory(id: string, profile?: RevalidateProfile): Promise<void>;
156
+ declare function revalidateCollections(profile?: RevalidateProfile): Promise<void>;
157
+ declare function revalidateCollection(id: string, profile?: RevalidateProfile): Promise<void>;
158
+ declare function revalidateBusiness(profile?: RevalidateProfile): Promise<void>;
159
+ declare function revalidateBrand(profile?: RevalidateProfile): Promise<void>;
160
+ declare function revalidateLocations(profile?: RevalidateProfile): Promise<void>;
161
+ declare function revalidateLocation(id: string, profile?: RevalidateProfile): Promise<void>;
162
+ declare function revalidatePricing(profile?: RevalidateProfile): Promise<void>;
163
+ declare function revalidateAddOns(profile?: RevalidateProfile): Promise<void>;
164
+ declare function revalidateAddOn(id: string, profile?: RevalidateProfile): Promise<void>;
165
+ declare function revalidateSubscriptions(profile?: RevalidateProfile): Promise<void>;
166
+ declare function revalidateSubscription(id: string, profile?: RevalidateProfile): Promise<void>;
167
+ declare function revalidateStock(productId?: string, profile?: RevalidateProfile): Promise<void>;
168
+ declare function revalidateByTag(tag: string, profile?: RevalidateProfile): Promise<void>;
168
169
 
169
170
  declare function updateProducts(): Promise<void>;
170
171
  declare function updateProduct(id: string): Promise<void>;
@@ -185,20 +186,43 @@ declare function updateStock(productId?: string): Promise<void>;
185
186
  declare function updateByTag(tag: string): Promise<void>;
186
187
  declare function refreshPage(): Promise<void>;
187
188
 
188
- /** Next 16 cacheLife profile — a built-in name (`'max'`/`'hours'`/…) or `{expire: secs}`. */
189
- type RevalidateProfile = string | {
190
- expire: number;
191
- };
192
- interface RevalidateRouteOptions {
193
- /** Defaults to `process.env.CIMPLIFY_REVALIDATE_SECRET`. */
194
- secret?: string;
195
- /** Defaults to a lazy import of `next/cache.revalidateTag`. Override for tests. */
196
- revalidateTag?: (tag: string, profile: RevalidateProfile) => void;
197
- /** Defaults to `Date.now`. Override for tests. */
198
- now?: () => number;
199
- /** Profile used when the request body doesn't include one. Defaults to `'max'`. */
200
- defaultProfile?: RevalidateProfile;
189
+ interface OidcConfig {
190
+ authUrl?: string;
191
+ clientId: string;
192
+ cookieName?: string;
193
+ cookieDomain?: string;
194
+ }
195
+ interface CimplifySession {
196
+ sub: string;
197
+ name?: string;
198
+ email?: string;
199
+ emailVerified?: boolean;
200
+ phoneNumber?: string;
201
+ phoneNumberVerified?: boolean;
202
+ exp: number;
203
+ iat: number;
204
+ }
205
+ interface CodeExchangeOptions extends OidcConfig {
206
+ code: string;
207
+ codeVerifier: string;
208
+ redirectUri: string;
209
+ }
210
+ interface CodeExchangeResult {
211
+ accessToken: string;
212
+ idToken?: string;
213
+ refreshToken?: string;
214
+ expiresIn: number;
215
+ scope: string;
216
+ }
217
+ declare function exchangeCode(opts: CodeExchangeOptions): Promise<CodeExchangeResult>;
218
+ declare function verifyIdToken(cfg: OidcConfig, idToken: string): Promise<JWTVerifyResult>;
219
+ declare function buildSessionCookie(cfg: OidcConfig, idToken: string, maxAgeSeconds: number): string;
220
+ declare function buildSignoutCookie(cfg: OidcConfig): string;
221
+ interface CallbackHandlerOptions extends OidcConfig {
222
+ redirectUri: string;
201
223
  }
202
- declare function revalidateRouteHandler(req: Request, options?: RevalidateRouteOptions): Promise<Response>;
224
+ declare function handleOidcCallback(req: Request, opts: CallbackHandlerOptions): Promise<Response>;
225
+ declare function handleSessionRequest(req: Request, cfg: OidcConfig): Promise<Response>;
226
+ declare function getSessionFromCookieHeader(cfg: OidcConfig, cookieHeader: string | null | undefined): Promise<CimplifySession | null>;
203
227
 
204
- export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, CimplifyClient, type RevalidateProfile$1 as RevalidateProfile, type RevalidateRouteOptions, type RevalidateProfile as RevalidateRouteProfile, type ServerClientOptions, getServerClient, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateRouteHandler, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions };
228
+ export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, type CallbackHandlerOptions, CimplifyClient, type CimplifySession, type CodeExchangeOptions, type CodeExchangeResult, type OidcConfig, type RevalidateProfile, type ServerClientOptions, buildSessionCookie, buildSignoutCookie, exchangeCode, getServerClient, getSessionFromCookieHeader, handleOidcCallback, handleSessionRequest, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions, verifyIdToken };