@cimplify/sdk 0.103.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 (65) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/advanced.js +22 -22
  4. package/dist/advanced.mjs +3 -3
  5. package/dist/{chunk-C2JSNJUC.mjs → chunk-2WPVUIHX.mjs} +52 -11
  6. package/dist/{chunk-JG5CQNCB.js → chunk-4BKOKHE3.js} +4 -0
  7. package/dist/{chunk-R6OLQ33I.js → chunk-5BDYDZ4U.js} +239 -87
  8. package/dist/{chunk-H7ACMHM3.mjs → chunk-5RT4HYMP.mjs} +32 -4
  9. package/dist/{chunk-NNG6IFFX.js → chunk-7PDEX54K.js} +3 -3
  10. package/dist/{chunk-M4URVKHE.mjs → chunk-DYIAX3WI.mjs} +1 -1
  11. package/dist/{chunk-QOWPGS7Z.js → chunk-E4K2VQDD.js} +35 -5
  12. package/dist/{chunk-VNPEYLB2.mjs → chunk-H3RATH4B.mjs} +4 -0
  13. package/dist/{chunk-JSWJ4XDE.js → chunk-IQFFSKE2.js} +315 -108
  14. package/dist/{chunk-J6PNHDHL.mjs → chunk-OCCNG6MO.mjs} +284 -77
  15. package/dist/{chunk-GERXZQSX.mjs → chunk-OKADBZAI.mjs} +171 -20
  16. package/dist/{chunk-VIL6IQCG.js → chunk-YVAEY3VC.js} +54 -13
  17. package/dist/{client-Dqg2mc-7.d.ts → client-BVNWjk6W.d.ts} +2 -2
  18. package/dist/{client-BfpNjJ_a.d.mts → client-BuLcOWLv.d.ts} +115 -23
  19. package/dist/{client-DHBwvh7U.d.ts → client-D5AoobFc.d.mts} +115 -23
  20. package/dist/{client-DpqRobY9.d.mts → client-fM716k7G.d.mts} +2 -2
  21. package/dist/{index-C8uDqLwJ.d.ts → index-BtcoqrY1.d.ts} +3 -3
  22. package/dist/{index-e2y6AK70.d.mts → index-D7Tf3v7c.d.mts} +3 -3
  23. package/dist/index.d.mts +10 -8
  24. package/dist/index.d.ts +10 -8
  25. package/dist/index.js +107 -106
  26. package/dist/index.mjs +6 -5
  27. package/dist/{link-cuNVYc2s.d.mts → link-D9iSVxt5.d.mts} +12 -1
  28. package/dist/{link-cuNVYc2s.d.ts → link-D9iSVxt5.d.ts} +12 -1
  29. package/dist/mock/cli.mjs +53 -10
  30. package/dist/mock/library.js +53 -10
  31. package/dist/mock/library.mjs +53 -10
  32. package/dist/mock/msw.js +53 -10
  33. package/dist/mock/msw.mjs +53 -10
  34. package/dist/{payment-H5LoIvXU.d.mts → payment-g0HFkEDU.d.mts} +519 -54
  35. package/dist/{payment-H5LoIvXU.d.ts → payment-g0HFkEDU.d.ts} +519 -54
  36. package/dist/{price-C2RqscMY.d.ts → price-BLIeAb8K.d.ts} +1 -1
  37. package/dist/{price-BvePgDXe.d.mts → price-Czq_cTC_.d.mts} +1 -1
  38. package/dist/react.d.mts +4 -4
  39. package/dist/react.d.ts +4 -4
  40. package/dist/react.js +193 -169
  41. package/dist/react.mjs +54 -30
  42. package/dist/{server-C7FyLdrz.d.mts → server-BkVhOIwn.d.mts} +4 -2
  43. package/dist/{server-DoXIpSd7.d.ts → server-DKK_D-PP.d.ts} +4 -2
  44. package/dist/server.d.mts +4 -4
  45. package/dist/server.d.ts +4 -4
  46. package/dist/server.js +11 -10
  47. package/dist/server.mjs +5 -4
  48. package/dist/testing/msw.d.mts +2 -2
  49. package/dist/testing/msw.d.ts +2 -2
  50. package/dist/testing/msw.js +3 -3
  51. package/dist/testing/msw.mjs +2 -2
  52. package/dist/testing/suite.d.mts +6 -6
  53. package/dist/testing/suite.d.ts +6 -6
  54. package/dist/testing/suite.js +25 -25
  55. package/dist/testing/suite.mjs +6 -6
  56. package/dist/testing.d.mts +46 -6
  57. package/dist/testing.d.ts +46 -6
  58. package/dist/testing.js +94 -82
  59. package/dist/testing.mjs +13 -9
  60. package/dist/utils.d.mts +4 -4
  61. package/dist/utils.d.ts +4 -4
  62. package/dist/utils.js +31 -31
  63. package/dist/utils.mjs +2 -2
  64. package/package.json +1 -1
  65. package/registry/chat-widget.json +1 -1
package/dist/react.mjs CHANGED
@@ -1,13 +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-GERXZQSX.mjs';
7
- import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-J6PNHDHL.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
8
  import './chunk-GOHSXBKW.mjs';
9
- import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-M4URVKHE.mjs';
10
- import { isSupportedCurrency, currencyCode, CimplifyError } from './chunk-VNPEYLB2.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';
11
11
  import './chunk-3G6RQLXK.mjs';
12
12
  import React14, { createContext, lazy, memo, Suspense, useMemo, useContext, useRef, useCallback, useState, useEffect, useId, useSyncExternalStore } from 'react';
13
13
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -6139,7 +6139,7 @@ function useChat(options = {}) {
6139
6139
  if (!c) return;
6140
6140
  const last = lastConfirmedMessage();
6141
6141
  const result = await c.support.getMessages({
6142
- after: last?.created_at,
6142
+ afterSequence: last?.sequence,
6143
6143
  limit: 50
6144
6144
  });
6145
6145
  if (result.ok && result.value.length > 0) {
@@ -6182,9 +6182,9 @@ function useChat(options = {}) {
6182
6182
  );
6183
6183
  return mergeMessages(snapshot, extras);
6184
6184
  });
6185
- aiEnabledRef.current = result.value.conversation.ai_enabled;
6186
- setHumanRequested(result.value.conversation.needs_human_review ?? false);
6187
- 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);
6188
6188
  setMayHaveOlder(result.value.messages.length >= 50);
6189
6189
  }, []);
6190
6190
  const connectWebSocket = useCallback(() => {
@@ -6212,23 +6212,36 @@ function useChat(options = {}) {
6212
6212
  ws.onmessage = (event) => {
6213
6213
  try {
6214
6214
  const envelope = JSON.parse(event.data);
6215
- if (envelope.type === "message.created" && envelope.data) {
6216
- appendMessages([envelope.data]);
6217
- } else if (envelope.type === "thread.read") {
6218
- const at = envelope.data?.last_read_at;
6219
- if (at) setSeenAt((prev) => !prev || prev < at ? at : prev);
6220
- } else if (envelope.type === "thread.responding") {
6221
- const active = envelope.data?.active;
6222
- if (active) startAwaitingReply();
6223
- else stopAwaitingReply();
6224
- } else if (envelope.type === "resync") {
6225
- 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;
6226
6241
  const last = lastConfirmedMessage();
6227
- if (latest && (!last || new Date(last.created_at).getTime() < new Date(latest).getTime())) {
6242
+ if (latest === void 0 || !last?.sequence || last.sequence < latest) {
6228
6243
  fetchNewMessages();
6229
6244
  }
6230
- } else if (envelope.type === "rekey") {
6231
- void resyncConversation();
6232
6245
  }
6233
6246
  } catch {
6234
6247
  }
@@ -6249,7 +6262,15 @@ function useChat(options = {}) {
6249
6262
  ws.onerror = () => {
6250
6263
  };
6251
6264
  wsRef.current = ws;
6252
- }, [appendMessages, startPolling, stopPolling, fetchNewMessages, resyncConversation, lastConfirmedMessage]);
6265
+ }, [
6266
+ appendMessages,
6267
+ startPolling,
6268
+ stopPolling,
6269
+ fetchNewMessages,
6270
+ resyncConversation,
6271
+ lastConfirmedMessage,
6272
+ stopAwaitingReply
6273
+ ]);
6253
6274
  const resetConversation = useCallback(() => {
6254
6275
  stopPolling();
6255
6276
  if (wsReconnectTimerRef.current) {
@@ -6277,9 +6298,9 @@ function useChat(options = {}) {
6277
6298
  const c = clientRef.current;
6278
6299
  setMessages(value.messages);
6279
6300
  setConversationOpened(true);
6280
- aiEnabledRef.current = value.conversation.ai_enabled;
6281
- setHumanRequested(value.conversation.needs_human_review ?? false);
6282
- 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);
6283
6304
  setMayHaveOlder(value.messages.length >= 50);
6284
6305
  setClaimedAs(c?.support.claimedCustomerName ?? null);
6285
6306
  connectWebSocket();
@@ -6448,7 +6469,7 @@ function useChat(options = {}) {
6448
6469
  const c = clientRef.current;
6449
6470
  const earliest = messagesRef.current[0];
6450
6471
  if (!c || !earliest) return false;
6451
- const result = await c.support.getMessages({ before: earliest.created_at, limit: 50 });
6472
+ const result = await c.support.getMessages({ beforeSequence: earliest.sequence, limit: 50 });
6452
6473
  if (!result.ok) {
6453
6474
  setError(result.error);
6454
6475
  return false;
@@ -20871,6 +20892,7 @@ function KeepConversation({ client }) {
20871
20892
  const [dismissed, setDismissed] = useState(readKeepDismissed);
20872
20893
  const [contact, setContact] = useState("");
20873
20894
  const [code, setCode] = useState("");
20895
+ const [challengeId, setChallengeId] = useState(null);
20874
20896
  const [busy, setBusy] = useState(false);
20875
20897
  const [verifyError, setVerifyError] = useState(null);
20876
20898
  if (dismissed) return null;
@@ -20883,6 +20905,7 @@ function KeepConversation({ client }) {
20883
20905
  const result = await client.link.requestOtp({ contact: trimmed, contact_type: contactType });
20884
20906
  setBusy(false);
20885
20907
  if (result.ok) {
20908
+ setChallengeId(result.value.challenge_id);
20886
20909
  setCode("");
20887
20910
  setStep("code");
20888
20911
  } else {
@@ -20890,10 +20913,11 @@ function KeepConversation({ client }) {
20890
20913
  }
20891
20914
  };
20892
20915
  const verify = async (value) => {
20893
- if (value.length !== 6 || busy) return;
20916
+ if (value.length !== 6 || busy || challengeId === null) return;
20894
20917
  setBusy(true);
20895
20918
  setVerifyError(null);
20896
20919
  const result = await client.link.verifyOtp({
20920
+ ...challengeId === void 0 ? {} : { challenge_id: challengeId },
20897
20921
  contact: contact.trim(),
20898
20922
  contact_type: contactType,
20899
20923
  otp_code: value
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-H5LoIvXU.mjs';
2
+ import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-g0HFkEDU.mjs';
3
3
 
4
4
  interface Clock {
5
5
  now(): Date;
@@ -583,7 +583,7 @@ interface AuthService {
583
583
  expires_at: string;
584
584
  code_hint?: string;
585
585
  };
586
- verifyOtp(contact: string, code: string): Session;
586
+ verifyOtp(contact: string, code: string, challengeId?: string): Session;
587
587
  logout(token: string): void;
588
588
  updateProfile(token: string, profile: {
589
589
  name?: string;
@@ -771,6 +771,7 @@ interface CheckoutResult {
771
771
  provider: string;
772
772
  client_secret: string;
773
773
  public_key: string;
774
+ provider_account_id?: string;
774
775
  } | {
775
776
  type: "redirect";
776
777
  authorization_url: string;
@@ -918,6 +919,7 @@ interface MockDeliveryOption {
918
919
  name: string;
919
920
  description?: string;
920
921
  fee: string;
922
+ fee_status: "priced" | "arranged";
921
923
  currency: string;
922
924
  free_delivery_applied: boolean;
923
925
  free_over_amount?: string;
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-H5LoIvXU.js';
2
+ import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-g0HFkEDU.js';
3
3
 
4
4
  interface Clock {
5
5
  now(): Date;
@@ -583,7 +583,7 @@ interface AuthService {
583
583
  expires_at: string;
584
584
  code_hint?: string;
585
585
  };
586
- verifyOtp(contact: string, code: string): Session;
586
+ verifyOtp(contact: string, code: string, challengeId?: string): Session;
587
587
  logout(token: string): void;
588
588
  updateProfile(token: string, profile: {
589
589
  name?: string;
@@ -771,6 +771,7 @@ interface CheckoutResult {
771
771
  provider: string;
772
772
  client_secret: string;
773
773
  public_key: string;
774
+ provider_account_id?: string;
774
775
  } | {
775
776
  type: "redirect";
776
777
  authorization_url: string;
@@ -918,6 +919,7 @@ interface MockDeliveryOption {
918
919
  name: string;
919
920
  description?: string;
920
921
  fee: string;
922
+ fee_status: "priced" | "arranged";
921
923
  currency: string;
922
924
  free_delivery_applied: boolean;
923
925
  free_over_amount?: string;
package/dist/server.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { ac as CimplifyClient } from './client-BfpNjJ_a.mjs';
2
- export { C as CacheOptions, cb as ReadRequestOptions, cx as Result } from './client-BfpNjJ_a.mjs';
3
- export { U as Category, X as CimplifyError, Y as Collection, be as Product, bs as ProductWithDetails } from './payment-H5LoIvXU.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 './link-cuNVYc2s.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 { ac as CimplifyClient } from './client-DHBwvh7U.js';
2
- export { C as CacheOptions, cb as ReadRequestOptions, cx as Result } from './client-DHBwvh7U.js';
3
- export { U as Category, X as CimplifyError, Y as Collection, be as Product, bs as ProductWithDetails } from './payment-H5LoIvXU.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 './link-cuNVYc2s.js';
5
+ import './link-D9iSVxt5.js';
6
6
 
7
7
  interface ServerClientOptions {
8
8
  /**
package/dist/server.js CHANGED
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkR6OLQ33I_js = require('./chunk-R6OLQ33I.js');
4
- var chunkJSWJ4XDE_js = require('./chunk-JSWJ4XDE.js');
3
+ var chunk5BDYDZ4U_js = require('./chunk-5BDYDZ4U.js');
4
+ require('./chunk-XREIZ56K.js');
5
+ var chunkIQFFSKE2_js = require('./chunk-IQFFSKE2.js');
5
6
  require('./chunk-CNN7Z2IP.js');
6
- require('./chunk-NNG6IFFX.js');
7
- var chunkJG5CQNCB_js = require('./chunk-JG5CQNCB.js');
7
+ require('./chunk-7PDEX54K.js');
8
+ var chunk4BKOKHE3_js = require('./chunk-4BKOKHE3.js');
8
9
  require('./chunk-OWW5GUSB.js');
9
10
  var react = require('react');
10
11
  var jose = require('jose');
@@ -27,7 +28,7 @@ function readEnv(...keys) {
27
28
  var getServerClient = react.cache((opts = {}) => {
28
29
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
29
30
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
30
- const client = chunkR6OLQ33I_js.createCimplifyClient({
31
+ const client = chunk5BDYDZ4U_js.createCimplifyClient({
31
32
  baseUrl,
32
33
  publicKey,
33
34
  suppressPublicKeyWarning: true
@@ -251,7 +252,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
251
252
  var discoveryCache = /* @__PURE__ */ new Map();
252
253
  var jwksCache = /* @__PURE__ */ new Map();
253
254
  function issuerBase(cfg) {
254
- return (cfg.issuer ?? cfg.authUrl ?? chunkJSWJ4XDE_js.DEFAULT_ISSUER).replace(/\/$/, "");
255
+ return (cfg.issuer ?? cfg.authUrl ?? chunkIQFFSKE2_js.DEFAULT_ISSUER).replace(/\/$/, "");
255
256
  }
256
257
  function cookieName(cfg) {
257
258
  return cfg.cookieName ?? SESSION_COOKIE;
@@ -466,12 +467,12 @@ async function handleOidcCallback(req, opts) {
466
467
  }
467
468
  function readPkceCookie(cookieHeader) {
468
469
  if (!cookieHeader) return null;
469
- const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkJSWJ4XDE_js.PKCE_COOKIE}=`));
470
+ const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkIQFFSKE2_js.PKCE_COOKIE}=`));
470
471
  if (!match) return null;
471
- return chunkJSWJ4XDE_js.decodePkceState(match.slice(chunkJSWJ4XDE_js.PKCE_COOKIE.length + 1));
472
+ return chunkIQFFSKE2_js.decodePkceState(match.slice(chunkIQFFSKE2_js.PKCE_COOKIE.length + 1));
472
473
  }
473
474
  function buildPkceClearCookie() {
474
- return `${chunkJSWJ4XDE_js.PKCE_COOKIE}=; Path=${chunkJSWJ4XDE_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`;
475
476
  }
476
477
  function safeReturnPath(returnTo, fallback) {
477
478
  if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
@@ -643,7 +644,7 @@ async function handleTokenRefresh(req, cfg) {
643
644
 
644
645
  Object.defineProperty(exports, "CimplifyError", {
645
646
  enumerable: true,
646
- get: function () { return chunkJG5CQNCB_js.CimplifyError; }
647
+ get: function () { return chunk4BKOKHE3_js.CimplifyError; }
647
648
  });
648
649
  exports.CACHE_LIFE_DEFAULT = CACHE_LIFE_DEFAULT;
649
650
  exports.CACHE_LIFE_PROBE = CACHE_LIFE_PROBE;
package/dist/server.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import { createCimplifyClient } from './chunk-GERXZQSX.mjs';
2
- import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-J6PNHDHL.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';
3
4
  import './chunk-GOHSXBKW.mjs';
4
- import './chunk-M4URVKHE.mjs';
5
- export { CimplifyError } from './chunk-VNPEYLB2.mjs';
5
+ import './chunk-DYIAX3WI.mjs';
6
+ export { CimplifyError } from './chunk-H3RATH4B.mjs';
6
7
  import './chunk-3G6RQLXK.mjs';
7
8
  import { cache } from 'react';
8
9
  import { jwtVerify, createRemoteJWKSet } from 'jose';
@@ -1,6 +1,6 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-C7FyLdrz.mjs';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-BkVhOIwn.mjs';
2
2
  import 'hono';
3
- import '../payment-H5LoIvXU.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-DoXIpSd7.js';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-DKK_D-PP.js';
2
2
  import 'hono';
3
- import '../payment-H5LoIvXU.js';
3
+ import '../payment-g0HFkEDU.js';
4
4
 
5
5
  interface MswHandlerSetup {
6
6
  handlers: unknown[];
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkVIL6IQCG_js = require('../chunk-VIL6IQCG.js');
3
+ var chunkYVAEY3VC_js = require('../chunk-YVAEY3VC.js');
4
4
  require('../chunk-XREIZ56K.js');
5
5
  require('../chunk-CNN7Z2IP.js');
6
- require('../chunk-JG5CQNCB.js');
6
+ require('../chunk-4BKOKHE3.js');
7
7
  require('../chunk-OWW5GUSB.js');
8
8
 
9
9
  // src/mock/msw.ts
10
10
  async function createMswHandlers(options = {}) {
11
11
  const baseUrl = options.baseUrl ?? "http://localhost:8787";
12
- const handle = chunkVIL6IQCG_js.createMockApp(options);
12
+ const handle = chunkYVAEY3VC_js.createMockApp(options);
13
13
  const msw = await import('msw').catch(() => {
14
14
  throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
15
15
  });
@@ -1,7 +1,7 @@
1
- import { createMockApp } from '../chunk-C2JSNJUC.mjs';
1
+ import { createMockApp } from '../chunk-2WPVUIHX.mjs';
2
2
  import '../chunk-U4MW6PYU.mjs';
3
3
  import '../chunk-GOHSXBKW.mjs';
4
- import '../chunk-VNPEYLB2.mjs';
4
+ import '../chunk-H3RATH4B.mjs';
5
5
  import '../chunk-3G6RQLXK.mjs';
6
6
 
7
7
  // src/mock/msw.ts
@@ -1,10 +1,10 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-DpqRobY9.mjs';
3
- import { C as CreateAppOptions } from '../server-C7FyLdrz.mjs';
4
- export { S as SeedName } from '../server-C7FyLdrz.mjs';
5
- import '../client-BfpNjJ_a.mjs';
6
- import '../payment-H5LoIvXU.mjs';
7
- import '../link-cuNVYc2s.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-Dqg2mc-7.js';
3
- import { C as CreateAppOptions } from '../server-DoXIpSd7.js';
4
- export { S as SeedName } from '../server-DoXIpSd7.js';
5
- import '../client-DHBwvh7U.js';
6
- import '../payment-H5LoIvXU.js';
7
- import '../link-cuNVYc2s.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,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkQOWPGS7Z_js = require('../chunk-QOWPGS7Z.js');
4
- require('../chunk-VIL6IQCG.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-R6OLQ33I.js');
7
- require('../chunk-JSWJ4XDE.js');
7
+ require('../chunk-IQFFSKE2.js');
8
8
  require('../chunk-CNN7Z2IP.js');
9
- require('../chunk-NNG6IFFX.js');
10
- require('../chunk-JG5CQNCB.js');
9
+ require('../chunk-7PDEX54K.js');
10
+ require('../chunk-4BKOKHE3.js');
11
11
  require('../chunk-OWW5GUSB.js');
12
12
  var vitest = require('vitest');
13
13
 
@@ -22,11 +22,11 @@ var PLACEHOLDER_PHRASES = [
22
22
  function createBrandSuite(opts) {
23
23
  vitest.describe(opts.label ?? "brand schema", () => {
24
24
  vitest.it("conforms to the Cimplify brand contract", () => {
25
- vitest.expect(() => chunkQOWPGS7Z_js.assertBrand(opts.brand)).not.toThrow();
25
+ vitest.expect(() => chunkE4K2VQDD_js.assertBrand(opts.brand)).not.toThrow();
26
26
  });
27
27
  vitest.it("declares a known mock seed", () => {
28
28
  const b = opts.brand;
29
- vitest.expect(chunkQOWPGS7Z_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
29
+ vitest.expect(chunkE4K2VQDD_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
30
30
  });
31
31
  vitest.it("has no placeholder copy left in", () => {
32
32
  const offenders = [];
@@ -58,7 +58,7 @@ ${msg}`);
58
58
  vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
59
59
  });
60
60
  vitest.it("zod-parses cleanly", () => {
61
- const result = chunkQOWPGS7Z_js.BrandSchema.safeParse(opts.brand);
61
+ const result = chunkE4K2VQDD_js.BrandSchema.safeParse(opts.brand);
62
62
  if (!result.success) {
63
63
  throw new Error(
64
64
  "Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
@@ -73,23 +73,23 @@ function createCartFlowSuite(opts = {}) {
73
73
  vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
74
74
  let h;
75
75
  vitest.beforeEach(() => {
76
- h = chunkQOWPGS7Z_js.createTestClient(opts);
76
+ h = chunkE4K2VQDD_js.createTestClient(opts);
77
77
  });
78
78
  vitest.afterEach(() => h.dispose());
79
79
  vitest.it("starts with an empty cart matching the canonical shape", async () => {
80
80
  const res = await h.client.cart.get();
81
81
  vitest.expect(res.ok).toBe(true);
82
82
  if (!res.ok) return;
83
- vitest.expect(() => chunkQOWPGS7Z_js.assertCart(res.value)).not.toThrow();
83
+ vitest.expect(() => chunkE4K2VQDD_js.assertCart(res.value)).not.toThrow();
84
84
  vitest.expect(res.value.items).toHaveLength(0);
85
85
  });
86
86
  vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
87
- const { product, variantId } = await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
87
+ const { product, variantId } = await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
88
88
  vitest.expect(product.id).toBeTruthy();
89
89
  const get = await h.client.cart.get();
90
90
  vitest.expect(get.ok).toBe(true);
91
91
  if (!get.ok) return;
92
- vitest.expect(() => chunkQOWPGS7Z_js.assertCart(get.value)).not.toThrow();
92
+ vitest.expect(() => chunkE4K2VQDD_js.assertCart(get.value)).not.toThrow();
93
93
  vitest.expect(get.value.items).toHaveLength(1);
94
94
  vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
95
95
  if (variantId) {
@@ -100,8 +100,8 @@ function createCartFlowSuite(opts = {}) {
100
100
  vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
101
101
  });
102
102
  vitest.it("dedupes by line_key when adding the same product twice", async () => {
103
- await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
104
- await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
103
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
104
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
105
105
  const res = await h.client.cart.get();
106
106
  vitest.expect(res.ok).toBe(true);
107
107
  if (!res.ok) return;
@@ -109,7 +109,7 @@ function createCartFlowSuite(opts = {}) {
109
109
  vitest.expect(res.value.items[0]?.quantity).toBe(2);
110
110
  });
111
111
  vitest.it("removes items and zeroes the subtotal", async () => {
112
- await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
112
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
113
113
  const before = await h.client.cart.get();
114
114
  if (!before.ok) throw before.error;
115
115
  const itemId = before.value.items[0]?.id;
@@ -135,28 +135,28 @@ function createContractSuite(opts = {}) {
135
135
  vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
136
136
  let h;
137
137
  vitest.beforeEach(() => {
138
- h = chunkQOWPGS7Z_js.createTestClient(opts);
138
+ h = chunkE4K2VQDD_js.createTestClient(opts);
139
139
  });
140
140
  vitest.afterEach(() => h.dispose());
141
141
  vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
142
- const result = chunkQOWPGS7Z_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
142
+ const result = chunkE4K2VQDD_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
143
143
  vitest.expect(result.success).toBe(true);
144
144
  });
145
145
  vitest.it("AddItemPayload schema rejects negative quantity", () => {
146
- const result = chunkQOWPGS7Z_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
146
+ const result = chunkE4K2VQDD_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
147
147
  vitest.expect(result.success).toBe(false);
148
148
  });
149
149
  vitest.it("AddItemPayload schema rejects empty item_id", () => {
150
- const result = chunkQOWPGS7Z_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
150
+ const result = chunkE4K2VQDD_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
151
151
  vitest.expect(result.success).toBe(false);
152
152
  });
153
153
  vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
154
- const { product } = await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
154
+ const { product } = await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
155
155
  const get = await h.client.cart.get();
156
156
  if (!get.ok) throw get.error;
157
157
  vitest.expect(get.value.items.length).toBeGreaterThan(0);
158
158
  for (const item of get.value.items) {
159
- const result = chunkQOWPGS7Z_js.CartItemSchema.safeParse(item);
159
+ const result = chunkE4K2VQDD_js.CartItemSchema.safeParse(item);
160
160
  if (!result.success) {
161
161
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
162
162
  throw new Error(`Cart item shape mismatch for ${product.name}:
@@ -166,19 +166,19 @@ ${issues}`);
166
166
  }
167
167
  });
168
168
  vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
169
- await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
169
+ await chunkE4K2VQDD_js.fixtures.addFirstProduct(h.client);
170
170
  const cartRes = await h.client.cart.get();
171
171
  if (!cartRes.ok) throw cartRes.error;
172
172
  const checkout = await h.client.checkout.process({
173
173
  cart_id: cartRes.value.id,
174
- customer: chunkQOWPGS7Z_js.fixtures.customer(),
174
+ customer: chunkE4K2VQDD_js.fixtures.customer(),
175
175
  order_type: "delivery",
176
176
  payment_method: "mobile_money",
177
177
  mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
178
178
  });
179
179
  vitest.expect(checkout.ok).toBe(true);
180
180
  if (!checkout.ok) return;
181
- const result = chunkQOWPGS7Z_js.CheckoutResponseSchema.safeParse(checkout.value);
181
+ const result = chunkE4K2VQDD_js.CheckoutResponseSchema.safeParse(checkout.value);
182
182
  if (!result.success) {
183
183
  const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
184
184
  throw new Error(`CheckoutResponse shape mismatch:
@@ -1,11 +1,11 @@
1
- import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-H7ACMHM3.mjs';
2
- import '../chunk-C2JSNJUC.mjs';
1
+ import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-5RT4HYMP.mjs';
2
+ import '../chunk-2WPVUIHX.mjs';
3
+ import '../chunk-OKADBZAI.mjs';
3
4
  import '../chunk-U4MW6PYU.mjs';
4
- import '../chunk-GERXZQSX.mjs';
5
- import '../chunk-J6PNHDHL.mjs';
5
+ import '../chunk-OCCNG6MO.mjs';
6
6
  import '../chunk-GOHSXBKW.mjs';
7
- import '../chunk-M4URVKHE.mjs';
8
- import '../chunk-VNPEYLB2.mjs';
7
+ import '../chunk-DYIAX3WI.mjs';
8
+ import '../chunk-H3RATH4B.mjs';
9
9
  import '../chunk-3G6RQLXK.mjs';
10
10
  import { describe, it, expect, beforeEach, afterEach } from 'vitest';
11
11