@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
@@ -2470,7 +2470,7 @@ function buildV1(deps) {
2470
2470
  });
2471
2471
  app.post("/activity/events", async (c) => {
2472
2472
  const body = await c.req.json().catch(() => ({}));
2473
- return tryRoute(c, () => deps.activity.recordEvents(deps.defaultBusinessId, c.var.session.id, body.events ?? []));
2473
+ return tryRoute(c, () => deps.activity.recordEvents(deps.defaultBusinessId, body.analytics_session_id ?? c.var.session.id, body.events ?? []));
2474
2474
  });
2475
2475
  app.get("/activity/state", (c) => tryRoute(c, () => deps.activity.getState(deps.defaultBusinessId, c.var.session.id)));
2476
2476
  app.get("/activity/recommendations", (c) => tryRoute(c, () => deps.activity.getRecommendations(deps.defaultBusinessId)));
@@ -5433,7 +5433,7 @@ function createActivityService(opts) {
5433
5433
  id,
5434
5434
  business_id: businessId,
5435
5435
  session_id: sessionId,
5436
- event_type: e.event_type,
5436
+ event_type: e.type,
5437
5437
  payload: e.payload ?? {},
5438
5438
  created_at: clock.iso()
5439
5439
  };
@@ -5624,6 +5624,13 @@ function createLiteService(opts) {
5624
5624
  }
5625
5625
 
5626
5626
  // src/mock/domain/link.ts
5627
+ var LOCATION_FIELDS = [
5628
+ "street_address",
5629
+ "city",
5630
+ "region",
5631
+ "postal_code",
5632
+ "country"
5633
+ ];
5627
5634
  var NOT_ENROLLED_ERROR = () => {
5628
5635
  throw {
5629
5636
  code: "NOT_ENROLLED",
@@ -5800,7 +5807,30 @@ function createLinkService({ clock, ids }) {
5800
5807
  },
5801
5808
  updateAddress(customerId, id, patch) {
5802
5809
  const a = this.getAddressById(customerId, id);
5803
- Object.assign(a, patch, { updated_at: clock.iso() });
5810
+ const {
5811
+ clear_coordinates: clearCoordinates = false,
5812
+ latitude,
5813
+ longitude,
5814
+ ...changes
5815
+ } = patch;
5816
+ const hasLatitude = latitude !== void 0;
5817
+ const hasLongitude = longitude !== void 0;
5818
+ if (hasLatitude !== hasLongitude) {
5819
+ throw new Error("latitude and longitude must be supplied together");
5820
+ }
5821
+ if (clearCoordinates && hasLatitude) {
5822
+ throw new Error("clear_coordinates cannot be combined with coordinates");
5823
+ }
5824
+ const locationChanged = LOCATION_FIELDS.some((field) => field in changes);
5825
+ Object.assign(a, changes);
5826
+ if (hasLatitude && hasLongitude) {
5827
+ a.latitude = latitude ?? null;
5828
+ a.longitude = longitude ?? null;
5829
+ } else if (clearCoordinates || locationChanged) {
5830
+ a.latitude = null;
5831
+ a.longitude = null;
5832
+ }
5833
+ a.updated_at = clock.iso();
5804
5834
  return a;
5805
5835
  },
5806
5836
  deleteAddress(customerId, id) {
@@ -2468,7 +2468,7 @@ function buildV1(deps) {
2468
2468
  });
2469
2469
  app.post("/activity/events", async (c) => {
2470
2470
  const body = await c.req.json().catch(() => ({}));
2471
- return tryRoute(c, () => deps.activity.recordEvents(deps.defaultBusinessId, c.var.session.id, body.events ?? []));
2471
+ return tryRoute(c, () => deps.activity.recordEvents(deps.defaultBusinessId, body.analytics_session_id ?? c.var.session.id, body.events ?? []));
2472
2472
  });
2473
2473
  app.get("/activity/state", (c) => tryRoute(c, () => deps.activity.getState(deps.defaultBusinessId, c.var.session.id)));
2474
2474
  app.get("/activity/recommendations", (c) => tryRoute(c, () => deps.activity.getRecommendations(deps.defaultBusinessId)));
@@ -5431,7 +5431,7 @@ function createActivityService(opts) {
5431
5431
  id,
5432
5432
  business_id: businessId,
5433
5433
  session_id: sessionId,
5434
- event_type: e.event_type,
5434
+ event_type: e.type,
5435
5435
  payload: e.payload ?? {},
5436
5436
  created_at: clock.iso()
5437
5437
  };
@@ -5622,6 +5622,13 @@ function createLiteService(opts) {
5622
5622
  }
5623
5623
 
5624
5624
  // src/mock/domain/link.ts
5625
+ var LOCATION_FIELDS = [
5626
+ "street_address",
5627
+ "city",
5628
+ "region",
5629
+ "postal_code",
5630
+ "country"
5631
+ ];
5625
5632
  var NOT_ENROLLED_ERROR = () => {
5626
5633
  throw {
5627
5634
  code: "NOT_ENROLLED",
@@ -5798,7 +5805,30 @@ function createLinkService({ clock, ids }) {
5798
5805
  },
5799
5806
  updateAddress(customerId, id, patch) {
5800
5807
  const a = this.getAddressById(customerId, id);
5801
- Object.assign(a, patch, { updated_at: clock.iso() });
5808
+ const {
5809
+ clear_coordinates: clearCoordinates = false,
5810
+ latitude,
5811
+ longitude,
5812
+ ...changes
5813
+ } = patch;
5814
+ const hasLatitude = latitude !== void 0;
5815
+ const hasLongitude = longitude !== void 0;
5816
+ if (hasLatitude !== hasLongitude) {
5817
+ throw new Error("latitude and longitude must be supplied together");
5818
+ }
5819
+ if (clearCoordinates && hasLatitude) {
5820
+ throw new Error("clear_coordinates cannot be combined with coordinates");
5821
+ }
5822
+ const locationChanged = LOCATION_FIELDS.some((field) => field in changes);
5823
+ Object.assign(a, changes);
5824
+ if (hasLatitude && hasLongitude) {
5825
+ a.latitude = latitude ?? null;
5826
+ a.longitude = longitude ?? null;
5827
+ } else if (clearCoordinates || locationChanged) {
5828
+ a.latitude = null;
5829
+ a.longitude = null;
5830
+ }
5831
+ a.updated_at = clock.iso();
5802
5832
  return a;
5803
5833
  },
5804
5834
  deleteAddress(customerId, id) {
@@ -1,4 +1,4 @@
1
- import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-TIQLOH2B.mjs';
1
+ import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-Z7M6GAHS.mjs';
2
2
  import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-O3YUHLZL.mjs';
3
3
 
4
4
  // src/store-credit.ts
@@ -15,34 +15,178 @@ var StoreCreditQueries = class {
15
15
  }
16
16
  };
17
17
 
18
+ // src/internal/analytics-session.ts
19
+ var ANALYTICS_SESSION_IDLE_TIMEOUT_MS = 30 * 60 * 1e3;
20
+ var ANALYTICS_SESSION_STORAGE_KEY = "cimplify_analytics_session";
21
+ var ANALYTICS_SESSION_STATE_VERSION = 1;
22
+ var MICROSECONDS_PER_MILLISECOND = 1e3;
23
+ var MICROSECONDS_PER_SECOND = 1e6;
24
+ var AnalyticsSessionCoordinator = class {
25
+ constructor() {
26
+ this.fallbackState = null;
27
+ }
28
+ beginEvent(nowMs = Date.now()) {
29
+ const state = this.resolveActiveState(nowMs);
30
+ state.lastActivityAtMs = nowMs;
31
+ const occurredAt = reserveOccurredAt(state, nowMs, 1);
32
+ this.write(state);
33
+ return toEventContext(state, occurredAt);
34
+ }
35
+ beginPage(path, nowMs = Date.now()) {
36
+ const existing = this.read();
37
+ const expired = !existing || isExpired(existing, nowMs);
38
+ const state = expired ? newSession(nowMs) : existing;
39
+ const previousPage = expired ? void 0 : durationFor(state.activePage, nowMs);
40
+ state.lastActivityAtMs = nowMs;
41
+ state.activePage = { path, enteredAtMs: nowMs };
42
+ const occurredAt = reserveOccurredAt(state, nowMs, previousPage ? 2 : 1);
43
+ this.write(state);
44
+ return {
45
+ session: toEventContext(state, occurredAt),
46
+ previousPage
47
+ };
48
+ }
49
+ current() {
50
+ const state = this.read();
51
+ if (!state || isExpired(state, Date.now())) return null;
52
+ return toContext(state);
53
+ }
54
+ markBootstrapped(sessionId) {
55
+ const state = this.read();
56
+ if (!state || state.id !== sessionId) return;
57
+ state.bootstrapped = true;
58
+ this.write(state);
59
+ }
60
+ reset() {
61
+ this.fallbackState = null;
62
+ try {
63
+ sessionStorage.removeItem(ANALYTICS_SESSION_STORAGE_KEY);
64
+ } catch {
65
+ }
66
+ }
67
+ resolveActiveState(nowMs) {
68
+ const state = this.read();
69
+ return !state || isExpired(state, nowMs) ? newSession(nowMs) : state;
70
+ }
71
+ read() {
72
+ try {
73
+ const serialized = sessionStorage.getItem(ANALYTICS_SESSION_STORAGE_KEY);
74
+ if (!serialized) return this.fallbackState;
75
+ const state = JSON.parse(serialized);
76
+ if (!isPersistedSession(state)) {
77
+ sessionStorage.removeItem(ANALYTICS_SESSION_STORAGE_KEY);
78
+ return this.fallbackState;
79
+ }
80
+ this.fallbackState = state;
81
+ return state;
82
+ } catch {
83
+ return this.fallbackState;
84
+ }
85
+ }
86
+ write(state) {
87
+ this.fallbackState = state;
88
+ try {
89
+ sessionStorage.setItem(ANALYTICS_SESSION_STORAGE_KEY, JSON.stringify(state));
90
+ } catch {
91
+ }
92
+ }
93
+ };
94
+ function newSession(nowMs) {
95
+ return {
96
+ version: ANALYTICS_SESSION_STATE_VERSION,
97
+ id: generateSessionId(),
98
+ startedAtMs: nowMs,
99
+ lastActivityAtMs: nowMs,
100
+ bootstrapped: false
101
+ };
102
+ }
103
+ function toContext(state) {
104
+ return {
105
+ id: state.id,
106
+ startedAt: new Date(state.startedAtMs).toISOString(),
107
+ requiresBootstrap: !state.bootstrapped
108
+ };
109
+ }
110
+ function toEventContext(state, occurredAtMicros) {
111
+ return {
112
+ ...toContext(state),
113
+ occurredAt: formatEpochMicros(occurredAtMicros)
114
+ };
115
+ }
116
+ function reserveOccurredAt(state, nowMs, eventCount) {
117
+ const wallClockMicros = Math.trunc(nowMs) * MICROSECONDS_PER_MILLISECOND;
118
+ const occurredAtMicros = Math.max(
119
+ wallClockMicros,
120
+ (state.lastOccurredAtMicros ?? wallClockMicros - 1) + 1
121
+ );
122
+ state.lastOccurredAtMicros = occurredAtMicros + eventCount - 1;
123
+ return occurredAtMicros;
124
+ }
125
+ function formatEpochMicros(epochMicros) {
126
+ const epochMillis = Math.floor(epochMicros / MICROSECONDS_PER_MILLISECOND);
127
+ const microsWithinSecond = epochMicros % MICROSECONDS_PER_SECOND;
128
+ const millisecondIso = new Date(epochMillis).toISOString();
129
+ return `${millisecondIso.slice(0, -5)}.${String(microsWithinSecond).padStart(6, "0")}Z`;
130
+ }
131
+ function durationFor(activePage, nowMs) {
132
+ if (!activePage || nowMs < activePage.enteredAtMs) return void 0;
133
+ return {
134
+ path: activePage.path,
135
+ timeOnPageSeconds: Math.floor((nowMs - activePage.enteredAtMs) / 1e3)
136
+ };
137
+ }
138
+ function isExpired(state, nowMs) {
139
+ return nowMs - state.lastActivityAtMs >= ANALYTICS_SESSION_IDLE_TIMEOUT_MS;
140
+ }
141
+ function isPersistedSession(value) {
142
+ if (!value || typeof value !== "object") return false;
143
+ const state = value;
144
+ 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));
145
+ }
146
+ function generateSessionId() {
147
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
148
+ return crypto.randomUUID();
149
+ }
150
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (character) => {
151
+ const random = Math.random() * 16 | 0;
152
+ const value = character === "x" ? random : random & 3 | 8;
153
+ return value.toString(16);
154
+ });
155
+ }
156
+
18
157
  // src/activity.ts
19
158
  var VISITOR_ID_STORAGE_KEY = "cimplify_visitor_id";
20
- var SESSION_STARTED_STORAGE_KEY = "cimplify_session_started_at";
21
159
  var ActivityService = class {
22
160
  constructor(client) {
23
161
  this.client = client;
162
+ this.sessions = new AnalyticsSessionCoordinator();
163
+ this.bootstrapRequest = null;
24
164
  }
25
165
  /**
26
166
  * Record session start (landing, referrer, UTM, device). Fire-and-forget,
27
- * at most once per tab session; called automatically by the track* methods.
167
+ * at most once per 30-minute-idle analytics session; called automatically
168
+ * by the track* methods.
28
169
  */
29
170
  startSession() {
30
171
  if (typeof window === "undefined") return;
31
- let alreadyStarted = null;
32
- try {
33
- alreadyStarted = sessionStorage.getItem(SESSION_STARTED_STORAGE_KEY);
34
- } catch {
35
- }
36
- if (alreadyStarted) return;
37
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
38
- try {
39
- sessionStorage.setItem(SESSION_STARTED_STORAGE_KEY, startedAt);
40
- } catch {
41
- }
42
- this.client.post("/api/v1/activity/session", this.buildSessionPayload(startedAt)).catch(() => {
172
+ const session = this.sessions.beginEvent();
173
+ void this.bootstrapSession(session).catch(() => {
174
+ });
175
+ }
176
+ /** Rebind an existing analytics session after the server authenticates a customer. */
177
+ refreshIdentity() {
178
+ if (typeof window === "undefined") return;
179
+ const session = this.sessions.current();
180
+ if (!session) return;
181
+ void this.bootstrapSession(session, true).catch(() => {
43
182
  });
44
183
  }
45
- buildSessionPayload(startedAt) {
184
+ /** A signed-out browser starts a fresh anonymous analytics session. */
185
+ resetSession() {
186
+ this.sessions.reset();
187
+ this.bootstrapRequest = null;
188
+ }
189
+ buildSessionPayload(session) {
46
190
  const params = new URLSearchParams(window.location.search);
47
191
  const utm = (key) => params.get(`utm_${key}`) || void 0;
48
192
  const { visitorId, isNewVisitor } = resolveVisitor();
@@ -52,7 +196,8 @@ var ActivityService = class {
52
196
  } catch {
53
197
  }
54
198
  return {
55
- started_at: startedAt,
199
+ analytics_session_id: session.id,
200
+ started_at: session.startedAt,
56
201
  landing_page: window.location.pathname,
57
202
  landing_url: window.location.href,
58
203
  referrer_url: document.referrer || void 0,
@@ -72,17 +217,28 @@ var ActivityService = class {
72
217
  is_new_visitor: isNewVisitor
73
218
  };
74
219
  }
75
- /** Product/category views imply one; call this for every other page. */
220
+ /** Route-level page view. Product/category interactions are tracked separately. */
76
221
  trackPageView(options = {}) {
77
- this.sendEvents([
78
- {
79
- type: "page_view",
80
- page_path: options.pagePath ?? currentPath(),
81
- page_title: options.pageTitle ?? currentTitle()
82
- }
83
- ]);
222
+ if (typeof window === "undefined") return;
223
+ const pagePath = options.pagePath ?? currentPath() ?? "";
224
+ const transition = this.sessions.beginPage(pagePath);
225
+ const events = [];
226
+ if (transition.previousPage) {
227
+ events.push({
228
+ type: "page_duration",
229
+ page_path: transition.previousPage.path,
230
+ time_on_page: transition.previousPage.timeOnPageSeconds
231
+ });
232
+ }
233
+ events.push({
234
+ type: "page_view",
235
+ page_path: pagePath,
236
+ page_title: options.pageTitle ?? currentTitle()
237
+ });
238
+ this.sendEvents(events, transition.session);
84
239
  }
85
240
  trackProductView(productId, options = {}) {
241
+ if (typeof window === "undefined") return;
86
242
  const event = {
87
243
  type: "product_view",
88
244
  product_id: productId,
@@ -94,6 +250,7 @@ var ActivityService = class {
94
250
  this.sendEvents([event]);
95
251
  }
96
252
  trackCategoryView(categoryId, options = {}) {
253
+ if (typeof window === "undefined") return;
97
254
  const event = {
98
255
  type: "category_view",
99
256
  category_id: categoryId,
@@ -149,10 +306,33 @@ var ActivityService = class {
149
306
  window.removeEventListener("popstate", record);
150
307
  };
151
308
  }
152
- sendEvents(events) {
153
- this.startSession();
154
- this.client.post("/api/v1/activity/events", { events }).catch(() => {
309
+ sendEvents(events, session) {
310
+ if (typeof window === "undefined") return;
311
+ void this.postEvents(events, session ?? this.sessions.beginEvent()).catch(() => {
312
+ });
313
+ }
314
+ async postEvents(events, session) {
315
+ await this.bootstrapSession(session);
316
+ await this.client.post("/api/v1/activity/events", {
317
+ analytics_session_id: session.id,
318
+ occurred_at: session.occurredAt,
319
+ events
320
+ });
321
+ }
322
+ bootstrapSession(session, force = false) {
323
+ if (!force && !session.requiresBootstrap) return Promise.resolve();
324
+ if (!force && this.bootstrapRequest?.sessionId === session.id) {
325
+ return this.bootstrapRequest.promise;
326
+ }
327
+ const promise = this.client.post("/api/v1/activity/session", this.buildSessionPayload(session)).then(() => {
328
+ this.sessions.markBootstrapped(session.id);
329
+ }).finally(() => {
330
+ if (this.bootstrapRequest?.promise === promise) {
331
+ this.bootstrapRequest = null;
332
+ }
155
333
  });
334
+ this.bootstrapRequest = { sessionId: session.id, promise };
335
+ return promise;
156
336
  }
157
337
  };
158
338
  function currentPath() {
@@ -334,6 +514,7 @@ var DeliveryService = class {
334
514
  if (query.dropoffLat != null) params.set("dropoff_lat", String(query.dropoffLat));
335
515
  if (query.dropoffLng != null) params.set("dropoff_lng", String(query.dropoffLng));
336
516
  if (query.country) params.set("country", query.country);
517
+ if (query.currency) params.set("currency", query.currency);
337
518
  if (query.orderValue != null) params.set("order_value", String(query.orderValue));
338
519
  return safe(
339
520
  this.client.get(`/api/v1/delivery/options?${params.toString()}`)
@@ -760,6 +941,7 @@ var CimplifyClient = class {
760
941
  clearSession() {
761
942
  const previous = this.accessToken;
762
943
  this.accessToken = null;
944
+ this._activity?.resetSession();
763
945
  this.sessionToken = null;
764
946
  this.sessionEpoch++;
765
947
  try {
@@ -1217,9 +1217,17 @@ var CheckoutResolver = class {
1217
1217
  );
1218
1218
  }
1219
1219
  if (popupError === "PROVIDER_UNAVAILABLE") {
1220
- return this.fail("PROVIDER_UNAVAILABLE", "Card payment provider is unavailable.", false);
1220
+ return this.fail(
1221
+ "PROVIDER_UNAVAILABLE",
1222
+ "Card payment provider is unavailable.",
1223
+ false
1224
+ );
1221
1225
  }
1222
- return this.fail("PAYMENT_CANCELLED", "Card payment was cancelled before completion.", true);
1226
+ return this.fail(
1227
+ "PAYMENT_CANCELLED",
1228
+ "Card payment was cancelled before completion.",
1229
+ true
1230
+ );
1223
1231
  }
1224
1232
  paymentReference = popupResult.reference || paymentReference;
1225
1233
  break;
@@ -1227,7 +1235,11 @@ var CheckoutResolver = class {
1227
1235
  case NEXT_ACTION_REDIRECT: {
1228
1236
  if (typeof window !== "undefined" && this.returnUrl) {
1229
1237
  window.location.assign(action.authorization_url);
1230
- return this.fail("REDIRECT_REQUIRED", "Redirecting to complete payment authorization.", true);
1238
+ return this.fail(
1239
+ "REDIRECT_REQUIRED",
1240
+ "Redirecting to complete payment authorization.",
1241
+ true
1242
+ );
1231
1243
  }
1232
1244
  if (typeof window !== "undefined") {
1233
1245
  const popup = window.open(
@@ -1484,8 +1496,12 @@ var CheckoutResolver = class {
1484
1496
  apartment: source.apartment || void 0,
1485
1497
  city: source.city || "",
1486
1498
  region: source.region || "",
1499
+ postal_code: source.postal_code || void 0,
1500
+ country: source.country || void 0,
1487
1501
  delivery_instructions: source.delivery_instructions || void 0,
1488
- phone_for_delivery: source.phone_for_delivery || void 0
1502
+ phone_for_delivery: source.phone_for_delivery || void 0,
1503
+ latitude: source.latitude,
1504
+ longitude: source.longitude
1489
1505
  };
1490
1506
  }
1491
1507
  getEnrollmentMobileMoney() {
@@ -1859,6 +1875,7 @@ var LinkService = class {
1859
1875
  );
1860
1876
  if (result.ok && result.value.session_token) {
1861
1877
  this.client.setAccessToken(result.value.session_token);
1878
+ this.client.activity.refreshIdentity();
1862
1879
  this.client.autoClaimChatIdentity();
1863
1880
  }
1864
1881
  return result;
@@ -1871,6 +1888,7 @@ var LinkService = class {
1871
1888
  );
1872
1889
  if (result.ok && result.value.session_token) {
1873
1890
  this.client.setAccessToken(result.value.session_token);
1891
+ this.client.activity.refreshIdentity();
1874
1892
  this.client.autoClaimChatIdentity();
1875
1893
  }
1876
1894
  return result;
@@ -2055,6 +2073,7 @@ var AuthService = class {
2055
2073
  );
2056
2074
  if (result.ok && result.value.session_token) {
2057
2075
  this.client.setAccessToken(result.value.session_token);
2076
+ this.client.activity.refreshIdentity();
2058
2077
  this.client.autoClaimChatIdentity();
2059
2078
  }
2060
2079
  return result;
@@ -957,6 +957,10 @@ interface CreateAddressInput {
957
957
  region?: string;
958
958
  postal_code?: string;
959
959
  country?: string;
960
+ delivery_instructions?: string;
961
+ phone_for_delivery?: string;
962
+ latitude?: number;
963
+ longitude?: number;
960
964
  }
961
965
  interface UpdateAddressInput {
962
966
  address_id: string;
@@ -967,6 +971,11 @@ interface UpdateAddressInput {
967
971
  region?: string;
968
972
  postal_code?: string;
969
973
  country?: string;
974
+ delivery_instructions?: string;
975
+ phone_for_delivery?: string;
976
+ latitude?: number;
977
+ longitude?: number;
978
+ clear_coordinates?: boolean;
970
979
  }
971
980
  interface CreateMobileMoneyInput {
972
981
  phone_number: string;
@@ -983,8 +992,12 @@ interface AddressData {
983
992
  apartment?: string;
984
993
  city: string;
985
994
  region: string;
995
+ postal_code?: string;
996
+ country?: string;
986
997
  delivery_instructions?: string;
987
998
  phone_for_delivery?: string;
999
+ latitude?: number;
1000
+ longitude?: number;
988
1001
  }
989
1002
  interface MobileMoneyData {
990
1003
  phone_number: string;
@@ -2418,14 +2431,21 @@ interface DismissMessageResponse {
2418
2431
  }
2419
2432
  declare class ActivityService {
2420
2433
  private client;
2434
+ private readonly sessions;
2435
+ private bootstrapRequest;
2421
2436
  constructor(client: CimplifyClient);
2422
2437
  /**
2423
2438
  * Record session start (landing, referrer, UTM, device). Fire-and-forget,
2424
- * at most once per tab session; called automatically by the track* methods.
2439
+ * at most once per 30-minute-idle analytics session; called automatically
2440
+ * by the track* methods.
2425
2441
  */
2426
2442
  startSession(): void;
2443
+ /** Rebind an existing analytics session after the server authenticates a customer. */
2444
+ refreshIdentity(): void;
2445
+ /** A signed-out browser starts a fresh anonymous analytics session. */
2446
+ resetSession(): void;
2427
2447
  private buildSessionPayload;
2428
- /** Product/category views imply one; call this for every other page. */
2448
+ /** Route-level page view. Product/category interactions are tracked separately. */
2429
2449
  trackPageView(options?: TrackPageViewOptions): void;
2430
2450
  trackProductView(productId: string, options?: TrackProductViewOptions): void;
2431
2451
  trackCategoryView(categoryId: string, options?: TrackCategoryViewOptions): void;
@@ -2438,6 +2458,8 @@ declare class ActivityService {
2438
2458
  /** Records a page view now and on every route change; returns a stop fn. */
2439
2459
  autoTrackPageViews(): () => void;
2440
2460
  private sendEvents;
2461
+ private postEvents;
2462
+ private bootstrapSession;
2441
2463
  }
2442
2464
 
2443
2465
  interface IdempotencyOption$2 {
@@ -2542,6 +2564,8 @@ interface DeliveryOptionsResponse {
2542
2564
  }
2543
2565
  interface GetDeliveryOptionsParams {
2544
2566
  country?: string;
2567
+ /** Cart currency. Rates in another currency are never returned. */
2568
+ currency?: string;
2545
2569
  /** Cart goods total — drives free-over thresholds and zone minimums. */
2546
2570
  orderValue?: Money;
2547
2571
  }
@@ -1,5 +1,5 @@
1
- import { af as CimplifyClient } from './client-LPg_AUUr.js';
2
- import { A as AppHandle, C as CreateAppOptions } from './server-CNyy47HL.js';
1
+ import { af as CimplifyClient } from './client-CrPglBBz.js';
2
+ import { A as AppHandle, C as CreateAppOptions } from './server-zyrpzJVn.js';
3
3
 
4
4
  /**
5
5
  * Test client + fixtures.
@@ -957,6 +957,10 @@ interface CreateAddressInput {
957
957
  region?: string;
958
958
  postal_code?: string;
959
959
  country?: string;
960
+ delivery_instructions?: string;
961
+ phone_for_delivery?: string;
962
+ latitude?: number;
963
+ longitude?: number;
960
964
  }
961
965
  interface UpdateAddressInput {
962
966
  address_id: string;
@@ -967,6 +971,11 @@ interface UpdateAddressInput {
967
971
  region?: string;
968
972
  postal_code?: string;
969
973
  country?: string;
974
+ delivery_instructions?: string;
975
+ phone_for_delivery?: string;
976
+ latitude?: number;
977
+ longitude?: number;
978
+ clear_coordinates?: boolean;
970
979
  }
971
980
  interface CreateMobileMoneyInput {
972
981
  phone_number: string;
@@ -983,8 +992,12 @@ interface AddressData {
983
992
  apartment?: string;
984
993
  city: string;
985
994
  region: string;
995
+ postal_code?: string;
996
+ country?: string;
986
997
  delivery_instructions?: string;
987
998
  phone_for_delivery?: string;
999
+ latitude?: number;
1000
+ longitude?: number;
988
1001
  }
989
1002
  interface MobileMoneyData {
990
1003
  phone_number: string;
@@ -2418,14 +2431,21 @@ interface DismissMessageResponse {
2418
2431
  }
2419
2432
  declare class ActivityService {
2420
2433
  private client;
2434
+ private readonly sessions;
2435
+ private bootstrapRequest;
2421
2436
  constructor(client: CimplifyClient);
2422
2437
  /**
2423
2438
  * Record session start (landing, referrer, UTM, device). Fire-and-forget,
2424
- * at most once per tab session; called automatically by the track* methods.
2439
+ * at most once per 30-minute-idle analytics session; called automatically
2440
+ * by the track* methods.
2425
2441
  */
2426
2442
  startSession(): void;
2443
+ /** Rebind an existing analytics session after the server authenticates a customer. */
2444
+ refreshIdentity(): void;
2445
+ /** A signed-out browser starts a fresh anonymous analytics session. */
2446
+ resetSession(): void;
2427
2447
  private buildSessionPayload;
2428
- /** Product/category views imply one; call this for every other page. */
2448
+ /** Route-level page view. Product/category interactions are tracked separately. */
2429
2449
  trackPageView(options?: TrackPageViewOptions): void;
2430
2450
  trackProductView(productId: string, options?: TrackProductViewOptions): void;
2431
2451
  trackCategoryView(categoryId: string, options?: TrackCategoryViewOptions): void;
@@ -2438,6 +2458,8 @@ declare class ActivityService {
2438
2458
  /** Records a page view now and on every route change; returns a stop fn. */
2439
2459
  autoTrackPageViews(): () => void;
2440
2460
  private sendEvents;
2461
+ private postEvents;
2462
+ private bootstrapSession;
2441
2463
  }
2442
2464
 
2443
2465
  interface IdempotencyOption$2 {
@@ -2542,6 +2564,8 @@ interface DeliveryOptionsResponse {
2542
2564
  }
2543
2565
  interface GetDeliveryOptionsParams {
2544
2566
  country?: string;
2567
+ /** Cart currency. Rates in another currency are never returned. */
2568
+ currency?: string;
2545
2569
  /** Cart goods total — drives free-over thresholds and zone minimums. */
2546
2570
  orderValue?: Money;
2547
2571
  }
@@ -1,5 +1,5 @@
1
- import { af as CimplifyClient } from './client-D8XcrONA.mjs';
2
- import { A as AppHandle, C as CreateAppOptions } from './server--RyVAfPN.mjs';
1
+ import { af as CimplifyClient } from './client-BwRAAk4y.mjs';
2
+ import { A as AppHandle, C as CreateAppOptions } from './server-DRAW2OOX.mjs';
3
3
 
4
4
  /**
5
5
  * Test client + fixtures.