@cimplify/sdk 0.100.2 → 0.100.4

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 (55) hide show
  1. package/README.md +17 -0
  2. package/dist/advanced.d.mts +1 -1
  3. package/dist/advanced.d.ts +1 -1
  4. package/dist/advanced.js +20 -20
  5. package/dist/advanced.mjs +1 -1
  6. package/dist/{chunk-6JEKKL3M.js → chunk-3HU5I5VG.js} +23 -4
  7. package/dist/{chunk-YWNJJO2U.mjs → chunk-HSDQWJLA.mjs} +2 -2
  8. package/dist/{chunk-IJI7KMTG.js → chunk-JEVCHTKZ.js} +256 -74
  9. package/dist/{chunk-QRBBSIAY.js → chunk-LMD7B33E.js} +4 -4
  10. package/dist/{chunk-IFAQLFAJ.js → chunk-PNTINRAU.js} +33 -3
  11. package/dist/{chunk-B2YOCOLH.mjs → chunk-RQPXLXB2.mjs} +33 -3
  12. package/dist/{chunk-PJUXAUM2.mjs → chunk-RWR7JF7F.mjs} +210 -28
  13. package/dist/{chunk-TIQLOH2B.mjs → chunk-Z7M6GAHS.mjs} +23 -4
  14. package/dist/{client-D8XcrONA.d.mts → client-BwRAAk4y.d.mts} +26 -2
  15. package/dist/{client-CgXkRu2o.d.ts → client-CPcZIrjC.d.ts} +2 -2
  16. package/dist/{client-LPg_AUUr.d.ts → client-CrPglBBz.d.ts} +26 -2
  17. package/dist/{client-C6wb92AD.d.mts → client-DGrvLiJv.d.mts} +2 -2
  18. package/dist/index.d.mts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +69 -69
  21. package/dist/index.mjs +3 -3
  22. package/dist/lint-rules.json +1 -0
  23. package/dist/lint.d.mts +537 -0
  24. package/dist/lint.d.ts +537 -0
  25. package/dist/lint.js +540 -0
  26. package/dist/lint.mjs +524 -0
  27. package/dist/mock/cli.mjs +33 -3
  28. package/dist/mock/library.js +33 -3
  29. package/dist/mock/library.mjs +33 -3
  30. package/dist/mock/msw.js +33 -3
  31. package/dist/mock/msw.mjs +33 -3
  32. package/dist/react.d.mts +10 -5
  33. package/dist/react.d.ts +10 -5
  34. package/dist/react.js +40 -35
  35. package/dist/react.mjs +14 -9
  36. package/dist/{server--RyVAfPN.d.mts → server-DRAW2OOX.d.mts} +7 -4
  37. package/dist/{server-CNyy47HL.d.ts → server-zyrpzJVn.d.ts} +7 -4
  38. package/dist/server.d.mts +2 -2
  39. package/dist/server.d.ts +2 -2
  40. package/dist/server.js +7 -7
  41. package/dist/server.mjs +2 -2
  42. package/dist/styles.css +1 -1
  43. package/dist/testing/msw.d.mts +1 -1
  44. package/dist/testing/msw.d.ts +1 -1
  45. package/dist/testing/msw.js +2 -2
  46. package/dist/testing/msw.mjs +1 -1
  47. package/dist/testing/suite.d.mts +4 -4
  48. package/dist/testing/suite.d.ts +4 -4
  49. package/dist/testing/suite.js +23 -23
  50. package/dist/testing/suite.mjs +4 -4
  51. package/dist/testing.d.mts +3 -3
  52. package/dist/testing.d.ts +3 -3
  53. package/dist/testing.js +79 -79
  54. package/dist/testing.mjs +5 -5
  55. package/package.json +10 -2
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk6JEKKL3M_js = require('./chunk-6JEKKL3M.js');
3
+ var chunk3HU5I5VG_js = require('./chunk-3HU5I5VG.js');
4
4
  var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
5
5
 
6
6
  // src/store-credit.ts
@@ -13,38 +13,182 @@ var StoreCreditQueries = class {
13
13
  * currency. Requires a signed-in customer; returns an error otherwise.
14
14
  */
15
15
  async balance() {
16
- return chunk6JEKKL3M_js.safe(this.client.get("/api/v1/store-credit/balance"));
16
+ return chunk3HU5I5VG_js.safe(this.client.get("/api/v1/store-credit/balance"));
17
17
  }
18
18
  };
19
19
 
20
+ // src/internal/analytics-session.ts
21
+ var ANALYTICS_SESSION_IDLE_TIMEOUT_MS = 30 * 60 * 1e3;
22
+ var ANALYTICS_SESSION_STORAGE_KEY = "cimplify_analytics_session";
23
+ var ANALYTICS_SESSION_STATE_VERSION = 1;
24
+ var MICROSECONDS_PER_MILLISECOND = 1e3;
25
+ var MICROSECONDS_PER_SECOND = 1e6;
26
+ var AnalyticsSessionCoordinator = class {
27
+ constructor() {
28
+ this.fallbackState = null;
29
+ }
30
+ beginEvent(nowMs = Date.now()) {
31
+ const state = this.resolveActiveState(nowMs);
32
+ state.lastActivityAtMs = nowMs;
33
+ const occurredAt = reserveOccurredAt(state, nowMs, 1);
34
+ this.write(state);
35
+ return toEventContext(state, occurredAt);
36
+ }
37
+ beginPage(path, nowMs = Date.now()) {
38
+ const existing = this.read();
39
+ const expired = !existing || isExpired(existing, nowMs);
40
+ const state = expired ? newSession(nowMs) : existing;
41
+ const previousPage = expired ? void 0 : durationFor(state.activePage, nowMs);
42
+ state.lastActivityAtMs = nowMs;
43
+ state.activePage = { path, enteredAtMs: nowMs };
44
+ const occurredAt = reserveOccurredAt(state, nowMs, previousPage ? 2 : 1);
45
+ this.write(state);
46
+ return {
47
+ session: toEventContext(state, occurredAt),
48
+ previousPage
49
+ };
50
+ }
51
+ current() {
52
+ const state = this.read();
53
+ if (!state || isExpired(state, Date.now())) return null;
54
+ return toContext(state);
55
+ }
56
+ markBootstrapped(sessionId) {
57
+ const state = this.read();
58
+ if (!state || state.id !== sessionId) return;
59
+ state.bootstrapped = true;
60
+ this.write(state);
61
+ }
62
+ reset() {
63
+ this.fallbackState = null;
64
+ try {
65
+ sessionStorage.removeItem(ANALYTICS_SESSION_STORAGE_KEY);
66
+ } catch {
67
+ }
68
+ }
69
+ resolveActiveState(nowMs) {
70
+ const state = this.read();
71
+ return !state || isExpired(state, nowMs) ? newSession(nowMs) : state;
72
+ }
73
+ read() {
74
+ try {
75
+ const serialized = sessionStorage.getItem(ANALYTICS_SESSION_STORAGE_KEY);
76
+ if (!serialized) return this.fallbackState;
77
+ const state = JSON.parse(serialized);
78
+ if (!isPersistedSession(state)) {
79
+ sessionStorage.removeItem(ANALYTICS_SESSION_STORAGE_KEY);
80
+ return this.fallbackState;
81
+ }
82
+ this.fallbackState = state;
83
+ return state;
84
+ } catch {
85
+ return this.fallbackState;
86
+ }
87
+ }
88
+ write(state) {
89
+ this.fallbackState = state;
90
+ try {
91
+ sessionStorage.setItem(ANALYTICS_SESSION_STORAGE_KEY, JSON.stringify(state));
92
+ } catch {
93
+ }
94
+ }
95
+ };
96
+ function newSession(nowMs) {
97
+ return {
98
+ version: ANALYTICS_SESSION_STATE_VERSION,
99
+ id: generateSessionId(),
100
+ startedAtMs: nowMs,
101
+ lastActivityAtMs: nowMs,
102
+ bootstrapped: false
103
+ };
104
+ }
105
+ function toContext(state) {
106
+ return {
107
+ id: state.id,
108
+ startedAt: new Date(state.startedAtMs).toISOString(),
109
+ requiresBootstrap: !state.bootstrapped
110
+ };
111
+ }
112
+ function toEventContext(state, occurredAtMicros) {
113
+ return {
114
+ ...toContext(state),
115
+ occurredAt: formatEpochMicros(occurredAtMicros)
116
+ };
117
+ }
118
+ function reserveOccurredAt(state, nowMs, eventCount) {
119
+ const wallClockMicros = Math.trunc(nowMs) * MICROSECONDS_PER_MILLISECOND;
120
+ const occurredAtMicros = Math.max(
121
+ wallClockMicros,
122
+ (state.lastOccurredAtMicros ?? wallClockMicros - 1) + 1
123
+ );
124
+ state.lastOccurredAtMicros = occurredAtMicros + eventCount - 1;
125
+ return occurredAtMicros;
126
+ }
127
+ function formatEpochMicros(epochMicros) {
128
+ const epochMillis = Math.floor(epochMicros / MICROSECONDS_PER_MILLISECOND);
129
+ const microsWithinSecond = epochMicros % MICROSECONDS_PER_SECOND;
130
+ const millisecondIso = new Date(epochMillis).toISOString();
131
+ return `${millisecondIso.slice(0, -5)}.${String(microsWithinSecond).padStart(6, "0")}Z`;
132
+ }
133
+ function durationFor(activePage, nowMs) {
134
+ if (!activePage || nowMs < activePage.enteredAtMs) return void 0;
135
+ return {
136
+ path: activePage.path,
137
+ timeOnPageSeconds: Math.floor((nowMs - activePage.enteredAtMs) / 1e3)
138
+ };
139
+ }
140
+ function isExpired(state, nowMs) {
141
+ return nowMs - state.lastActivityAtMs >= ANALYTICS_SESSION_IDLE_TIMEOUT_MS;
142
+ }
143
+ function isPersistedSession(value) {
144
+ if (!value || typeof value !== "object") return false;
145
+ const state = value;
146
+ return state.version === ANALYTICS_SESSION_STATE_VERSION && typeof state.id === "string" && state.id.length > 0 && typeof state.startedAtMs === "number" && Number.isFinite(state.startedAtMs) && typeof state.lastActivityAtMs === "number" && Number.isFinite(state.lastActivityAtMs) && (state.lastOccurredAtMicros === void 0 || typeof state.lastOccurredAtMicros === "number" && Number.isSafeInteger(state.lastOccurredAtMicros)) && typeof state.bootstrapped === "boolean" && (!state.activePage || typeof state.activePage.path === "string" && typeof state.activePage.enteredAtMs === "number" && Number.isFinite(state.activePage.enteredAtMs));
147
+ }
148
+ function generateSessionId() {
149
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
150
+ return crypto.randomUUID();
151
+ }
152
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (character) => {
153
+ const random = Math.random() * 16 | 0;
154
+ const value = character === "x" ? random : random & 3 | 8;
155
+ return value.toString(16);
156
+ });
157
+ }
158
+
20
159
  // src/activity.ts
21
160
  var VISITOR_ID_STORAGE_KEY = "cimplify_visitor_id";
22
- var SESSION_STARTED_STORAGE_KEY = "cimplify_session_started_at";
23
161
  var ActivityService = class {
24
162
  constructor(client) {
25
163
  this.client = client;
164
+ this.sessions = new AnalyticsSessionCoordinator();
165
+ this.bootstrapRequest = null;
26
166
  }
27
167
  /**
28
168
  * Record session start (landing, referrer, UTM, device). Fire-and-forget,
29
- * at most once per tab session; called automatically by the track* methods.
169
+ * at most once per 30-minute-idle analytics session; called automatically
170
+ * by the track* methods.
30
171
  */
31
172
  startSession() {
32
173
  if (typeof window === "undefined") return;
33
- let alreadyStarted = null;
34
- try {
35
- alreadyStarted = sessionStorage.getItem(SESSION_STARTED_STORAGE_KEY);
36
- } catch {
37
- }
38
- if (alreadyStarted) return;
39
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
40
- try {
41
- sessionStorage.setItem(SESSION_STARTED_STORAGE_KEY, startedAt);
42
- } catch {
43
- }
44
- this.client.post("/api/v1/activity/session", this.buildSessionPayload(startedAt)).catch(() => {
174
+ const session = this.sessions.beginEvent();
175
+ void this.bootstrapSession(session).catch(() => {
176
+ });
177
+ }
178
+ /** Rebind an existing analytics session after the server authenticates a customer. */
179
+ refreshIdentity() {
180
+ if (typeof window === "undefined") return;
181
+ const session = this.sessions.current();
182
+ if (!session) return;
183
+ void this.bootstrapSession(session, true).catch(() => {
45
184
  });
46
185
  }
47
- buildSessionPayload(startedAt) {
186
+ /** A signed-out browser starts a fresh anonymous analytics session. */
187
+ resetSession() {
188
+ this.sessions.reset();
189
+ this.bootstrapRequest = null;
190
+ }
191
+ buildSessionPayload(session) {
48
192
  const params = new URLSearchParams(window.location.search);
49
193
  const utm = (key) => params.get(`utm_${key}`) || void 0;
50
194
  const { visitorId, isNewVisitor } = resolveVisitor();
@@ -54,7 +198,8 @@ var ActivityService = class {
54
198
  } catch {
55
199
  }
56
200
  return {
57
- started_at: startedAt,
201
+ analytics_session_id: session.id,
202
+ started_at: session.startedAt,
58
203
  landing_page: window.location.pathname,
59
204
  landing_url: window.location.href,
60
205
  referrer_url: document.referrer || void 0,
@@ -74,17 +219,28 @@ var ActivityService = class {
74
219
  is_new_visitor: isNewVisitor
75
220
  };
76
221
  }
77
- /** Product/category views imply one; call this for every other page. */
222
+ /** Route-level page view. Product/category interactions are tracked separately. */
78
223
  trackPageView(options = {}) {
79
- this.sendEvents([
80
- {
81
- type: "page_view",
82
- page_path: options.pagePath ?? currentPath(),
83
- page_title: options.pageTitle ?? currentTitle()
84
- }
85
- ]);
224
+ if (typeof window === "undefined") return;
225
+ const pagePath = options.pagePath ?? currentPath() ?? "";
226
+ const transition = this.sessions.beginPage(pagePath);
227
+ const events = [];
228
+ if (transition.previousPage) {
229
+ events.push({
230
+ type: "page_duration",
231
+ page_path: transition.previousPage.path,
232
+ time_on_page: transition.previousPage.timeOnPageSeconds
233
+ });
234
+ }
235
+ events.push({
236
+ type: "page_view",
237
+ page_path: pagePath,
238
+ page_title: options.pageTitle ?? currentTitle()
239
+ });
240
+ this.sendEvents(events, transition.session);
86
241
  }
87
242
  trackProductView(productId, options = {}) {
243
+ if (typeof window === "undefined") return;
88
244
  const event = {
89
245
  type: "product_view",
90
246
  product_id: productId,
@@ -96,6 +252,7 @@ var ActivityService = class {
96
252
  this.sendEvents([event]);
97
253
  }
98
254
  trackCategoryView(categoryId, options = {}) {
255
+ if (typeof window === "undefined") return;
99
256
  const event = {
100
257
  type: "category_view",
101
258
  category_id: categoryId,
@@ -105,7 +262,7 @@ var ActivityService = class {
105
262
  this.sendEvents([event]);
106
263
  }
107
264
  async getState() {
108
- return chunk6JEKKL3M_js.safe(this.client.get("/api/v1/activity/state"));
265
+ return chunk3HU5I5VG_js.safe(this.client.get("/api/v1/activity/state"));
109
266
  }
110
267
  async getRecommendations(options) {
111
268
  const params = new URLSearchParams();
@@ -113,10 +270,10 @@ var ActivityService = class {
113
270
  if (options?.limit) params.set("limit", String(options.limit));
114
271
  const query = params.toString();
115
272
  const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
116
- return chunk6JEKKL3M_js.safe(this.client.get(path));
273
+ return chunk3HU5I5VG_js.safe(this.client.get(path));
117
274
  }
118
275
  async dismissMessage(code) {
119
- return chunk6JEKKL3M_js.safe(
276
+ return chunk3HU5I5VG_js.safe(
120
277
  this.client.post("/api/v1/activity/messages/dismiss", { code })
121
278
  );
122
279
  }
@@ -151,10 +308,33 @@ var ActivityService = class {
151
308
  window.removeEventListener("popstate", record);
152
309
  };
153
310
  }
154
- sendEvents(events) {
155
- this.startSession();
156
- this.client.post("/api/v1/activity/events", { events }).catch(() => {
311
+ sendEvents(events, session) {
312
+ if (typeof window === "undefined") return;
313
+ void this.postEvents(events, session ?? this.sessions.beginEvent()).catch(() => {
314
+ });
315
+ }
316
+ async postEvents(events, session) {
317
+ await this.bootstrapSession(session);
318
+ await this.client.post("/api/v1/activity/events", {
319
+ analytics_session_id: session.id,
320
+ occurred_at: session.occurredAt,
321
+ events
322
+ });
323
+ }
324
+ bootstrapSession(session, force = false) {
325
+ if (!force && !session.requiresBootstrap) return Promise.resolve();
326
+ if (!force && this.bootstrapRequest?.sessionId === session.id) {
327
+ return this.bootstrapRequest.promise;
328
+ }
329
+ const promise = this.client.post("/api/v1/activity/session", this.buildSessionPayload(session)).then(() => {
330
+ this.sessions.markBootstrapped(session.id);
331
+ }).finally(() => {
332
+ if (this.bootstrapRequest?.promise === promise) {
333
+ this.bootstrapRequest = null;
334
+ }
157
335
  });
336
+ this.bootstrapRequest = { sessionId: session.id, promise };
337
+ return promise;
158
338
  }
159
339
  };
160
340
  function currentPath() {
@@ -189,16 +369,16 @@ var SubscriptionService = class {
189
369
  this.client = client;
190
370
  }
191
371
  async list() {
192
- return chunk6JEKKL3M_js.safe(this.client.get("/api/v1/subscriptions"));
372
+ return chunk3HU5I5VG_js.safe(this.client.get("/api/v1/subscriptions"));
193
373
  }
194
374
  async get(id) {
195
375
  const encodedId = encodeURIComponent(id);
196
- return chunk6JEKKL3M_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
376
+ return chunk3HU5I5VG_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
197
377
  }
198
378
  async cancel(id, reason, opts) {
199
379
  const encodedId = encodeURIComponent(id);
200
- const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
201
- return chunk6JEKKL3M_js.safe(
380
+ const idempotencyKey = opts?.idempotencyKey ?? chunk3HU5I5VG_js.generateIdempotencyKey();
381
+ return chunk3HU5I5VG_js.safe(
202
382
  this.client.post(
203
383
  `/api/v1/subscriptions/${encodedId}/cancel`,
204
384
  { reason },
@@ -208,20 +388,20 @@ var SubscriptionService = class {
208
388
  }
209
389
  async pause(id) {
210
390
  const encodedId = encodeURIComponent(id);
211
- return chunk6JEKKL3M_js.safe(
391
+ return chunk3HU5I5VG_js.safe(
212
392
  this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
213
393
  );
214
394
  }
215
395
  async resume(id) {
216
396
  const encodedId = encodeURIComponent(id);
217
- return chunk6JEKKL3M_js.safe(
397
+ return chunk3HU5I5VG_js.safe(
218
398
  this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
219
399
  );
220
400
  }
221
401
  async skipNextRenewal(id, opts) {
222
402
  const encodedId = encodeURIComponent(id);
223
- const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
224
- return chunk6JEKKL3M_js.safe(
403
+ const idempotencyKey = opts?.idempotencyKey ?? chunk3HU5I5VG_js.generateIdempotencyKey();
404
+ return chunk3HU5I5VG_js.safe(
225
405
  this.client.post(
226
406
  `/api/v1/subscriptions/${encodedId}/skip`,
227
407
  void 0,
@@ -237,8 +417,8 @@ var UploadService = class {
237
417
  this.client = client;
238
418
  }
239
419
  async init(filename, contentType, sizeBytes, opts) {
240
- const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
241
- return chunk6JEKKL3M_js.safe(
420
+ const idempotencyKey = opts?.idempotencyKey ?? chunk3HU5I5VG_js.generateIdempotencyKey();
421
+ return chunk3HU5I5VG_js.safe(
242
422
  this.client.post(
243
423
  "/api/v1/uploads/init",
244
424
  {
@@ -251,7 +431,7 @@ var UploadService = class {
251
431
  );
252
432
  }
253
433
  async confirm(uploadId) {
254
- return chunk6JEKKL3M_js.safe(
434
+ return chunk3HU5I5VG_js.safe(
255
435
  this.client.post("/api/v1/uploads/confirm", {
256
436
  upload_id: uploadId
257
437
  })
@@ -297,7 +477,7 @@ var PlacesService = class {
297
477
  this.client = client;
298
478
  }
299
479
  async autocomplete(input, sessionToken) {
300
- return chunk6JEKKL3M_js.safe(
480
+ return chunk3HU5I5VG_js.safe(
301
481
  this.client.post("/api/v1/places/autocomplete", {
302
482
  input,
303
483
  sessionToken
@@ -305,7 +485,7 @@ var PlacesService = class {
305
485
  );
306
486
  }
307
487
  async details(placeId, sessionToken) {
308
- return chunk6JEKKL3M_js.safe(
488
+ return chunk3HU5I5VG_js.safe(
309
489
  this.client.post("/api/v1/places/details", {
310
490
  place_id: placeId,
311
491
  sessionToken
@@ -324,7 +504,7 @@ var DeliveryService = class {
324
504
  params.set("dropoff_lat", String(dropoffLat));
325
505
  params.set("dropoff_lng", String(dropoffLng));
326
506
  if (country) params.set("country", country);
327
- return chunk6JEKKL3M_js.safe(this.client.get(`/api/v1/delivery/fee?${params.toString()}`));
507
+ return chunk3HU5I5VG_js.safe(this.client.get(`/api/v1/delivery/fee?${params.toString()}`));
328
508
  }
329
509
  async getOptions(queryOrLatitude, longitude, legacyOptions) {
330
510
  const query = typeof queryOrLatitude === "number" ? {
@@ -336,8 +516,9 @@ var DeliveryService = class {
336
516
  if (query.dropoffLat != null) params.set("dropoff_lat", String(query.dropoffLat));
337
517
  if (query.dropoffLng != null) params.set("dropoff_lng", String(query.dropoffLng));
338
518
  if (query.country) params.set("country", query.country);
519
+ if (query.currency) params.set("currency", query.currency);
339
520
  if (query.orderValue != null) params.set("order_value", String(query.orderValue));
340
- return chunk6JEKKL3M_js.safe(
521
+ return chunk3HU5I5VG_js.safe(
341
522
  this.client.get(`/api/v1/delivery/options?${params.toString()}`)
342
523
  );
343
524
  }
@@ -414,7 +595,7 @@ var SupportService = class {
414
595
  async claimConversation() {
415
596
  const accessToken = this.client.getAccessToken();
416
597
  if (!accessToken) {
417
- return chunk6JEKKL3M_js.err(new chunkNIOUSKQQ_js.CimplifyError("not_authenticated", "No access token to claim with"));
598
+ return chunk3HU5I5VG_js.err(new chunkNIOUSKQQ_js.CimplifyError("not_authenticated", "No access token to claim with"));
418
599
  }
419
600
  if (this.claimInFlight) {
420
601
  if (this.claimInFlightToken === accessToken) return this.claimInFlight;
@@ -422,12 +603,12 @@ var SupportService = class {
422
603
  return this.claimConversation();
423
604
  }
424
605
  if (this.lastClaimedAccessToken === accessToken) {
425
- return chunk6JEKKL3M_js.err(new chunkNIOUSKQQ_js.CimplifyError("already_claimed", "Session already claimed for this token"));
606
+ return chunk3HU5I5VG_js.err(new chunkNIOUSKQQ_js.CimplifyError("already_claimed", "Session already claimed for this token"));
426
607
  }
427
608
  const epoch = this.client.getSessionEpoch();
428
609
  this.claimInFlightToken = accessToken;
429
610
  this.claimInFlight = (async () => {
430
- const result = await chunk6JEKKL3M_js.safe(
611
+ const result = await chunk3HU5I5VG_js.safe(
431
612
  this.client.post(
432
613
  "/api/v1/support/conversation/claim",
433
614
  { access_token: accessToken },
@@ -436,7 +617,7 @@ var SupportService = class {
436
617
  );
437
618
  if (result.ok) {
438
619
  if (this.client.getSessionEpoch() !== epoch) {
439
- return chunk6JEKKL3M_js.err(
620
+ return chunk3HU5I5VG_js.err(
440
621
  new chunkNIOUSKQQ_js.CimplifyError("session_cleared", "Session was cleared during the claim")
441
622
  );
442
623
  }
@@ -465,20 +646,20 @@ var SupportService = class {
465
646
  * the inbox with empty threads.
466
647
  */
467
648
  async peekConversation() {
468
- const result = await chunk6JEKKL3M_js.safe(
649
+ const result = await chunk3HU5I5VG_js.safe(
469
650
  this.client.get("/api/v1/support/conversation")
470
651
  );
471
652
  if (!result.ok) return result;
472
- if (!result.value.conversation) return chunk6JEKKL3M_js.ok(null);
473
- return chunk6JEKKL3M_js.ok({
653
+ if (!result.value.conversation) return chunk3HU5I5VG_js.ok(null);
654
+ return chunk3HU5I5VG_js.ok({
474
655
  conversation: result.value.conversation,
475
656
  messages: result.value.messages
476
657
  });
477
658
  }
478
659
  /** Open (or resume) the customer's widget conversation. */
479
660
  async openConversation(opts) {
480
- const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
481
- return chunk6JEKKL3M_js.safe(
661
+ const idempotencyKey = opts?.idempotencyKey ?? chunk3HU5I5VG_js.generateIdempotencyKey();
662
+ return chunk3HU5I5VG_js.safe(
482
663
  this.client.post("/api/v1/support/conversation", void 0, {
483
664
  idempotencyKey
484
665
  })
@@ -493,8 +674,8 @@ var SupportService = class {
493
674
  * server resolves it thread-scoped and echoes the quote as `reply_to`.
494
675
  */
495
676
  async sendMessage(content, opts) {
496
- const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
497
- return chunk6JEKKL3M_js.safe(
677
+ const idempotencyKey = opts?.idempotencyKey ?? chunk3HU5I5VG_js.generateIdempotencyKey();
678
+ return chunk3HU5I5VG_js.safe(
498
679
  this.client.post(
499
680
  "/api/v1/support/conversation/messages",
500
681
  {
@@ -518,11 +699,11 @@ var SupportService = class {
518
699
  if (options.limit) params.set("limit", String(options.limit));
519
700
  const query = params.toString();
520
701
  const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
521
- return chunk6JEKKL3M_js.safe(this.client.get(path));
702
+ return chunk3HU5I5VG_js.safe(this.client.get(path));
522
703
  }
523
704
  /** React to a message in the active conversation by its `ChatMessage.id`. */
524
705
  async reactToMessage(messageId, emoji) {
525
- return chunk6JEKKL3M_js.safe(
706
+ return chunk3HU5I5VG_js.safe(
526
707
  this.client.post(
527
708
  `/api/v1/support/conversation/messages/${messageId}/reactions`,
528
709
  { emoji }
@@ -531,8 +712,8 @@ var SupportService = class {
531
712
  }
532
713
  /** Ask for a person: flags the thread for the merchant's inbox. */
533
714
  async requestHuman(opts) {
534
- const idempotencyKey = opts?.idempotencyKey ?? chunk6JEKKL3M_js.generateIdempotencyKey();
535
- return chunk6JEKKL3M_js.safe(
715
+ const idempotencyKey = opts?.idempotencyKey ?? chunk3HU5I5VG_js.generateIdempotencyKey();
716
+ return chunk3HU5I5VG_js.safe(
536
717
  this.client.post(
537
718
  "/api/v1/support/conversation/handoff",
538
719
  void 0,
@@ -762,6 +943,7 @@ var CimplifyClient = class {
762
943
  clearSession() {
763
944
  const previous = this.accessToken;
764
945
  this.accessToken = null;
946
+ this._activity?.resetSession();
765
947
  this.sessionToken = null;
766
948
  this.sessionEpoch++;
767
949
  try {
@@ -1256,25 +1438,25 @@ var CimplifyClient = class {
1256
1438
  }
1257
1439
  get catalogue() {
1258
1440
  if (!this._catalogue) {
1259
- this._catalogue = new chunk6JEKKL3M_js.CatalogueQueries(this);
1441
+ this._catalogue = new chunk3HU5I5VG_js.CatalogueQueries(this);
1260
1442
  }
1261
1443
  return this._catalogue;
1262
1444
  }
1263
1445
  get cart() {
1264
1446
  if (!this._cart) {
1265
- this._cart = new chunk6JEKKL3M_js.CartOperations(this);
1447
+ this._cart = new chunk3HU5I5VG_js.CartOperations(this);
1266
1448
  }
1267
1449
  return this._cart;
1268
1450
  }
1269
1451
  get checkout() {
1270
1452
  if (!this._checkout) {
1271
- this._checkout = new chunk6JEKKL3M_js.CheckoutService(this);
1453
+ this._checkout = new chunk3HU5I5VG_js.CheckoutService(this);
1272
1454
  }
1273
1455
  return this._checkout;
1274
1456
  }
1275
1457
  get orders() {
1276
1458
  if (!this._orders) {
1277
- this._orders = new chunk6JEKKL3M_js.OrderQueries(this);
1459
+ this._orders = new chunk3HU5I5VG_js.OrderQueries(this);
1278
1460
  }
1279
1461
  return this._orders;
1280
1462
  }
@@ -1304,43 +1486,43 @@ var CimplifyClient = class {
1304
1486
  }
1305
1487
  get link() {
1306
1488
  if (!this._link) {
1307
- this._link = new chunk6JEKKL3M_js.LinkService(this);
1489
+ this._link = new chunk3HU5I5VG_js.LinkService(this);
1308
1490
  }
1309
1491
  return this._link;
1310
1492
  }
1311
1493
  get auth() {
1312
1494
  if (!this._auth) {
1313
- this._auth = new chunk6JEKKL3M_js.AuthService(this);
1495
+ this._auth = new chunk3HU5I5VG_js.AuthService(this);
1314
1496
  }
1315
1497
  return this._auth;
1316
1498
  }
1317
1499
  get business() {
1318
1500
  if (!this._business) {
1319
- this._business = new chunk6JEKKL3M_js.BusinessService(this);
1501
+ this._business = new chunk3HU5I5VG_js.BusinessService(this);
1320
1502
  }
1321
1503
  return this._business;
1322
1504
  }
1323
1505
  get inventory() {
1324
1506
  if (!this._inventory) {
1325
- this._inventory = new chunk6JEKKL3M_js.InventoryService(this);
1507
+ this._inventory = new chunk3HU5I5VG_js.InventoryService(this);
1326
1508
  }
1327
1509
  return this._inventory;
1328
1510
  }
1329
1511
  get scheduling() {
1330
1512
  if (!this._scheduling) {
1331
- this._scheduling = new chunk6JEKKL3M_js.SchedulingService(this);
1513
+ this._scheduling = new chunk3HU5I5VG_js.SchedulingService(this);
1332
1514
  }
1333
1515
  return this._scheduling;
1334
1516
  }
1335
1517
  get lite() {
1336
1518
  if (!this._lite) {
1337
- this._lite = new chunk6JEKKL3M_js.LiteService(this);
1519
+ this._lite = new chunk3HU5I5VG_js.LiteService(this);
1338
1520
  }
1339
1521
  return this._lite;
1340
1522
  }
1341
1523
  get fx() {
1342
1524
  if (!this._fx) {
1343
- this._fx = new chunk6JEKKL3M_js.FxService(this);
1525
+ this._fx = new chunk3HU5I5VG_js.FxService(this);
1344
1526
  }
1345
1527
  return this._fx;
1346
1528
  }
@@ -1375,7 +1557,7 @@ var CimplifyClient = class {
1375
1557
  if (businessId) {
1376
1558
  this.setBusinessId(businessId);
1377
1559
  }
1378
- return chunk6JEKKL3M_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
1560
+ return chunk3HU5I5VG_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
1379
1561
  }
1380
1562
  };
1381
1563
  function createCimplifyClient(config = {}) {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkIFAQLFAJ_js = require('./chunk-IFAQLFAJ.js');
4
- var chunkIJI7KMTG_js = require('./chunk-IJI7KMTG.js');
3
+ var chunkPNTINRAU_js = require('./chunk-PNTINRAU.js');
4
+ var chunkJEVCHTKZ_js = require('./chunk-JEVCHTKZ.js');
5
5
  var zod = require('zod');
6
6
 
7
7
  var cimplifyRegistry = zod.z.registry();
@@ -600,7 +600,7 @@ async function toForwardedRequest(input, init) {
600
600
  };
601
601
  }
602
602
  function createTestClient(options = {}) {
603
- const mock = chunkIFAQLFAJ_js.createMockApp(options);
603
+ const mock = chunkPNTINRAU_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;
@@ -619,7 +619,7 @@ function createTestClient(options = {}) {
619
619
  if (echoed) sessionToken = echoed;
620
620
  return res;
621
621
  };
622
- const client = chunkIJI7KMTG_js.createCimplifyClient({
622
+ const client = chunkJEVCHTKZ_js.createCimplifyClient({
623
623
  baseUrl: TEST_BASE_URL,
624
624
  // Link mock lives at /v1/link on the same Hono app, so point the SDK's
625
625
  // separate Link transport at the same TEST_BASE_URL.