@cimplify/sdk 0.94.1 → 0.95.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 (45) hide show
  1. package/dist/advanced.d.mts +1 -1
  2. package/dist/advanced.d.ts +1 -1
  3. package/dist/{chunk-BRYMPBEN.mjs → chunk-7TEMLVDT.mjs} +15 -4
  4. package/dist/{chunk-7A3YHBVW.mjs → chunk-BUPCMMRR.mjs} +2 -2
  5. package/dist/{chunk-XVOHMOGU.js → chunk-FECGCIVV.js} +15 -4
  6. package/dist/{chunk-QLGZIBRO.js → chunk-W5PH7SPK.js} +40 -6
  7. package/dist/{chunk-QL6VROSG.js → chunk-WEEGNH7K.js} +4 -4
  8. package/dist/{chunk-FKARGZK3.mjs → chunk-XMDLF5Y6.mjs} +40 -6
  9. package/dist/{client-BTL9d_nN.d.mts → client-BNfVL2IL.d.mts} +7 -6
  10. package/dist/{client-Bhe2TnFW.d.mts → client-BeMhSkRT.d.mts} +2 -2
  11. package/dist/{client-DrkuEK_I.d.ts → client-CCCOOaI3.d.ts} +2 -2
  12. package/dist/{client-BX30FAWZ.d.ts → client-CX59ew7C.d.ts} +7 -6
  13. package/dist/index.d.mts +2 -2
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.js +10 -10
  16. package/dist/index.mjs +1 -1
  17. package/dist/mock/cli.mjs +15 -4
  18. package/dist/mock/library.js +15 -4
  19. package/dist/mock/library.mjs +15 -4
  20. package/dist/mock/msw.js +15 -4
  21. package/dist/mock/msw.mjs +15 -4
  22. package/dist/react.d.mts +2 -8
  23. package/dist/react.d.ts +2 -8
  24. package/dist/react.js +10 -43
  25. package/dist/react.mjs +4 -37
  26. package/dist/{server-BN9ZCAKT.d.mts → server-HVDbbqR9.d.mts} +6 -0
  27. package/dist/{server-DDGbfW_S.d.ts → server-JBuTPY-j.d.ts} +6 -0
  28. package/dist/server.d.mts +2 -2
  29. package/dist/server.d.ts +2 -2
  30. package/dist/server.js +2 -2
  31. package/dist/server.mjs +1 -1
  32. package/dist/testing/msw.d.mts +1 -1
  33. package/dist/testing/msw.d.ts +1 -1
  34. package/dist/testing/msw.js +2 -2
  35. package/dist/testing/msw.mjs +1 -1
  36. package/dist/testing/suite.d.mts +4 -4
  37. package/dist/testing/suite.d.ts +4 -4
  38. package/dist/testing/suite.js +22 -22
  39. package/dist/testing/suite.mjs +3 -3
  40. package/dist/testing.d.mts +18 -18
  41. package/dist/testing.d.ts +18 -18
  42. package/dist/testing.js +78 -78
  43. package/dist/testing.mjs +4 -4
  44. package/package.json +1 -1
  45. package/registry/chat-widget.json +1 -1
@@ -2556,10 +2556,15 @@ function buildV1(deps) {
2556
2556
  );
2557
2557
  app.post("/support/conversation/messages", async (c) => {
2558
2558
  const body = await c.req.json().catch(() => ({}));
2559
- return tryRoute(
2560
- c,
2561
- () => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
2562
- );
2559
+ return tryRoute(c, () => {
2560
+ const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
2561
+ return deps.support.sendMessage(conversationId, {
2562
+ content: body.content ?? "",
2563
+ content_type: body.content_type,
2564
+ sender_type: body.sender_type,
2565
+ reply_to_message_id: body.reply_to_message_id
2566
+ });
2567
+ });
2563
2568
  });
2564
2569
  app.get(
2565
2570
  "/support/conversation/messages",
@@ -5574,6 +5579,12 @@ function createSupportService(opts) {
5574
5579
  registry.conversations.put(id, conv);
5575
5580
  return conv;
5576
5581
  },
5582
+ ensureConversation(businessId, customerId) {
5583
+ const existing = registry.conversations.list(
5584
+ (c) => c.business_id === businessId && c.customer_id === customerId
5585
+ );
5586
+ return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
5587
+ },
5577
5588
  peekConversation(businessId, customerId) {
5578
5589
  const matches = registry.conversations.list(
5579
5590
  (c) => c.business_id === businessId && c.customer_id === customerId
package/dist/mock/msw.js CHANGED
@@ -2556,10 +2556,15 @@ function buildV1(deps) {
2556
2556
  );
2557
2557
  app.post("/support/conversation/messages", async (c) => {
2558
2558
  const body = await c.req.json().catch(() => ({}));
2559
- return tryRoute(
2560
- c,
2561
- () => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
2562
- );
2559
+ return tryRoute(c, () => {
2560
+ const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
2561
+ return deps.support.sendMessage(conversationId, {
2562
+ content: body.content ?? "",
2563
+ content_type: body.content_type,
2564
+ sender_type: body.sender_type,
2565
+ reply_to_message_id: body.reply_to_message_id
2566
+ });
2567
+ });
2563
2568
  });
2564
2569
  app.get(
2565
2570
  "/support/conversation/messages",
@@ -5574,6 +5579,12 @@ function createSupportService(opts) {
5574
5579
  registry.conversations.put(id, conv);
5575
5580
  return conv;
5576
5581
  },
5582
+ ensureConversation(businessId, customerId) {
5583
+ const existing = registry.conversations.list(
5584
+ (c) => c.business_id === businessId && c.customer_id === customerId
5585
+ );
5586
+ return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
5587
+ },
5577
5588
  peekConversation(businessId, customerId) {
5578
5589
  const matches = registry.conversations.list(
5579
5590
  (c) => c.business_id === businessId && c.customer_id === customerId
package/dist/mock/msw.mjs CHANGED
@@ -2554,10 +2554,15 @@ function buildV1(deps) {
2554
2554
  );
2555
2555
  app.post("/support/conversation/messages", async (c) => {
2556
2556
  const body = await c.req.json().catch(() => ({}));
2557
- return tryRoute(
2558
- c,
2559
- () => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
2560
- );
2557
+ return tryRoute(c, () => {
2558
+ const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
2559
+ return deps.support.sendMessage(conversationId, {
2560
+ content: body.content ?? "",
2561
+ content_type: body.content_type,
2562
+ sender_type: body.sender_type,
2563
+ reply_to_message_id: body.reply_to_message_id
2564
+ });
2565
+ });
2561
2566
  });
2562
2567
  app.get(
2563
2568
  "/support/conversation/messages",
@@ -5572,6 +5577,12 @@ function createSupportService(opts) {
5572
5577
  registry.conversations.put(id, conv);
5573
5578
  return conv;
5574
5579
  },
5580
+ ensureConversation(businessId, customerId) {
5581
+ const existing = registry.conversations.list(
5582
+ (c) => c.business_id === businessId && c.customer_id === customerId
5583
+ );
5584
+ return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
5585
+ },
5575
5586
  peekConversation(businessId, customerId) {
5576
5587
  const matches = registry.conversations.list(
5577
5588
  (c) => c.business_id === businessId && c.customer_id === customerId
package/dist/react.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React$1, { ReactNode } from 'react';
2
2
  import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-DQlIdqsi.mjs';
3
3
  export { A as AdConfig, g as getVariantDisplayName } from './sign-in-DQlIdqsi.mjs';
4
- import { af as CimplifyClient, ca as OrderType, cv as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a_ as EnrichedOrderItem, aZ as EnrichedOrder, w as Business, bz as Location, cM as ReorderResult, c8 as OrderStatus, bP as Order, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cr as PriceQuote, cB as QuoteUiMessage, d6 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, df as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aC as DeliveryOptionsResponse, bc as FxRateResponse, dp as StoreCreditBalance, dr as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aY as ElementsOptions, cl as PaymentMethodInfo, aW as ElementsCheckoutResult, cu as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bo as LineItem, di as Staff, d1 as Room } from './client-BTL9d_nN.mjs';
4
+ import { af as CimplifyClient, ca as OrderType, cv as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a_ as EnrichedOrderItem, aZ as EnrichedOrder, w as Business, bz as Location, cM as ReorderResult, c8 as OrderStatus, bP as Order, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cr as PriceQuote, cB as QuoteUiMessage, d6 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, df as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aC as DeliveryOptionsResponse, bc as FxRateResponse, dp as StoreCreditBalance, dr as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aY as ElementsOptions, cl as PaymentMethodInfo, aW as ElementsCheckoutResult, cu as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bo as LineItem, di as Staff, d1 as Room } from './client-BNfVL2IL.mjs';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ad as CurrencyCode, aZ as Product, aQ as Pagination, V as CimplifyError, bb as ProductWithDetails, S as Category, aO as Money, E as BundleSelectionInput, a1 as ComponentSelectionInput, D as BundleSelectionData, aa as CompositeSelectionData, W as Collection, b6 as ProductTaxonomy, bx as TaxonomyWithChildren, b7 as ProductTimeProfile, aj as Deal, b2 as ProductDealInfo, ap as DiscountValidation, G as BundleSummary, a8 as CompositePriceResult, bs as SubscriptionWithDetails, br as SubscriptionStatus, bo as Subscription, ae as CustomAttributeDefinition, bc as PropertyFacet, b1 as ProductBillingPlan, bQ as VariantView, bK as VariantAxisWithValues, f as AddOnWithOptions, y as BundleComponentView, z as BundlePriceType, a6 as CompositeGroupView, as as DisplayCart, b3 as ProductInputField, h as AddressValue, bi as SaleInfo, bD as UpcomingSale, av as DurationUnit, t as BoundaryKind, bk as SchedulingMode, al as DepositType, af as CustomAttributeValue, b4 as ProductProperty, be as QuantityPricingTier } from './product-O8-wcHSe.mjs';
7
7
  import { P as ProductWithPrice } from './price-BvRtp6ak.mjs';
@@ -869,14 +869,8 @@ interface CimplifyProviderProps {
869
869
  optimistic?: boolean;
870
870
  prefetch?: PrefetchOptions;
871
871
  linkComponent?: CimplifyLinkComponent;
872
- /**
873
- * Auto-record a page view on mount and on every route change. Default true,
874
- * so a storefront reports traffic without wiring anything. Set false where
875
- * consent has not been given, or where the app tracks page views itself.
876
- */
877
- trackPageViews?: boolean;
878
872
  }
879
- declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, trackPageViews, }: CimplifyProviderProps): React$1.ReactElement;
873
+ declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, }: CimplifyProviderProps): React$1.ReactElement;
880
874
  declare function useCimplify(): CimplifyContextValue;
881
875
  declare function useOptionalCimplify(): CimplifyContextValue | null;
882
876
  declare function useCimplifyClient(): CimplifyClientContextValue;
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React$1, { ReactNode } from 'react';
2
2
  import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-DQlIdqsi.js';
3
3
  export { A as AdConfig, g as getVariantDisplayName } from './sign-in-DQlIdqsi.js';
4
- import { af as CimplifyClient, ca as OrderType, cv as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a_ as EnrichedOrderItem, aZ as EnrichedOrder, w as Business, bz as Location, cM as ReorderResult, c8 as OrderStatus, bP as Order, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cr as PriceQuote, cB as QuoteUiMessage, d6 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, df as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aC as DeliveryOptionsResponse, bc as FxRateResponse, dp as StoreCreditBalance, dr as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aY as ElementsOptions, cl as PaymentMethodInfo, aW as ElementsCheckoutResult, cu as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bo as LineItem, di as Staff, d1 as Room } from './client-BX30FAWZ.js';
4
+ import { af as CimplifyClient, ca as OrderType, cv as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a_ as EnrichedOrderItem, aZ as EnrichedOrder, w as Business, bz as Location, cM as ReorderResult, c8 as OrderStatus, bP as Order, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cr as PriceQuote, cB as QuoteUiMessage, d6 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, df as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aC as DeliveryOptionsResponse, bc as FxRateResponse, dp as StoreCreditBalance, dr as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aY as ElementsOptions, cl as PaymentMethodInfo, aW as ElementsCheckoutResult, cu as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bo as LineItem, di as Staff, d1 as Room } from './client-CX59ew7C.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ad as CurrencyCode, aZ as Product, aQ as Pagination, V as CimplifyError, bb as ProductWithDetails, S as Category, aO as Money, E as BundleSelectionInput, a1 as ComponentSelectionInput, D as BundleSelectionData, aa as CompositeSelectionData, W as Collection, b6 as ProductTaxonomy, bx as TaxonomyWithChildren, b7 as ProductTimeProfile, aj as Deal, b2 as ProductDealInfo, ap as DiscountValidation, G as BundleSummary, a8 as CompositePriceResult, bs as SubscriptionWithDetails, br as SubscriptionStatus, bo as Subscription, ae as CustomAttributeDefinition, bc as PropertyFacet, b1 as ProductBillingPlan, bQ as VariantView, bK as VariantAxisWithValues, f as AddOnWithOptions, y as BundleComponentView, z as BundlePriceType, a6 as CompositeGroupView, as as DisplayCart, b3 as ProductInputField, h as AddressValue, bi as SaleInfo, bD as UpcomingSale, av as DurationUnit, t as BoundaryKind, bk as SchedulingMode, al as DepositType, af as CustomAttributeValue, b4 as ProductProperty, be as QuantityPricingTier } from './product-O8-wcHSe.js';
7
7
  import { P as ProductWithPrice } from './price-23RNXftz.js';
@@ -869,14 +869,8 @@ interface CimplifyProviderProps {
869
869
  optimistic?: boolean;
870
870
  prefetch?: PrefetchOptions;
871
871
  linkComponent?: CimplifyLinkComponent;
872
- /**
873
- * Auto-record a page view on mount and on every route change. Default true,
874
- * so a storefront reports traffic without wiring anything. Set false where
875
- * consent has not been given, or where the app tracks page views itself.
876
- */
877
- trackPageViews?: boolean;
878
872
  }
879
- declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, trackPageViews, }: CimplifyProviderProps): React$1.ReactElement;
873
+ declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, }: CimplifyProviderProps): React$1.ReactElement;
880
874
  declare function useCimplify(): CimplifyContextValue;
881
875
  declare function useOptionalCimplify(): CimplifyContextValue | null;
882
876
  declare function useCimplifyClient(): CimplifyClientContextValue;
package/dist/react.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  var chunkHKN3YG76_js = require('./chunk-HKN3YG76.js');
5
5
  var chunkXREIZ56K_js = require('./chunk-XREIZ56K.js');
6
- var chunkQLGZIBRO_js = require('./chunk-QLGZIBRO.js');
6
+ var chunkW5PH7SPK_js = require('./chunk-W5PH7SPK.js');
7
7
  var chunkVEOAMBEX_js = require('./chunk-VEOAMBEX.js');
8
8
  var chunkPTPOQVXS_js = require('./chunk-PTPOQVXS.js');
9
9
  var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
@@ -806,7 +806,7 @@ async function syncFromServer(entry) {
806
806
  return next;
807
807
  }
808
808
  function emitMutationError(entry, operation, opId, idempotencyKey, error) {
809
- entry.client.events.emit(chunkQLGZIBRO_js.MUTATION_ERROR, {
809
+ entry.client.events.emit(chunkW5PH7SPK_js.MUTATION_ERROR, {
810
810
  service: "cart",
811
811
  operation,
812
812
  opId,
@@ -846,10 +846,10 @@ function getOrCreateStore(params) {
846
846
  syncTail: Promise.resolve(),
847
847
  failedOpRemovers: /* @__PURE__ */ new Set()
848
848
  };
849
- client.events.on(chunkQLGZIBRO_js.SESSION_CLAIMED, () => {
849
+ client.events.on(chunkW5PH7SPK_js.SESSION_CLAIMED, () => {
850
850
  if (entry.initialized) void syncFromServer(entry);
851
851
  });
852
- client.events.on(chunkQLGZIBRO_js.SESSION_CLEARED, () => {
852
+ client.events.on(chunkW5PH7SPK_js.SESSION_CLEARED, () => {
853
853
  if (entry.initialized) void syncFromServer(entry);
854
854
  });
855
855
  cartStores.set(storeKey, entry);
@@ -1137,37 +1137,6 @@ function preconnectOrigin(url, crossOrigin) {
1137
1137
  if (crossOrigin) link.crossOrigin = crossOrigin;
1138
1138
  document.head.appendChild(link);
1139
1139
  }
1140
- function usePageViewTracking(client, enabled) {
1141
- React14.useEffect(() => {
1142
- if (!enabled || typeof window === "undefined") return;
1143
- let lastPath = null;
1144
- const record = () => {
1145
- const path = window.location.pathname;
1146
- if (path === lastPath) return;
1147
- lastPath = path;
1148
- try {
1149
- client.activity?.trackPageView({ pagePath: path });
1150
- } catch {
1151
- }
1152
- };
1153
- record();
1154
- const { pushState, replaceState } = window.history;
1155
- window.history.pushState = function(...args) {
1156
- pushState.apply(this, args);
1157
- record();
1158
- };
1159
- window.history.replaceState = function(...args) {
1160
- replaceState.apply(this, args);
1161
- record();
1162
- };
1163
- window.addEventListener("popstate", record);
1164
- return () => {
1165
- window.history.pushState = pushState;
1166
- window.history.replaceState = replaceState;
1167
- window.removeEventListener("popstate", record);
1168
- };
1169
- }, [client, enabled]);
1170
- }
1171
1140
  var LOCATION_STORAGE_KEY = "cimplify_location_id";
1172
1141
  var DISPLAY_CURRENCY_STORAGE_KEY = "cimplify_display_currency";
1173
1142
  var FX_REFRESH_INTERVAL = 12e4;
@@ -1176,7 +1145,7 @@ var DEFAULT_COUNTRY = "US";
1176
1145
  function createDefaultClient() {
1177
1146
  const processRef = globalThis.process;
1178
1147
  const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
1179
- return chunkQLGZIBRO_js.createCimplifyClient({ publicKey: envPublicKey });
1148
+ return chunkW5PH7SPK_js.createCimplifyClient({ publicKey: envPublicKey });
1180
1149
  }
1181
1150
  function getStoredLocationId() {
1182
1151
  if (typeof window === "undefined" || !window.localStorage) {
@@ -1248,11 +1217,9 @@ function CimplifyProvider({
1248
1217
  initialLocations,
1249
1218
  optimistic = true,
1250
1219
  prefetch,
1251
- linkComponent,
1252
- trackPageViews = true
1220
+ linkComponent
1253
1221
  }) {
1254
1222
  const resolvedClient = React14.useMemo(() => client ?? createDefaultClient(), [client]);
1255
- usePageViewTracking(resolvedClient, trackPageViews);
1256
1223
  const resolvedPrefetch = React14.useMemo(
1257
1224
  () => ({
1258
1225
  mode: prefetch?.mode ?? DEFAULT_PREFETCH_OPTIONS.mode,
@@ -6192,7 +6159,7 @@ function useChat(options = {}) {
6192
6159
  const watchSessionClaims = React14.useCallback(() => {
6193
6160
  const c = clientRef.current;
6194
6161
  if (!c || claimUnsubRef.current) return;
6195
- const unsubClaimed = c.events.on(chunkQLGZIBRO_js.SESSION_CLAIMED, (event) => {
6162
+ const unsubClaimed = c.events.on(chunkW5PH7SPK_js.SESSION_CLAIMED, (event) => {
6196
6163
  setClaimedAs(event.customerName || c.support.claimedCustomerName || null);
6197
6164
  if (!openedRef.current) {
6198
6165
  void openIfExisting();
@@ -6201,7 +6168,7 @@ function useChat(options = {}) {
6201
6168
  connectWebSocket();
6202
6169
  void resyncConversation();
6203
6170
  });
6204
- const unsubCleared = c.events.on(chunkQLGZIBRO_js.SESSION_CLEARED, resetConversation);
6171
+ const unsubCleared = c.events.on(chunkW5PH7SPK_js.SESSION_CLEARED, resetConversation);
6205
6172
  claimUnsubRef.current = () => {
6206
6173
  unsubClaimed();
6207
6174
  unsubCleared();
@@ -17419,12 +17386,12 @@ function Panel({
17419
17386
  }
17420
17387
  ),
17421
17388
  error != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-red-200 bg-red-50 px-4 py-2 text-xs text-red-600", children: error.userMessage || "Something went wrong. Please try again." }),
17422
- (isActive || isLoading) && /* @__PURE__ */ jsxRuntime.jsx(
17389
+ /* @__PURE__ */ jsxRuntime.jsx(
17423
17390
  ChatInput,
17424
17391
  {
17425
17392
  placeholder,
17426
17393
  isSending,
17427
- onSend,
17394
+ onSend: isActive ? onSend : onStartConversation,
17428
17395
  onAttach,
17429
17396
  className: classNames?.input
17430
17397
  }
package/dist/react.mjs CHANGED
@@ -3,7 +3,7 @@ import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, isMultiDayServi
3
3
  export { getVariantDisplayName } from './chunk-RRBY35TJ.mjs';
4
4
  import { messagePreview } from './chunk-U4MW6PYU.mjs';
5
5
  export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
6
- import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, MUTATION_ERROR } from './chunk-FKARGZK3.mjs';
6
+ import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, MUTATION_ERROR } from './chunk-XMDLF5Y6.mjs';
7
7
  import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-VUSHG3HA.mjs';
8
8
  import { parsePrice, formatMoney, formatPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-KFLGQGMC.mjs';
9
9
  import { isSupportedCurrency, CimplifyError } from './chunk-K5EN2W2Q.mjs';
@@ -1113,37 +1113,6 @@ function preconnectOrigin(url, crossOrigin) {
1113
1113
  if (crossOrigin) link.crossOrigin = crossOrigin;
1114
1114
  document.head.appendChild(link);
1115
1115
  }
1116
- function usePageViewTracking(client, enabled) {
1117
- useEffect(() => {
1118
- if (!enabled || typeof window === "undefined") return;
1119
- let lastPath = null;
1120
- const record = () => {
1121
- const path = window.location.pathname;
1122
- if (path === lastPath) return;
1123
- lastPath = path;
1124
- try {
1125
- client.activity?.trackPageView({ pagePath: path });
1126
- } catch {
1127
- }
1128
- };
1129
- record();
1130
- const { pushState, replaceState } = window.history;
1131
- window.history.pushState = function(...args) {
1132
- pushState.apply(this, args);
1133
- record();
1134
- };
1135
- window.history.replaceState = function(...args) {
1136
- replaceState.apply(this, args);
1137
- record();
1138
- };
1139
- window.addEventListener("popstate", record);
1140
- return () => {
1141
- window.history.pushState = pushState;
1142
- window.history.replaceState = replaceState;
1143
- window.removeEventListener("popstate", record);
1144
- };
1145
- }, [client, enabled]);
1146
- }
1147
1116
  var LOCATION_STORAGE_KEY = "cimplify_location_id";
1148
1117
  var DISPLAY_CURRENCY_STORAGE_KEY = "cimplify_display_currency";
1149
1118
  var FX_REFRESH_INTERVAL = 12e4;
@@ -1224,11 +1193,9 @@ function CimplifyProvider({
1224
1193
  initialLocations,
1225
1194
  optimistic = true,
1226
1195
  prefetch,
1227
- linkComponent,
1228
- trackPageViews = true
1196
+ linkComponent
1229
1197
  }) {
1230
1198
  const resolvedClient = useMemo(() => client ?? createDefaultClient(), [client]);
1231
- usePageViewTracking(resolvedClient, trackPageViews);
1232
1199
  const resolvedPrefetch = useMemo(
1233
1200
  () => ({
1234
1201
  mode: prefetch?.mode ?? DEFAULT_PREFETCH_OPTIONS.mode,
@@ -17395,12 +17362,12 @@ function Panel({
17395
17362
  }
17396
17363
  ),
17397
17364
  error != null && /* @__PURE__ */ jsx("div", { className: "border-t border-red-200 bg-red-50 px-4 py-2 text-xs text-red-600", children: error.userMessage || "Something went wrong. Please try again." }),
17398
- (isActive || isLoading) && /* @__PURE__ */ jsx(
17365
+ /* @__PURE__ */ jsx(
17399
17366
  ChatInput,
17400
17367
  {
17401
17368
  placeholder,
17402
17369
  isSending,
17403
- onSend,
17370
+ onSend: isActive ? onSend : onStartConversation,
17404
17371
  onAttach,
17405
17372
  className: classNames?.input
17406
17373
  }
@@ -952,6 +952,12 @@ interface ActivityService {
952
952
 
953
953
  interface SupportService {
954
954
  openConversation(businessId: string, customerId?: string): MockConversation;
955
+ /**
956
+ * The conversation for this visitor, opening one if none exists. Mirrors the
957
+ * lens, whose `send_message` takes no conversation id at all and resolves the
958
+ * thread from the widget identity — so a first message must not 404.
959
+ */
960
+ ensureConversation(businessId: string, customerId?: string): MockConversation;
955
961
  peekConversation(businessId: string, customerId?: string): {
956
962
  conversation: MockConversation | null;
957
963
  messages: MockChatMessage[];
@@ -952,6 +952,12 @@ interface ActivityService {
952
952
 
953
953
  interface SupportService {
954
954
  openConversation(businessId: string, customerId?: string): MockConversation;
955
+ /**
956
+ * The conversation for this visitor, opening one if none exists. Mirrors the
957
+ * lens, whose `send_message` takes no conversation id at all and resolves the
958
+ * thread from the widget identity — so a first message must not 404.
959
+ */
960
+ ensureConversation(businessId: string, customerId?: string): MockConversation;
955
961
  peekConversation(businessId: string, customerId?: string): {
956
962
  conversation: MockConversation | null;
957
963
  messages: MockChatMessage[];
package/dist/server.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { af as CimplifyClient } from './client-BTL9d_nN.mjs';
2
- export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-BTL9d_nN.mjs';
1
+ import { af as CimplifyClient } from './client-BNfVL2IL.mjs';
2
+ export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-BNfVL2IL.mjs';
3
3
  export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-O8-wcHSe.mjs';
4
4
  import { JWTVerifyResult } from 'jose';
5
5
  import './payment-pKPpaORI.mjs';
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { af as CimplifyClient } from './client-BX30FAWZ.js';
2
- export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-BX30FAWZ.js';
1
+ import { af as CimplifyClient } from './client-CX59ew7C.js';
2
+ export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-CX59ew7C.js';
3
3
  export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-O8-wcHSe.js';
4
4
  import { JWTVerifyResult } from 'jose';
5
5
  import './payment-By0JidTe.js';
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkQLGZIBRO_js = require('./chunk-QLGZIBRO.js');
3
+ var chunkW5PH7SPK_js = require('./chunk-W5PH7SPK.js');
4
4
  var chunkVEOAMBEX_js = require('./chunk-VEOAMBEX.js');
5
5
  require('./chunk-PTPOQVXS.js');
6
6
  var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
@@ -26,7 +26,7 @@ function readEnv(...keys) {
26
26
  var getServerClient = react.cache((opts = {}) => {
27
27
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
28
28
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
29
- const client = chunkQLGZIBRO_js.createCimplifyClient({
29
+ const client = chunkW5PH7SPK_js.createCimplifyClient({
30
30
  baseUrl,
31
31
  publicKey,
32
32
  suppressPublicKeyWarning: true
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createCimplifyClient } from './chunk-FKARGZK3.mjs';
1
+ import { createCimplifyClient } from './chunk-XMDLF5Y6.mjs';
2
2
  import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-VUSHG3HA.mjs';
3
3
  import './chunk-KFLGQGMC.mjs';
4
4
  export { CimplifyError } from './chunk-K5EN2W2Q.mjs';
@@ -1,4 +1,4 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-BN9ZCAKT.mjs';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-HVDbbqR9.mjs';
2
2
  import 'hono';
3
3
  import '../product-O8-wcHSe.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-DDGbfW_S.js';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-JBuTPY-j.js';
2
2
  import 'hono';
3
3
  import '../product-O8-wcHSe.js';
4
4
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkXVOHMOGU_js = require('../chunk-XVOHMOGU.js');
3
+ var chunkFECGCIVV_js = require('../chunk-FECGCIVV.js');
4
4
  require('../chunk-XREIZ56K.js');
5
5
  require('../chunk-AETVRBKI.js');
6
6
  require('../chunk-OWW5GUSB.js');
@@ -8,7 +8,7 @@ require('../chunk-OWW5GUSB.js');
8
8
  // src/mock/msw.ts
9
9
  async function createMswHandlers(options = {}) {
10
10
  const baseUrl = options.baseUrl ?? "http://localhost:8787";
11
- const handle = chunkXVOHMOGU_js.createMockApp(options);
11
+ const handle = chunkFECGCIVV_js.createMockApp(options);
12
12
  const msw = await import('msw').catch(() => {
13
13
  throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
14
14
  });
@@ -1,4 +1,4 @@
1
- import { createMockApp } from '../chunk-BRYMPBEN.mjs';
1
+ import { createMockApp } from '../chunk-7TEMLVDT.mjs';
2
2
  import '../chunk-U4MW6PYU.mjs';
3
3
  import '../chunk-K5EN2W2Q.mjs';
4
4
  import '../chunk-3G6RQLXK.mjs';
@@ -1,8 +1,8 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-Bhe2TnFW.mjs';
3
- import { C as CreateAppOptions } from '../server-BN9ZCAKT.mjs';
4
- export { S as SeedName } from '../server-BN9ZCAKT.mjs';
5
- import '../client-BTL9d_nN.mjs';
2
+ import { T as TestClientHandle } from '../client-BeMhSkRT.mjs';
3
+ import { C as CreateAppOptions } from '../server-HVDbbqR9.mjs';
4
+ export { S as SeedName } from '../server-HVDbbqR9.mjs';
5
+ import '../client-BNfVL2IL.mjs';
6
6
  import '../product-O8-wcHSe.mjs';
7
7
  import '../payment-pKPpaORI.mjs';
8
8
  import 'hono';
@@ -1,8 +1,8 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-DrkuEK_I.js';
3
- import { C as CreateAppOptions } from '../server-DDGbfW_S.js';
4
- export { S as SeedName } from '../server-DDGbfW_S.js';
5
- import '../client-BX30FAWZ.js';
2
+ import { T as TestClientHandle } from '../client-CCCOOaI3.js';
3
+ import { C as CreateAppOptions } from '../server-JBuTPY-j.js';
4
+ export { S as SeedName } from '../server-JBuTPY-j.js';
5
+ import '../client-CX59ew7C.js';
6
6
  import '../product-O8-wcHSe.js';
7
7
  import '../payment-By0JidTe.js';
8
8
  import 'hono';
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkQL6VROSG_js = require('../chunk-QL6VROSG.js');
4
- require('../chunk-XVOHMOGU.js');
3
+ var chunkWEEGNH7K_js = require('../chunk-WEEGNH7K.js');
4
+ require('../chunk-FECGCIVV.js');
5
5
  require('../chunk-XREIZ56K.js');
6
- require('../chunk-QLGZIBRO.js');
6
+ require('../chunk-W5PH7SPK.js');
7
7
  require('../chunk-VEOAMBEX.js');
8
8
  require('../chunk-PTPOQVXS.js');
9
9
  require('../chunk-AETVRBKI.js');
@@ -21,11 +21,11 @@ var PLACEHOLDER_PHRASES = [
21
21
  function createBrandSuite(opts) {
22
22
  vitest.describe(opts.label ?? "brand schema", () => {
23
23
  vitest.it("conforms to the Cimplify brand contract", () => {
24
- vitest.expect(() => chunkQL6VROSG_js.assertBrand(opts.brand)).not.toThrow();
24
+ vitest.expect(() => chunkWEEGNH7K_js.assertBrand(opts.brand)).not.toThrow();
25
25
  });
26
26
  vitest.it("declares a known mock seed", () => {
27
27
  const b = opts.brand;
28
- vitest.expect(chunkQL6VROSG_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
28
+ vitest.expect(chunkWEEGNH7K_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
29
29
  });
30
30
  vitest.it("has no placeholder copy left in", () => {
31
31
  const offenders = [];
@@ -57,7 +57,7 @@ ${msg}`);
57
57
  vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
58
58
  });
59
59
  vitest.it("zod-parses cleanly", () => {
60
- const result = chunkQL6VROSG_js.BrandSchema.safeParse(opts.brand);
60
+ const result = chunkWEEGNH7K_js.BrandSchema.safeParse(opts.brand);
61
61
  if (!result.success) {
62
62
  throw new Error(
63
63
  "Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
@@ -72,23 +72,23 @@ function createCartFlowSuite(opts = {}) {
72
72
  vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
73
73
  let h;
74
74
  vitest.beforeEach(() => {
75
- h = chunkQL6VROSG_js.createTestClient(opts);
75
+ h = chunkWEEGNH7K_js.createTestClient(opts);
76
76
  });
77
77
  vitest.afterEach(() => h.dispose());
78
78
  vitest.it("starts with an empty cart matching the canonical shape", async () => {
79
79
  const res = await h.client.cart.get();
80
80
  vitest.expect(res.ok).toBe(true);
81
81
  if (!res.ok) return;
82
- vitest.expect(() => chunkQL6VROSG_js.assertCart(res.value)).not.toThrow();
82
+ vitest.expect(() => chunkWEEGNH7K_js.assertCart(res.value)).not.toThrow();
83
83
  vitest.expect(res.value.items).toHaveLength(0);
84
84
  });
85
85
  vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
86
- const { product, variantId } = await chunkQL6VROSG_js.fixtures.addFirstProduct(h.client);
86
+ const { product, variantId } = await chunkWEEGNH7K_js.fixtures.addFirstProduct(h.client);
87
87
  vitest.expect(product.id).toBeTruthy();
88
88
  const get = await h.client.cart.get();
89
89
  vitest.expect(get.ok).toBe(true);
90
90
  if (!get.ok) return;
91
- vitest.expect(() => chunkQL6VROSG_js.assertCart(get.value)).not.toThrow();
91
+ vitest.expect(() => chunkWEEGNH7K_js.assertCart(get.value)).not.toThrow();
92
92
  vitest.expect(get.value.items).toHaveLength(1);
93
93
  vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
94
94
  if (variantId) {
@@ -99,8 +99,8 @@ function createCartFlowSuite(opts = {}) {
99
99
  vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
100
100
  });
101
101
  vitest.it("dedupes by line_key when adding the same product twice", async () => {
102
- await chunkQL6VROSG_js.fixtures.addFirstProduct(h.client);
103
- await chunkQL6VROSG_js.fixtures.addFirstProduct(h.client);
102
+ await chunkWEEGNH7K_js.fixtures.addFirstProduct(h.client);
103
+ await chunkWEEGNH7K_js.fixtures.addFirstProduct(h.client);
104
104
  const res = await h.client.cart.get();
105
105
  vitest.expect(res.ok).toBe(true);
106
106
  if (!res.ok) return;
@@ -108,7 +108,7 @@ function createCartFlowSuite(opts = {}) {
108
108
  vitest.expect(res.value.items[0]?.quantity).toBe(2);
109
109
  });
110
110
  vitest.it("removes items and zeroes the subtotal", async () => {
111
- await chunkQL6VROSG_js.fixtures.addFirstProduct(h.client);
111
+ await chunkWEEGNH7K_js.fixtures.addFirstProduct(h.client);
112
112
  const before = await h.client.cart.get();
113
113
  if (!before.ok) throw before.error;
114
114
  const itemId = before.value.items[0]?.id;
@@ -134,28 +134,28 @@ function createContractSuite(opts = {}) {
134
134
  vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
135
135
  let h;
136
136
  vitest.beforeEach(() => {
137
- h = chunkQL6VROSG_js.createTestClient(opts);
137
+ h = chunkWEEGNH7K_js.createTestClient(opts);
138
138
  });
139
139
  vitest.afterEach(() => h.dispose());
140
140
  vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
141
- const result = chunkQL6VROSG_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
141
+ const result = chunkWEEGNH7K_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
142
142
  vitest.expect(result.success).toBe(true);
143
143
  });
144
144
  vitest.it("AddItemPayload schema rejects negative quantity", () => {
145
- const result = chunkQL6VROSG_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
145
+ const result = chunkWEEGNH7K_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
146
146
  vitest.expect(result.success).toBe(false);
147
147
  });
148
148
  vitest.it("AddItemPayload schema rejects empty item_id", () => {
149
- const result = chunkQL6VROSG_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
149
+ const result = chunkWEEGNH7K_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
150
150
  vitest.expect(result.success).toBe(false);
151
151
  });
152
152
  vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
153
- const { product } = await chunkQL6VROSG_js.fixtures.addFirstProduct(h.client);
153
+ const { product } = await chunkWEEGNH7K_js.fixtures.addFirstProduct(h.client);
154
154
  const get = await h.client.cart.get();
155
155
  if (!get.ok) throw get.error;
156
156
  vitest.expect(get.value.items.length).toBeGreaterThan(0);
157
157
  for (const item of get.value.items) {
158
- const result = chunkQL6VROSG_js.CartItemSchema.safeParse(item);
158
+ const result = chunkWEEGNH7K_js.CartItemSchema.safeParse(item);
159
159
  if (!result.success) {
160
160
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
161
161
  throw new Error(`Cart item shape mismatch for ${product.name}:
@@ -165,19 +165,19 @@ ${issues}`);
165
165
  }
166
166
  });
167
167
  vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
168
- await chunkQL6VROSG_js.fixtures.addFirstProduct(h.client);
168
+ await chunkWEEGNH7K_js.fixtures.addFirstProduct(h.client);
169
169
  const cartRes = await h.client.cart.get();
170
170
  if (!cartRes.ok) throw cartRes.error;
171
171
  const checkout = await h.client.checkout.process({
172
172
  cart_id: cartRes.value.id,
173
- customer: chunkQL6VROSG_js.fixtures.customer(),
173
+ customer: chunkWEEGNH7K_js.fixtures.customer(),
174
174
  order_type: "delivery",
175
175
  payment_method: "mobile_money",
176
176
  mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
177
177
  });
178
178
  vitest.expect(checkout.ok).toBe(true);
179
179
  if (!checkout.ok) return;
180
- const result = chunkQL6VROSG_js.CheckoutResponseSchema.safeParse(checkout.value);
180
+ const result = chunkWEEGNH7K_js.CheckoutResponseSchema.safeParse(checkout.value);
181
181
  if (!result.success) {
182
182
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
183
183
  throw new Error(`CheckoutResponse shape mismatch: