@cimplify/sdk 0.94.1 → 0.94.2

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.
@@ -2486,10 +2486,15 @@ function buildV1(deps) {
2486
2486
  );
2487
2487
  app.post("/support/conversation/messages", async (c) => {
2488
2488
  const body = await c.req.json().catch(() => ({}));
2489
- return tryRoute(
2490
- c,
2491
- () => 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 })
2492
- );
2489
+ return tryRoute(c, () => {
2490
+ const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
2491
+ return deps.support.sendMessage(conversationId, {
2492
+ content: body.content ?? "",
2493
+ content_type: body.content_type,
2494
+ sender_type: body.sender_type,
2495
+ reply_to_message_id: body.reply_to_message_id
2496
+ });
2497
+ });
2493
2498
  });
2494
2499
  app.get(
2495
2500
  "/support/conversation/messages",
@@ -5482,6 +5487,12 @@ function createSupportService(opts) {
5482
5487
  registry.conversations.put(id, conv);
5483
5488
  return conv;
5484
5489
  },
5490
+ ensureConversation(businessId, customerId) {
5491
+ const existing = registry.conversations.list(
5492
+ (c) => c.business_id === businessId && c.customer_id === customerId
5493
+ );
5494
+ return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
5495
+ },
5485
5496
  peekConversation(businessId, customerId) {
5486
5497
  const matches = registry.conversations.list(
5487
5498
  (c) => c.business_id === businessId && c.customer_id === customerId
@@ -2488,10 +2488,15 @@ function buildV1(deps) {
2488
2488
  );
2489
2489
  app.post("/support/conversation/messages", async (c) => {
2490
2490
  const body = await c.req.json().catch(() => ({}));
2491
- return tryRoute(
2492
- c,
2493
- () => 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 })
2494
- );
2491
+ return tryRoute(c, () => {
2492
+ const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
2493
+ return deps.support.sendMessage(conversationId, {
2494
+ content: body.content ?? "",
2495
+ content_type: body.content_type,
2496
+ sender_type: body.sender_type,
2497
+ reply_to_message_id: body.reply_to_message_id
2498
+ });
2499
+ });
2495
2500
  });
2496
2501
  app.get(
2497
2502
  "/support/conversation/messages",
@@ -5484,6 +5489,12 @@ function createSupportService(opts) {
5484
5489
  registry.conversations.put(id, conv);
5485
5490
  return conv;
5486
5491
  },
5492
+ ensureConversation(businessId, customerId) {
5493
+ const existing = registry.conversations.list(
5494
+ (c) => c.business_id === businessId && c.customer_id === customerId
5495
+ );
5496
+ return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
5497
+ },
5487
5498
  peekConversation(businessId, customerId) {
5488
5499
  const matches = registry.conversations.list(
5489
5500
  (c) => c.business_id === businessId && c.customer_id === customerId
@@ -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
  var chunkQLGZIBRO_js = require('./chunk-QLGZIBRO.js');
5
5
  var zod = require('zod');
6
6
 
@@ -600,7 +600,7 @@ async function toForwardedRequest(input, init) {
600
600
  };
601
601
  }
602
602
  function createTestClient(options = {}) {
603
- const mock = chunkXVOHMOGU_js.createMockApp(options);
603
+ const mock = chunkFECGCIVV_js.createMockApp(options);
604
604
  let sessionToken;
605
605
  const fetchImpl = async (input, init) => {
606
606
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
@@ -1,4 +1,4 @@
1
- import { createMockApp } from './chunk-BRYMPBEN.mjs';
1
+ import { createMockApp } from './chunk-7TEMLVDT.mjs';
2
2
  import { createCimplifyClient } from './chunk-FKARGZK3.mjs';
3
3
  import { z } from 'zod';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { af as CimplifyClient } from './client-BTL9d_nN.mjs';
2
- import { A as AppHandle, C as CreateAppOptions } from './server-BN9ZCAKT.mjs';
2
+ import { A as AppHandle, C as CreateAppOptions } from './server-HVDbbqR9.mjs';
3
3
 
4
4
  /**
5
5
  * Test client + fixtures.
@@ -1,5 +1,5 @@
1
1
  import { af as CimplifyClient } from './client-BX30FAWZ.js';
2
- import { A as AppHandle, C as CreateAppOptions } from './server-DDGbfW_S.js';
2
+ import { A as AppHandle, C as CreateAppOptions } from './server-JBuTPY-j.js';
3
3
 
4
4
  /**
5
5
  * Test client + fixtures.
package/dist/mock/cli.mjs CHANGED
@@ -3496,10 +3496,15 @@ function buildV1(deps) {
3496
3496
  );
3497
3497
  app.post("/support/conversation/messages", async (c) => {
3498
3498
  const body = await c.req.json().catch(() => ({}));
3499
- return tryRoute(
3500
- c,
3501
- () => 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 })
3502
- );
3499
+ return tryRoute(c, () => {
3500
+ const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
3501
+ return deps.support.sendMessage(conversationId, {
3502
+ content: body.content ?? "",
3503
+ content_type: body.content_type,
3504
+ sender_type: body.sender_type,
3505
+ reply_to_message_id: body.reply_to_message_id
3506
+ });
3507
+ });
3503
3508
  });
3504
3509
  app.get(
3505
3510
  "/support/conversation/messages",
@@ -6514,6 +6519,12 @@ function createSupportService(opts) {
6514
6519
  registry.conversations.put(id, conv);
6515
6520
  return conv;
6516
6521
  },
6522
+ ensureConversation(businessId, customerId) {
6523
+ const existing = registry.conversations.list(
6524
+ (c) => c.business_id === businessId && c.customer_id === customerId
6525
+ );
6526
+ return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
6527
+ },
6517
6528
  peekConversation(businessId, customerId) {
6518
6529
  const matches = registry.conversations.list(
6519
6530
  (c) => c.business_id === businessId && c.customer_id === customerId
@@ -2558,10 +2558,15 @@ function buildV1(deps) {
2558
2558
  );
2559
2559
  app.post("/support/conversation/messages", async (c) => {
2560
2560
  const body = await c.req.json().catch(() => ({}));
2561
- return tryRoute(
2562
- c,
2563
- () => 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 })
2564
- );
2561
+ return tryRoute(c, () => {
2562
+ const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
2563
+ return deps.support.sendMessage(conversationId, {
2564
+ content: body.content ?? "",
2565
+ content_type: body.content_type,
2566
+ sender_type: body.sender_type,
2567
+ reply_to_message_id: body.reply_to_message_id
2568
+ });
2569
+ });
2565
2570
  });
2566
2571
  app.get(
2567
2572
  "/support/conversation/messages",
@@ -5576,6 +5581,12 @@ function createSupportService(opts) {
5576
5581
  registry.conversations.put(id, conv);
5577
5582
  return conv;
5578
5583
  },
5584
+ ensureConversation(businessId, customerId) {
5585
+ const existing = registry.conversations.list(
5586
+ (c) => c.business_id === businessId && c.customer_id === customerId
5587
+ );
5588
+ return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
5589
+ },
5579
5590
  peekConversation(businessId, customerId) {
5580
5591
  const matches = registry.conversations.list(
5581
5592
  (c) => c.business_id === businessId && c.customer_id === customerId
@@ -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.js CHANGED
@@ -1137,6 +1137,23 @@ function preconnectOrigin(url, crossOrigin) {
1137
1137
  if (crossOrigin) link.crossOrigin = crossOrigin;
1138
1138
  document.head.appendChild(link);
1139
1139
  }
1140
+ function subscribeToPathChanges(onChange) {
1141
+ const { pushState, replaceState } = window.history;
1142
+ window.history.pushState = function(...args) {
1143
+ pushState.apply(this, args);
1144
+ onChange();
1145
+ };
1146
+ window.history.replaceState = function(...args) {
1147
+ replaceState.apply(this, args);
1148
+ onChange();
1149
+ };
1150
+ window.addEventListener("popstate", onChange);
1151
+ return () => {
1152
+ window.history.pushState = pushState;
1153
+ window.history.replaceState = replaceState;
1154
+ window.removeEventListener("popstate", onChange);
1155
+ };
1156
+ }
1140
1157
  function usePageViewTracking(client, enabled) {
1141
1158
  React14.useEffect(() => {
1142
1159
  if (!enabled || typeof window === "undefined") return;
@@ -1151,21 +1168,7 @@ function usePageViewTracking(client, enabled) {
1151
1168
  }
1152
1169
  };
1153
1170
  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
- };
1171
+ return subscribeToPathChanges(record);
1169
1172
  }, [client, enabled]);
1170
1173
  }
1171
1174
  var LOCATION_STORAGE_KEY = "cimplify_location_id";
@@ -17419,12 +17422,12 @@ function Panel({
17419
17422
  }
17420
17423
  ),
17421
17424
  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(
17425
+ /* @__PURE__ */ jsxRuntime.jsx(
17423
17426
  ChatInput,
17424
17427
  {
17425
17428
  placeholder,
17426
17429
  isSending,
17427
- onSend,
17430
+ onSend: isActive ? onSend : onStartConversation,
17428
17431
  onAttach,
17429
17432
  className: classNames?.input
17430
17433
  }
package/dist/react.mjs CHANGED
@@ -1113,6 +1113,23 @@ function preconnectOrigin(url, crossOrigin) {
1113
1113
  if (crossOrigin) link.crossOrigin = crossOrigin;
1114
1114
  document.head.appendChild(link);
1115
1115
  }
1116
+ function subscribeToPathChanges(onChange) {
1117
+ const { pushState, replaceState } = window.history;
1118
+ window.history.pushState = function(...args) {
1119
+ pushState.apply(this, args);
1120
+ onChange();
1121
+ };
1122
+ window.history.replaceState = function(...args) {
1123
+ replaceState.apply(this, args);
1124
+ onChange();
1125
+ };
1126
+ window.addEventListener("popstate", onChange);
1127
+ return () => {
1128
+ window.history.pushState = pushState;
1129
+ window.history.replaceState = replaceState;
1130
+ window.removeEventListener("popstate", onChange);
1131
+ };
1132
+ }
1116
1133
  function usePageViewTracking(client, enabled) {
1117
1134
  useEffect(() => {
1118
1135
  if (!enabled || typeof window === "undefined") return;
@@ -1127,21 +1144,7 @@ function usePageViewTracking(client, enabled) {
1127
1144
  }
1128
1145
  };
1129
1146
  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
- };
1147
+ return subscribeToPathChanges(record);
1145
1148
  }, [client, enabled]);
1146
1149
  }
1147
1150
  var LOCATION_STORAGE_KEY = "cimplify_location_id";
@@ -17395,12 +17398,12 @@ function Panel({
17395
17398
  }
17396
17399
  ),
17397
17400
  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(
17401
+ /* @__PURE__ */ jsx(
17399
17402
  ChatInput,
17400
17403
  {
17401
17404
  placeholder,
17402
17405
  isSending,
17403
- onSend,
17406
+ onSend: isActive ? onSend : onStartConversation,
17404
17407
  onAttach,
17405
17408
  className: classNames?.input
17406
17409
  }
@@ -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[];
@@ -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,7 +1,7 @@
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';
2
+ import { T as TestClientHandle } from '../client-BycFj07D.mjs';
3
+ import { C as CreateAppOptions } from '../server-HVDbbqR9.mjs';
4
+ export { S as SeedName } from '../server-HVDbbqR9.mjs';
5
5
  import '../client-BTL9d_nN.mjs';
6
6
  import '../product-O8-wcHSe.mjs';
7
7
  import '../payment-pKPpaORI.mjs';
@@ -1,7 +1,7 @@
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';
2
+ import { T as TestClientHandle } from '../client-DqYNEMce.js';
3
+ import { C as CreateAppOptions } from '../server-JBuTPY-j.js';
4
+ export { S as SeedName } from '../server-JBuTPY-j.js';
5
5
  import '../client-BX30FAWZ.js';
6
6
  import '../product-O8-wcHSe.js';
7
7
  import '../payment-By0JidTe.js';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkQL6VROSG_js = require('../chunk-QL6VROSG.js');
4
- require('../chunk-XVOHMOGU.js');
3
+ var chunkRQMCRU4C_js = require('../chunk-RQMCRU4C.js');
4
+ require('../chunk-FECGCIVV.js');
5
5
  require('../chunk-XREIZ56K.js');
6
6
  require('../chunk-QLGZIBRO.js');
7
7
  require('../chunk-VEOAMBEX.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(() => chunkRQMCRU4C_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(chunkRQMCRU4C_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 = chunkRQMCRU4C_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 = chunkRQMCRU4C_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(() => chunkRQMCRU4C_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 chunkRQMCRU4C_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(() => chunkRQMCRU4C_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 chunkRQMCRU4C_js.fixtures.addFirstProduct(h.client);
103
+ await chunkRQMCRU4C_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 chunkRQMCRU4C_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 = chunkRQMCRU4C_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 = chunkRQMCRU4C_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 = chunkRQMCRU4C_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 = chunkRQMCRU4C_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 chunkRQMCRU4C_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 = chunkRQMCRU4C_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 chunkRQMCRU4C_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: chunkRQMCRU4C_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 = chunkRQMCRU4C_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:
@@ -1,5 +1,5 @@
1
- import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-7A3YHBVW.mjs';
2
- import '../chunk-BRYMPBEN.mjs';
1
+ import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-VZWK2FJM.mjs';
2
+ import '../chunk-7TEMLVDT.mjs';
3
3
  import '../chunk-U4MW6PYU.mjs';
4
4
  import '../chunk-FKARGZK3.mjs';
5
5
  import '../chunk-VUSHG3HA.mjs';