@cimplify/sdk 0.102.0 → 0.104.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 (69) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/advanced.js +23 -22
  4. package/dist/advanced.mjs +4 -3
  5. package/dist/{chunk-DCMXUKDQ.mjs → chunk-2WPVUIHX.mjs} +455 -105
  6. package/dist/{chunk-NIOUSKQQ.js → chunk-4BKOKHE3.js} +9 -0
  7. package/dist/{chunk-YDA46OZ6.js → chunk-5BDYDZ4U.js} +722 -90
  8. package/dist/{chunk-4KNFBPV2.mjs → chunk-5RT4HYMP.mjs} +61 -15
  9. package/dist/{chunk-WMEC5JWN.js → chunk-7PDEX54K.js} +50 -13
  10. package/dist/chunk-CNN7Z2IP.js +125 -0
  11. package/dist/{chunk-DLW3RWRK.mjs → chunk-DYIAX3WI.mjs} +46 -12
  12. package/dist/{chunk-LOWSMGRT.js → chunk-E4K2VQDD.js} +64 -16
  13. package/dist/chunk-GOHSXBKW.mjs +105 -0
  14. package/dist/{chunk-O3YUHLZL.mjs → chunk-H3RATH4B.mjs} +9 -0
  15. package/dist/{chunk-YER7DIOM.js → chunk-IQFFSKE2.js} +753 -594
  16. package/dist/{chunk-Z3K2D3TE.mjs → chunk-OCCNG6MO.mjs} +735 -558
  17. package/dist/{chunk-DKLHCZ5M.mjs → chunk-OKADBZAI.mjs} +652 -25
  18. package/dist/{chunk-EAZGA7LD.js → chunk-YVAEY3VC.js} +457 -107
  19. package/dist/{client-nsiMwuC1.d.ts → client-BVNWjk6W.d.ts} +2 -2
  20. package/dist/{client-B40KFazg.d.ts → client-BuLcOWLv.d.ts} +202 -319
  21. package/dist/{client-BizGfqB7.d.mts → client-D5AoobFc.d.mts} +202 -319
  22. package/dist/{client-BdErclfU.d.mts → client-fM716k7G.d.mts} +2 -2
  23. package/dist/{index-DpmnI__D.d.mts → index-BtcoqrY1.d.ts} +14 -4
  24. package/dist/{index-nEyXWIyR.d.ts → index-D7Tf3v7c.d.mts} +14 -4
  25. package/dist/index.d.mts +83 -8
  26. package/dist/index.d.ts +83 -8
  27. package/dist/index.js +203 -169
  28. package/dist/index.mjs +7 -5
  29. package/dist/link-D9iSVxt5.d.mts +308 -0
  30. package/dist/link-D9iSVxt5.d.ts +308 -0
  31. package/dist/mock/cli.mjs +463 -104
  32. package/dist/mock/library.js +463 -104
  33. package/dist/mock/library.mjs +463 -104
  34. package/dist/mock/msw.js +463 -104
  35. package/dist/mock/msw.mjs +463 -104
  36. package/dist/{product-Byf0unSy.d.mts → payment-g0HFkEDU.d.mts} +708 -61
  37. package/dist/{product-Byf0unSy.d.ts → payment-g0HFkEDU.d.ts} +708 -61
  38. package/dist/{price-BstChV9a.d.ts → price-BLIeAb8K.d.ts} +1 -1
  39. package/dist/{price-CS4E5zLS.d.mts → price-Czq_cTC_.d.mts} +1 -1
  40. package/dist/react.d.mts +4 -4
  41. package/dist/react.d.ts +4 -4
  42. package/dist/react.js +194 -169
  43. package/dist/react.mjs +55 -30
  44. package/dist/{server-DqbZh8Bk.d.mts → server-BkVhOIwn.d.mts} +14 -10
  45. package/dist/{server-Cj40R2ZD.d.ts → server-DKK_D-PP.d.ts} +14 -10
  46. package/dist/server.d.mts +4 -4
  47. package/dist/server.d.ts +4 -4
  48. package/dist/server.js +12 -10
  49. package/dist/server.mjs +6 -4
  50. package/dist/testing/msw.d.mts +2 -2
  51. package/dist/testing/msw.d.ts +2 -2
  52. package/dist/testing/msw.js +4 -3
  53. package/dist/testing/msw.mjs +3 -2
  54. package/dist/testing/suite.d.mts +6 -6
  55. package/dist/testing/suite.d.ts +6 -6
  56. package/dist/testing/suite.js +26 -25
  57. package/dist/testing/suite.mjs +7 -6
  58. package/dist/testing.d.mts +195 -56
  59. package/dist/testing.d.ts +195 -56
  60. package/dist/testing.js +95 -82
  61. package/dist/testing.mjs +14 -9
  62. package/dist/utils.d.mts +4 -4
  63. package/dist/utils.d.ts +4 -4
  64. package/dist/utils.js +37 -29
  65. package/dist/utils.mjs +2 -2
  66. package/package.json +7 -1
  67. package/registry/chat-widget.json +1 -1
  68. package/dist/payment-l0rkieEQ.d.mts +0 -113
  69. package/dist/payment-vzNnIi1n.d.ts +0 -113
package/dist/react.mjs CHANGED
@@ -1,12 +1,13 @@
1
1
  "use client";
2
- import { splitGenUIContent, messagePreview } from './chunk-U4MW6PYU.mjs';
3
- export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
4
2
  import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, isMultiDayService, serviceBillingMultiplier, PRODUCT_TYPE, BOUNDARY_KIND, resolveGallery, chatMessageCards, RENDER_HINT, displaysGrossPrices, DEFAULT_CDN_BASE_URL } from './chunk-3V4DVXV3.mjs';
5
3
  export { getVariantDisplayName } from './chunk-3V4DVXV3.mjs';
6
- import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-DKLHCZ5M.mjs';
7
- import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-Z3K2D3TE.mjs';
8
- import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-DLW3RWRK.mjs';
9
- import { isSupportedCurrency, currencyCode, CimplifyError } from './chunk-O3YUHLZL.mjs';
4
+ import { chatRealtimeUpdateFromWire, SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-OKADBZAI.mjs';
5
+ import { splitGenUIContent, messagePreview } from './chunk-U4MW6PYU.mjs';
6
+ export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
7
+ import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-OCCNG6MO.mjs';
8
+ import './chunk-GOHSXBKW.mjs';
9
+ import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-DYIAX3WI.mjs';
10
+ import { isSupportedCurrency, currencyCode, CimplifyError } from './chunk-H3RATH4B.mjs';
10
11
  import './chunk-3G6RQLXK.mjs';
11
12
  import React14, { createContext, lazy, memo, Suspense, useMemo, useContext, useRef, useCallback, useState, useEffect, useId, useSyncExternalStore } from 'react';
12
13
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -6138,7 +6139,7 @@ function useChat(options = {}) {
6138
6139
  if (!c) return;
6139
6140
  const last = lastConfirmedMessage();
6140
6141
  const result = await c.support.getMessages({
6141
- after: last?.created_at,
6142
+ afterSequence: last?.sequence,
6142
6143
  limit: 50
6143
6144
  });
6144
6145
  if (result.ok && result.value.length > 0) {
@@ -6181,9 +6182,9 @@ function useChat(options = {}) {
6181
6182
  );
6182
6183
  return mergeMessages(snapshot, extras);
6183
6184
  });
6184
- aiEnabledRef.current = result.value.conversation.ai_enabled;
6185
- setHumanRequested(result.value.conversation.needs_human_review ?? false);
6186
- setSeenAt(result.value.conversation.team_read_at ?? null);
6185
+ aiEnabledRef.current = result.value.conversation.ai_mode === "auto";
6186
+ setHumanRequested(result.value.conversation.ai_mode === "off");
6187
+ setSeenAt(null);
6187
6188
  setMayHaveOlder(result.value.messages.length >= 50);
6188
6189
  }, []);
6189
6190
  const connectWebSocket = useCallback(() => {
@@ -6211,23 +6212,36 @@ function useChat(options = {}) {
6211
6212
  ws.onmessage = (event) => {
6212
6213
  try {
6213
6214
  const envelope = JSON.parse(event.data);
6214
- if (envelope.type === "message.created" && envelope.data) {
6215
- appendMessages([envelope.data]);
6216
- } else if (envelope.type === "thread.read") {
6217
- const at = envelope.data?.last_read_at;
6218
- if (at) setSeenAt((prev) => !prev || prev < at ? at : prev);
6219
- } else if (envelope.type === "thread.responding") {
6220
- const active = envelope.data?.active;
6221
- if (active) startAwaitingReply();
6222
- else stopAwaitingReply();
6223
- } else if (envelope.type === "resync") {
6224
- const latest = envelope.latest_message_at;
6215
+ const update = chatRealtimeUpdateFromWire(envelope);
6216
+ if (update.kind === "message") {
6217
+ appendMessages([update.message]);
6218
+ } else if (update.kind === "message_updated") {
6219
+ lastActivityRef.current = Date.now();
6220
+ setMessages(
6221
+ (previous) => update.message.deleted_at ? previous.filter((message) => message.id !== update.message.id) : previous.map(
6222
+ (message) => message.id === update.message.id ? update.message : message
6223
+ )
6224
+ );
6225
+ } else if (update.kind === "business_read") {
6226
+ setSeenAt(
6227
+ (prev) => !prev || prev < update.occurredAt ? update.occurredAt : prev
6228
+ );
6229
+ } else if (update.kind === "ai_mode") {
6230
+ aiEnabledRef.current = update.mode === "auto";
6231
+ setHumanRequested(update.mode === "off");
6232
+ if (update.mode !== "auto") stopAwaitingReply();
6233
+ } else if (update.kind === "handoff") {
6234
+ aiEnabledRef.current = false;
6235
+ setHumanRequested(true);
6236
+ stopAwaitingReply();
6237
+ } else if (update.kind === "reload") {
6238
+ void resyncConversation();
6239
+ } else if (update.kind === "resync") {
6240
+ const latest = update.latestSequence;
6225
6241
  const last = lastConfirmedMessage();
6226
- if (latest && (!last || new Date(last.created_at).getTime() < new Date(latest).getTime())) {
6242
+ if (latest === void 0 || !last?.sequence || last.sequence < latest) {
6227
6243
  fetchNewMessages();
6228
6244
  }
6229
- } else if (envelope.type === "rekey") {
6230
- void resyncConversation();
6231
6245
  }
6232
6246
  } catch {
6233
6247
  }
@@ -6248,7 +6262,15 @@ function useChat(options = {}) {
6248
6262
  ws.onerror = () => {
6249
6263
  };
6250
6264
  wsRef.current = ws;
6251
- }, [appendMessages, startPolling, stopPolling, fetchNewMessages, resyncConversation, lastConfirmedMessage]);
6265
+ }, [
6266
+ appendMessages,
6267
+ startPolling,
6268
+ stopPolling,
6269
+ fetchNewMessages,
6270
+ resyncConversation,
6271
+ lastConfirmedMessage,
6272
+ stopAwaitingReply
6273
+ ]);
6252
6274
  const resetConversation = useCallback(() => {
6253
6275
  stopPolling();
6254
6276
  if (wsReconnectTimerRef.current) {
@@ -6276,9 +6298,9 @@ function useChat(options = {}) {
6276
6298
  const c = clientRef.current;
6277
6299
  setMessages(value.messages);
6278
6300
  setConversationOpened(true);
6279
- aiEnabledRef.current = value.conversation.ai_enabled;
6280
- setHumanRequested(value.conversation.needs_human_review ?? false);
6281
- setSeenAt(value.conversation.team_read_at ?? null);
6301
+ aiEnabledRef.current = value.conversation.ai_mode === "auto";
6302
+ setHumanRequested(value.conversation.ai_mode === "off");
6303
+ setSeenAt(null);
6282
6304
  setMayHaveOlder(value.messages.length >= 50);
6283
6305
  setClaimedAs(c?.support.claimedCustomerName ?? null);
6284
6306
  connectWebSocket();
@@ -6447,7 +6469,7 @@ function useChat(options = {}) {
6447
6469
  const c = clientRef.current;
6448
6470
  const earliest = messagesRef.current[0];
6449
6471
  if (!c || !earliest) return false;
6450
- const result = await c.support.getMessages({ before: earliest.created_at, limit: 50 });
6472
+ const result = await c.support.getMessages({ beforeSequence: earliest.sequence, limit: 50 });
6451
6473
  if (!result.ok) {
6452
6474
  setError(result.error);
6453
6475
  return false;
@@ -20870,6 +20892,7 @@ function KeepConversation({ client }) {
20870
20892
  const [dismissed, setDismissed] = useState(readKeepDismissed);
20871
20893
  const [contact, setContact] = useState("");
20872
20894
  const [code, setCode] = useState("");
20895
+ const [challengeId, setChallengeId] = useState(null);
20873
20896
  const [busy, setBusy] = useState(false);
20874
20897
  const [verifyError, setVerifyError] = useState(null);
20875
20898
  if (dismissed) return null;
@@ -20882,6 +20905,7 @@ function KeepConversation({ client }) {
20882
20905
  const result = await client.link.requestOtp({ contact: trimmed, contact_type: contactType });
20883
20906
  setBusy(false);
20884
20907
  if (result.ok) {
20908
+ setChallengeId(result.value.challenge_id);
20885
20909
  setCode("");
20886
20910
  setStep("code");
20887
20911
  } else {
@@ -20889,10 +20913,11 @@ function KeepConversation({ client }) {
20889
20913
  }
20890
20914
  };
20891
20915
  const verify = async (value) => {
20892
- if (value.length !== 6 || busy) return;
20916
+ if (value.length !== 6 || busy || challengeId === null) return;
20893
20917
  setBusy(true);
20894
20918
  setVerifyError(null);
20895
20919
  const result = await client.link.verifyOtp({
20920
+ ...challengeId === void 0 ? {} : { challenge_id: challengeId },
20896
20921
  contact: contact.trim(),
20897
20922
  contact_type: contactType,
20898
20923
  otp_code: value
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { b6 as ProductInputField } from './product-Byf0unSy.mjs';
2
+ import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-g0HFkEDU.mjs';
3
3
 
4
4
  interface Clock {
5
5
  now(): Date;
@@ -289,6 +289,7 @@ interface MockOrder {
289
289
  items: unknown[];
290
290
  applied_discount_ids: string[];
291
291
  applied_discount_codes: string[];
292
+ payment_id?: string;
292
293
  payment_reference?: string;
293
294
  pickup_time?: string;
294
295
  metadata?: Record<string, unknown>;
@@ -582,7 +583,7 @@ interface AuthService {
582
583
  expires_at: string;
583
584
  code_hint?: string;
584
585
  };
585
- verifyOtp(contact: string, code: string): Session;
586
+ verifyOtp(contact: string, code: string, challengeId?: string): Session;
586
587
  logout(token: string): void;
587
588
  updateProfile(token: string, profile: {
588
589
  name?: string;
@@ -731,14 +732,7 @@ interface CartService {
731
732
 
732
733
  interface CheckoutService {
733
734
  process(session: Session, body: CheckoutBody): CheckoutResult;
734
- authorize(body: {
735
- order_id: string;
736
- otp?: string;
737
- pin?: string;
738
- }): {
739
- status: string;
740
- order_id: string;
741
- };
735
+ authorize(body: SubmitAuthorizationInput): CheckoutResult;
742
736
  }
743
737
  interface CheckoutBody {
744
738
  cart_id: string;
@@ -765,12 +759,19 @@ interface CheckoutBody {
765
759
  interface CheckoutResult {
766
760
  order_id: string;
767
761
  order_number: string;
762
+ payment_id?: string;
768
763
  payment_status: string;
769
764
  payment_reference?: string;
770
765
  requires_authorization: boolean;
771
766
  authorization_type?: "otp" | "pin" | "phone" | "birthday" | "address";
772
767
  next_action: {
773
768
  type: "none";
769
+ } | {
770
+ type: "card_popup";
771
+ provider: string;
772
+ client_secret: string;
773
+ public_key: string;
774
+ provider_account_id?: string;
774
775
  } | {
775
776
  type: "redirect";
776
777
  authorization_url: string;
@@ -778,6 +779,8 @@ interface CheckoutResult {
778
779
  type: "authorization";
779
780
  authorization_type: string;
780
781
  display_text?: string;
782
+ } | {
783
+ type: "poll";
781
784
  };
782
785
  provider?: string;
783
786
  authorization_url?: string;
@@ -916,6 +919,7 @@ interface MockDeliveryOption {
916
919
  name: string;
917
920
  description?: string;
918
921
  fee: string;
922
+ fee_status: "priced" | "arranged";
919
923
  currency: string;
920
924
  free_delivery_applied: boolean;
921
925
  free_over_amount?: string;
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { b6 as ProductInputField } from './product-Byf0unSy.js';
2
+ import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-g0HFkEDU.js';
3
3
 
4
4
  interface Clock {
5
5
  now(): Date;
@@ -289,6 +289,7 @@ interface MockOrder {
289
289
  items: unknown[];
290
290
  applied_discount_ids: string[];
291
291
  applied_discount_codes: string[];
292
+ payment_id?: string;
292
293
  payment_reference?: string;
293
294
  pickup_time?: string;
294
295
  metadata?: Record<string, unknown>;
@@ -582,7 +583,7 @@ interface AuthService {
582
583
  expires_at: string;
583
584
  code_hint?: string;
584
585
  };
585
- verifyOtp(contact: string, code: string): Session;
586
+ verifyOtp(contact: string, code: string, challengeId?: string): Session;
586
587
  logout(token: string): void;
587
588
  updateProfile(token: string, profile: {
588
589
  name?: string;
@@ -731,14 +732,7 @@ interface CartService {
731
732
 
732
733
  interface CheckoutService {
733
734
  process(session: Session, body: CheckoutBody): CheckoutResult;
734
- authorize(body: {
735
- order_id: string;
736
- otp?: string;
737
- pin?: string;
738
- }): {
739
- status: string;
740
- order_id: string;
741
- };
735
+ authorize(body: SubmitAuthorizationInput): CheckoutResult;
742
736
  }
743
737
  interface CheckoutBody {
744
738
  cart_id: string;
@@ -765,12 +759,19 @@ interface CheckoutBody {
765
759
  interface CheckoutResult {
766
760
  order_id: string;
767
761
  order_number: string;
762
+ payment_id?: string;
768
763
  payment_status: string;
769
764
  payment_reference?: string;
770
765
  requires_authorization: boolean;
771
766
  authorization_type?: "otp" | "pin" | "phone" | "birthday" | "address";
772
767
  next_action: {
773
768
  type: "none";
769
+ } | {
770
+ type: "card_popup";
771
+ provider: string;
772
+ client_secret: string;
773
+ public_key: string;
774
+ provider_account_id?: string;
774
775
  } | {
775
776
  type: "redirect";
776
777
  authorization_url: string;
@@ -778,6 +779,8 @@ interface CheckoutResult {
778
779
  type: "authorization";
779
780
  authorization_type: string;
780
781
  display_text?: string;
782
+ } | {
783
+ type: "poll";
781
784
  };
782
785
  provider?: string;
783
786
  authorization_url?: string;
@@ -916,6 +919,7 @@ interface MockDeliveryOption {
916
919
  name: string;
917
920
  description?: string;
918
921
  fee: string;
922
+ fee_status: "priced" | "arranged";
919
923
  currency: string;
920
924
  free_delivery_applied: boolean;
921
925
  free_over_amount?: string;
package/dist/server.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { af as CimplifyClient } from './client-BizGfqB7.mjs';
2
- export { J as CacheOptions, cD as ReadRequestOptions, c_ as Result } from './client-BizGfqB7.mjs';
3
- export { S as Category, V as CimplifyError, W as Collection, b0 as Product, be as ProductWithDetails } from './product-Byf0unSy.mjs';
1
+ import { ac as CimplifyClient } from './client-D5AoobFc.mjs';
2
+ export { C as CacheOptions, cf as ReadRequestOptions, cB as Result } from './client-D5AoobFc.mjs';
3
+ export { U as Category, X as CimplifyError, Y as Collection, be as Product, bs as ProductWithDetails } from './payment-g0HFkEDU.mjs';
4
4
  import { JWTVerifyResult } from 'jose';
5
- import './payment-l0rkieEQ.mjs';
5
+ import './link-D9iSVxt5.mjs';
6
6
 
7
7
  interface ServerClientOptions {
8
8
  /**
package/dist/server.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { af as CimplifyClient } from './client-B40KFazg.js';
2
- export { J as CacheOptions, cD as ReadRequestOptions, c_ as Result } from './client-B40KFazg.js';
3
- export { S as Category, V as CimplifyError, W as Collection, b0 as Product, be as ProductWithDetails } from './product-Byf0unSy.js';
1
+ import { ac as CimplifyClient } from './client-BuLcOWLv.js';
2
+ export { C as CacheOptions, cf as ReadRequestOptions, cB as Result } from './client-BuLcOWLv.js';
3
+ export { U as Category, X as CimplifyError, Y as Collection, be as Product, bs as ProductWithDetails } from './payment-g0HFkEDU.js';
4
4
  import { JWTVerifyResult } from 'jose';
5
- import './payment-vzNnIi1n.js';
5
+ import './link-D9iSVxt5.js';
6
6
 
7
7
  interface ServerClientOptions {
8
8
  /**
package/dist/server.js CHANGED
@@ -1,9 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkYDA46OZ6_js = require('./chunk-YDA46OZ6.js');
4
- var chunkYER7DIOM_js = require('./chunk-YER7DIOM.js');
5
- require('./chunk-WMEC5JWN.js');
6
- var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
3
+ var chunk5BDYDZ4U_js = require('./chunk-5BDYDZ4U.js');
4
+ require('./chunk-XREIZ56K.js');
5
+ var chunkIQFFSKE2_js = require('./chunk-IQFFSKE2.js');
6
+ require('./chunk-CNN7Z2IP.js');
7
+ require('./chunk-7PDEX54K.js');
8
+ var chunk4BKOKHE3_js = require('./chunk-4BKOKHE3.js');
7
9
  require('./chunk-OWW5GUSB.js');
8
10
  var react = require('react');
9
11
  var jose = require('jose');
@@ -26,7 +28,7 @@ function readEnv(...keys) {
26
28
  var getServerClient = react.cache((opts = {}) => {
27
29
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
28
30
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
29
- const client = chunkYDA46OZ6_js.createCimplifyClient({
31
+ const client = chunk5BDYDZ4U_js.createCimplifyClient({
30
32
  baseUrl,
31
33
  publicKey,
32
34
  suppressPublicKeyWarning: true
@@ -250,7 +252,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
250
252
  var discoveryCache = /* @__PURE__ */ new Map();
251
253
  var jwksCache = /* @__PURE__ */ new Map();
252
254
  function issuerBase(cfg) {
253
- return (cfg.issuer ?? cfg.authUrl ?? chunkYER7DIOM_js.DEFAULT_ISSUER).replace(/\/$/, "");
255
+ return (cfg.issuer ?? cfg.authUrl ?? chunkIQFFSKE2_js.DEFAULT_ISSUER).replace(/\/$/, "");
254
256
  }
255
257
  function cookieName(cfg) {
256
258
  return cfg.cookieName ?? SESSION_COOKIE;
@@ -465,12 +467,12 @@ async function handleOidcCallback(req, opts) {
465
467
  }
466
468
  function readPkceCookie(cookieHeader) {
467
469
  if (!cookieHeader) return null;
468
- const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkYER7DIOM_js.PKCE_COOKIE}=`));
470
+ const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkIQFFSKE2_js.PKCE_COOKIE}=`));
469
471
  if (!match) return null;
470
- return chunkYER7DIOM_js.decodePkceState(match.slice(chunkYER7DIOM_js.PKCE_COOKIE.length + 1));
472
+ return chunkIQFFSKE2_js.decodePkceState(match.slice(chunkIQFFSKE2_js.PKCE_COOKIE.length + 1));
471
473
  }
472
474
  function buildPkceClearCookie() {
473
- return `${chunkYER7DIOM_js.PKCE_COOKIE}=; Path=${chunkYER7DIOM_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
475
+ return `${chunkIQFFSKE2_js.PKCE_COOKIE}=; Path=${chunkIQFFSKE2_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
474
476
  }
475
477
  function safeReturnPath(returnTo, fallback) {
476
478
  if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
@@ -642,7 +644,7 @@ async function handleTokenRefresh(req, cfg) {
642
644
 
643
645
  Object.defineProperty(exports, "CimplifyError", {
644
646
  enumerable: true,
645
- get: function () { return chunkNIOUSKQQ_js.CimplifyError; }
647
+ get: function () { return chunk4BKOKHE3_js.CimplifyError; }
646
648
  });
647
649
  exports.CACHE_LIFE_DEFAULT = CACHE_LIFE_DEFAULT;
648
650
  exports.CACHE_LIFE_PROBE = CACHE_LIFE_PROBE;
package/dist/server.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import { createCimplifyClient } from './chunk-DKLHCZ5M.mjs';
2
- import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-Z3K2D3TE.mjs';
3
- import './chunk-DLW3RWRK.mjs';
4
- export { CimplifyError } from './chunk-O3YUHLZL.mjs';
1
+ import { createCimplifyClient } from './chunk-OKADBZAI.mjs';
2
+ import './chunk-U4MW6PYU.mjs';
3
+ import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-OCCNG6MO.mjs';
4
+ import './chunk-GOHSXBKW.mjs';
5
+ import './chunk-DYIAX3WI.mjs';
6
+ export { CimplifyError } from './chunk-H3RATH4B.mjs';
5
7
  import './chunk-3G6RQLXK.mjs';
6
8
  import { cache } from 'react';
7
9
  import { jwtVerify, createRemoteJWKSet } from 'jose';
@@ -1,6 +1,6 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-DqbZh8Bk.mjs';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-BkVhOIwn.mjs';
2
2
  import 'hono';
3
- import '../product-Byf0unSy.mjs';
3
+ import '../payment-g0HFkEDU.mjs';
4
4
 
5
5
  interface MswHandlerSetup {
6
6
  handlers: unknown[];
@@ -1,6 +1,6 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-Cj40R2ZD.js';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-DKK_D-PP.js';
2
2
  import 'hono';
3
- import '../product-Byf0unSy.js';
3
+ import '../payment-g0HFkEDU.js';
4
4
 
5
5
  interface MswHandlerSetup {
6
6
  handlers: unknown[];
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkEAZGA7LD_js = require('../chunk-EAZGA7LD.js');
3
+ var chunkYVAEY3VC_js = require('../chunk-YVAEY3VC.js');
4
4
  require('../chunk-XREIZ56K.js');
5
- require('../chunk-NIOUSKQQ.js');
5
+ require('../chunk-CNN7Z2IP.js');
6
+ require('../chunk-4BKOKHE3.js');
6
7
  require('../chunk-OWW5GUSB.js');
7
8
 
8
9
  // src/mock/msw.ts
9
10
  async function createMswHandlers(options = {}) {
10
11
  const baseUrl = options.baseUrl ?? "http://localhost:8787";
11
- const handle = chunkEAZGA7LD_js.createMockApp(options);
12
+ const handle = chunkYVAEY3VC_js.createMockApp(options);
12
13
  const msw = await import('msw').catch(() => {
13
14
  throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
14
15
  });
@@ -1,6 +1,7 @@
1
- import { createMockApp } from '../chunk-DCMXUKDQ.mjs';
1
+ import { createMockApp } from '../chunk-2WPVUIHX.mjs';
2
2
  import '../chunk-U4MW6PYU.mjs';
3
- import '../chunk-O3YUHLZL.mjs';
3
+ import '../chunk-GOHSXBKW.mjs';
4
+ import '../chunk-H3RATH4B.mjs';
4
5
  import '../chunk-3G6RQLXK.mjs';
5
6
 
6
7
  // src/mock/msw.ts
@@ -1,10 +1,10 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-BdErclfU.mjs';
3
- import { C as CreateAppOptions } from '../server-DqbZh8Bk.mjs';
4
- export { S as SeedName } from '../server-DqbZh8Bk.mjs';
5
- import '../client-BizGfqB7.mjs';
6
- import '../product-Byf0unSy.mjs';
7
- import '../payment-l0rkieEQ.mjs';
2
+ import { T as TestClientHandle } from '../client-fM716k7G.mjs';
3
+ import { C as CreateAppOptions } from '../server-BkVhOIwn.mjs';
4
+ export { S as SeedName } from '../server-BkVhOIwn.mjs';
5
+ import '../client-D5AoobFc.mjs';
6
+ import '../payment-g0HFkEDU.mjs';
7
+ import '../link-D9iSVxt5.mjs';
8
8
  import 'hono';
9
9
 
10
10
  /**
@@ -1,10 +1,10 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-nsiMwuC1.js';
3
- import { C as CreateAppOptions } from '../server-Cj40R2ZD.js';
4
- export { S as SeedName } from '../server-Cj40R2ZD.js';
5
- import '../client-B40KFazg.js';
6
- import '../product-Byf0unSy.js';
7
- import '../payment-vzNnIi1n.js';
2
+ import { T as TestClientHandle } from '../client-BVNWjk6W.js';
3
+ import { C as CreateAppOptions } from '../server-DKK_D-PP.js';
4
+ export { S as SeedName } from '../server-DKK_D-PP.js';
5
+ import '../client-BuLcOWLv.js';
6
+ import '../payment-g0HFkEDU.js';
7
+ import '../link-D9iSVxt5.js';
8
8
  import 'hono';
9
9
 
10
10
  /**
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkLOWSMGRT_js = require('../chunk-LOWSMGRT.js');
4
- require('../chunk-EAZGA7LD.js');
3
+ var chunkE4K2VQDD_js = require('../chunk-E4K2VQDD.js');
4
+ require('../chunk-YVAEY3VC.js');
5
+ require('../chunk-5BDYDZ4U.js');
5
6
  require('../chunk-XREIZ56K.js');
6
- require('../chunk-YDA46OZ6.js');
7
- require('../chunk-YER7DIOM.js');
8
- require('../chunk-WMEC5JWN.js');
9
- require('../chunk-NIOUSKQQ.js');
7
+ require('../chunk-IQFFSKE2.js');
8
+ require('../chunk-CNN7Z2IP.js');
9
+ require('../chunk-7PDEX54K.js');
10
+ require('../chunk-4BKOKHE3.js');
10
11
  require('../chunk-OWW5GUSB.js');
11
12
  var vitest = require('vitest');
12
13
 
@@ -21,11 +22,11 @@ var PLACEHOLDER_PHRASES = [
21
22
  function createBrandSuite(opts) {
22
23
  vitest.describe(opts.label ?? "brand schema", () => {
23
24
  vitest.it("conforms to the Cimplify brand contract", () => {
24
- vitest.expect(() => chunkLOWSMGRT_js.assertBrand(opts.brand)).not.toThrow();
25
+ vitest.expect(() => chunkE4K2VQDD_js.assertBrand(opts.brand)).not.toThrow();
25
26
  });
26
27
  vitest.it("declares a known mock seed", () => {
27
28
  const b = opts.brand;
28
- vitest.expect(chunkLOWSMGRT_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
29
+ vitest.expect(chunkE4K2VQDD_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
29
30
  });
30
31
  vitest.it("has no placeholder copy left in", () => {
31
32
  const offenders = [];
@@ -57,7 +58,7 @@ ${msg}`);
57
58
  vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
58
59
  });
59
60
  vitest.it("zod-parses cleanly", () => {
60
- const result = chunkLOWSMGRT_js.BrandSchema.safeParse(opts.brand);
61
+ const result = chunkE4K2VQDD_js.BrandSchema.safeParse(opts.brand);
61
62
  if (!result.success) {
62
63
  throw new Error(
63
64
  "Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
@@ -72,23 +73,23 @@ function createCartFlowSuite(opts = {}) {
72
73
  vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
73
74
  let h;
74
75
  vitest.beforeEach(() => {
75
- h = chunkLOWSMGRT_js.createTestClient(opts);
76
+ h = chunkE4K2VQDD_js.createTestClient(opts);
76
77
  });
77
78
  vitest.afterEach(() => h.dispose());
78
79
  vitest.it("starts with an empty cart matching the canonical shape", async () => {
79
80
  const res = await h.client.cart.get();
80
81
  vitest.expect(res.ok).toBe(true);
81
82
  if (!res.ok) return;
82
- vitest.expect(() => chunkLOWSMGRT_js.assertCart(res.value)).not.toThrow();
83
+ vitest.expect(() => chunkE4K2VQDD_js.assertCart(res.value)).not.toThrow();
83
84
  vitest.expect(res.value.items).toHaveLength(0);
84
85
  });
85
86
  vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
86
- const { product, variantId } = await chunkLOWSMGRT_js.fixtures.addFirstProduct(h.client);
87
+ const { product, variantId } = await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
87
88
  vitest.expect(product.id).toBeTruthy();
88
89
  const get = await h.client.cart.get();
89
90
  vitest.expect(get.ok).toBe(true);
90
91
  if (!get.ok) return;
91
- vitest.expect(() => chunkLOWSMGRT_js.assertCart(get.value)).not.toThrow();
92
+ vitest.expect(() => chunkE4K2VQDD_js.assertCart(get.value)).not.toThrow();
92
93
  vitest.expect(get.value.items).toHaveLength(1);
93
94
  vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
94
95
  if (variantId) {
@@ -99,8 +100,8 @@ function createCartFlowSuite(opts = {}) {
99
100
  vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
100
101
  });
101
102
  vitest.it("dedupes by line_key when adding the same product twice", async () => {
102
- await chunkLOWSMGRT_js.fixtures.addFirstProduct(h.client);
103
- await chunkLOWSMGRT_js.fixtures.addFirstProduct(h.client);
103
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
104
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
104
105
  const res = await h.client.cart.get();
105
106
  vitest.expect(res.ok).toBe(true);
106
107
  if (!res.ok) return;
@@ -108,7 +109,7 @@ function createCartFlowSuite(opts = {}) {
108
109
  vitest.expect(res.value.items[0]?.quantity).toBe(2);
109
110
  });
110
111
  vitest.it("removes items and zeroes the subtotal", async () => {
111
- await chunkLOWSMGRT_js.fixtures.addFirstProduct(h.client);
112
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
112
113
  const before = await h.client.cart.get();
113
114
  if (!before.ok) throw before.error;
114
115
  const itemId = before.value.items[0]?.id;
@@ -134,28 +135,28 @@ function createContractSuite(opts = {}) {
134
135
  vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
135
136
  let h;
136
137
  vitest.beforeEach(() => {
137
- h = chunkLOWSMGRT_js.createTestClient(opts);
138
+ h = chunkE4K2VQDD_js.createTestClient(opts);
138
139
  });
139
140
  vitest.afterEach(() => h.dispose());
140
141
  vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
141
- const result = chunkLOWSMGRT_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
142
+ const result = chunkE4K2VQDD_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
142
143
  vitest.expect(result.success).toBe(true);
143
144
  });
144
145
  vitest.it("AddItemPayload schema rejects negative quantity", () => {
145
- const result = chunkLOWSMGRT_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
146
+ const result = chunkE4K2VQDD_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
146
147
  vitest.expect(result.success).toBe(false);
147
148
  });
148
149
  vitest.it("AddItemPayload schema rejects empty item_id", () => {
149
- const result = chunkLOWSMGRT_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
150
+ const result = chunkE4K2VQDD_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
150
151
  vitest.expect(result.success).toBe(false);
151
152
  });
152
153
  vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
153
- const { product } = await chunkLOWSMGRT_js.fixtures.addFirstProduct(h.client);
154
+ const { product } = await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
154
155
  const get = await h.client.cart.get();
155
156
  if (!get.ok) throw get.error;
156
157
  vitest.expect(get.value.items.length).toBeGreaterThan(0);
157
158
  for (const item of get.value.items) {
158
- const result = chunkLOWSMGRT_js.CartItemSchema.safeParse(item);
159
+ const result = chunkE4K2VQDD_js.CartItemSchema.safeParse(item);
159
160
  if (!result.success) {
160
161
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
161
162
  throw new Error(`Cart item shape mismatch for ${product.name}:
@@ -165,19 +166,19 @@ ${issues}`);
165
166
  }
166
167
  });
167
168
  vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
168
- await chunkLOWSMGRT_js.fixtures.addFirstProduct(h.client);
169
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
169
170
  const cartRes = await h.client.cart.get();
170
171
  if (!cartRes.ok) throw cartRes.error;
171
172
  const checkout = await h.client.checkout.process({
172
173
  cart_id: cartRes.value.id,
173
- customer: chunkLOWSMGRT_js.fixtures.customer(),
174
+ customer: chunkE4K2VQDD_js.fixtures.customer(),
174
175
  order_type: "delivery",
175
176
  payment_method: "mobile_money",
176
177
  mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
177
178
  });
178
179
  vitest.expect(checkout.ok).toBe(true);
179
180
  if (!checkout.ok) return;
180
- const result = chunkLOWSMGRT_js.CheckoutResponseSchema.safeParse(checkout.value);
181
+ const result = chunkE4K2VQDD_js.CheckoutResponseSchema.safeParse(checkout.value);
181
182
  if (!result.success) {
182
183
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
183
184
  throw new Error(`CheckoutResponse shape mismatch: