@aranova/tracking-react 1.8.1 → 1.10.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.
package/dist/sales.mjs CHANGED
@@ -206,6 +206,7 @@ function camelRules(rules) {
206
206
  closedDates: rules.closed_dates,
207
207
  specialHours: rules.special_hours,
208
208
  vehicleRequired: rules.vehicle_required,
209
+ vehicleDeferred: rules.vehicle_deferred,
209
210
  dropOffOptions: rules.drop_off_options
210
211
  };
211
212
  }
@@ -399,8 +400,17 @@ var BOOKING_SIMULATE_HEADER = "X-Aranova-Simulate";
399
400
  var BOOKING_ERROR_CODES = {
400
401
  unavailable: "booking_unavailable",
401
402
  stale: "booking_config_stale",
402
- rejected: "booking_rejected"
403
+ rejected: "booking_rejected",
404
+ attemptMismatch: "booking_attempt_mismatch",
405
+ detailsConflict: "idempotency_conflict"
403
406
  };
407
+ function detailsFailure(error) {
408
+ if (!(error instanceof AranovaApiError)) return "failed";
409
+ if (error.code === BOOKING_ERROR_CODES.attemptMismatch) return "mismatch";
410
+ if (error.code === BOOKING_ERROR_CODES.detailsConflict) return "conflict";
411
+ if (error.status === 404) return "not_found";
412
+ return error.status === 422 ? "invalid" : "failed";
413
+ }
404
414
  var POLL_DELAYS_MS = [1e3, 2e3, 4e3, 8e3, 15e3];
405
415
  var INVALID_DETAILS = "Please check your details and try again.";
406
416
  var newBookingAttemptKey = uuidV4;
@@ -585,6 +595,26 @@ function createSalesBookingsClient(config, firing) {
585
595
  onPending?.(outcome);
586
596
  return withHandoff(await poll(outcome.id, outcome.mode), input);
587
597
  },
598
+ async updateBooking(bookingId, details, { attemptKey }) {
599
+ const body = {
600
+ idempotency_key: attemptKey,
601
+ vehicle: details.vehicle ?? null,
602
+ notes: details.notes?.trim() || null,
603
+ heard_via: details.heardVia?.trim() || null
604
+ };
605
+ try {
606
+ const response = await salesRequest(
607
+ config,
608
+ "POST",
609
+ `/bookings/${encodeURIComponent(bookingId)}/details`,
610
+ body
611
+ );
612
+ return { status: response.status, id: response.id };
613
+ } catch (error) {
614
+ const message = error instanceof Error ? error.message : String(error);
615
+ return { status: detailsFailure(error), id: bookingId, message };
616
+ }
617
+ },
588
618
  async status(id) {
589
619
  return outcomeOf(
590
620
  await salesRequest(
@@ -818,6 +848,7 @@ var zErrorCode = z.enum([
818
848
  "booking_unavailable",
819
849
  "booking_config_stale",
820
850
  "booking_rejected",
851
+ "booking_attempt_mismatch",
821
852
  "calendar_not_owned",
822
853
  "calendar_is_sandbox",
823
854
  "sandbox_exists",
@@ -898,7 +929,6 @@ var zSmsWithheldReason = z.enum([
898
929
  "confirmed_by_integration",
899
930
  "test_or_bot_session",
900
931
  "invalid_phone",
901
- "quiet_hours",
902
932
  "recently_texted"
903
933
  ]);
904
934
  var zSaleSmsStatusSchema = z.object({