@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.
@@ -1,4 +1,4 @@
1
- import { j as BookingDayWindows, c as BookingMode, k as ConversionIntegrations } from './bookings-B50X7GSG.js';
1
+ import { p as BookingDayWindows, h as BookingMode, q as ConversionIntegrations } from './bookings-D5TT6D8w.js';
2
2
  import * as zod_v4_core from 'zod/v4/core';
3
3
  import * as z from 'zod/mini';
4
4
  import { J as JsonValue, F as FormSubmitConfig, a as FormSubmitMetadata } from './form-submit-BLb28aCk.js';
@@ -30,6 +30,8 @@ interface BookingRules {
30
30
  /** `YYYY-MM-DD` shop dates whose start hours replace their weekday's. */
31
31
  specialHours: Record<string, BookingDayWindows>;
32
32
  vehicleRequired: boolean;
33
+ /** The vehicle may come after booking: send it with `bookings.updateBooking`. */
34
+ vehicleDeferred: boolean;
33
35
  /** `waitForIt` / `dropOff`; empty when the shop hides the question. */
34
36
  dropOffOptions: string[];
35
37
  }
@@ -1,4 +1,4 @@
1
- import { j as BookingDayWindows, c as BookingMode, k as ConversionIntegrations } from './bookings-n8UUzrak.mjs';
1
+ import { p as BookingDayWindows, h as BookingMode, q as ConversionIntegrations } from './bookings-CUes6H05.mjs';
2
2
  import * as zod_v4_core from 'zod/v4/core';
3
3
  import * as z from 'zod/mini';
4
4
  import { J as JsonValue, F as FormSubmitConfig, a as FormSubmitMetadata } from './form-submit-BLb28aCk.mjs';
@@ -30,6 +30,8 @@ interface BookingRules {
30
30
  /** `YYYY-MM-DD` shop dates whose start hours replace their weekday's. */
31
31
  specialHours: Record<string, BookingDayWindows>;
32
32
  vehicleRequired: boolean;
33
+ /** The vehicle may come after booking: send it with `bookings.updateBooking`. */
34
+ vehicleDeferred: boolean;
33
35
  /** `waitForIt` / `dropOff`; empty when the shop hides the question. */
34
36
  dropOffOptions: string[];
35
37
  }
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/mini';
2
- import { S as SalesBookingsClient, g as ConversionConfigStore, l as TrackingConfigRuntime } from './bookings-B50X7GSG.js';
2
+ import { S as SalesBookingsClient, l as ConversionConfigStore, s as TrackingConfigRuntime } from './bookings-D5TT6D8w.js';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  /** Raw identifiers a caller may hand us (normalized before use). */
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/mini';
2
- import { S as SalesBookingsClient, g as ConversionConfigStore, l as TrackingConfigRuntime } from './bookings-n8UUzrak.mjs';
2
+ import { S as SalesBookingsClient, l as ConversionConfigStore, s as TrackingConfigRuntime } from './bookings-CUes6H05.mjs';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  /** Raw identifiers a caller may hand us (normalized before use). */
package/dist/sales.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-DByfvgzT.mjs';
2
- export { B as BookingDropOff, a as BookingFormSubmit, b as BookingInput, c as BookingMode, d as BookingOutcome, e as BookingSimulation, f as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-n8UUzrak.mjs';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-CY6gbYud.mjs';
2
+ export { B as BookingDetailsFailure, a as BookingDetailsInput, b as BookingDetailsOptions, c as BookingDetailsOutcome, d as BookingDetailsStatus, e as BookingDropOff, f as BookingFormSubmit, g as BookingInput, h as BookingMode, i as BookingOutcome, j as BookingSimulation, k as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-CUes6H05.mjs';
3
3
  import 'zod/mini';
4
4
  import 'libphonenumber-js';
5
5
  import './form-submit-BLb28aCk.mjs';
package/dist/sales.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-D4QRnpdz.js';
2
- export { B as BookingDropOff, a as BookingFormSubmit, b as BookingInput, c as BookingMode, d as BookingOutcome, e as BookingSimulation, f as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-B50X7GSG.js';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-5AdaCCUc.js';
2
+ export { B as BookingDetailsFailure, a as BookingDetailsInput, b as BookingDetailsOptions, c as BookingDetailsOutcome, d as BookingDetailsStatus, e as BookingDropOff, f as BookingFormSubmit, g as BookingInput, h as BookingMode, i as BookingOutcome, j as BookingSimulation, k as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-D5TT6D8w.js';
3
3
  import 'zod/mini';
4
4
  import 'libphonenumber-js';
5
5
  import './form-submit-BLb28aCk.js';
package/dist/sales.js CHANGED
@@ -259,6 +259,7 @@ function camelRules(rules) {
259
259
  closedDates: rules.closed_dates,
260
260
  specialHours: rules.special_hours,
261
261
  vehicleRequired: rules.vehicle_required,
262
+ vehicleDeferred: rules.vehicle_deferred,
262
263
  dropOffOptions: rules.drop_off_options
263
264
  };
264
265
  }
@@ -452,8 +453,17 @@ var BOOKING_SIMULATE_HEADER = "X-Aranova-Simulate";
452
453
  var BOOKING_ERROR_CODES = {
453
454
  unavailable: "booking_unavailable",
454
455
  stale: "booking_config_stale",
455
- rejected: "booking_rejected"
456
+ rejected: "booking_rejected",
457
+ attemptMismatch: "booking_attempt_mismatch",
458
+ detailsConflict: "idempotency_conflict"
456
459
  };
460
+ function detailsFailure(error) {
461
+ if (!(error instanceof AranovaApiError)) return "failed";
462
+ if (error.code === BOOKING_ERROR_CODES.attemptMismatch) return "mismatch";
463
+ if (error.code === BOOKING_ERROR_CODES.detailsConflict) return "conflict";
464
+ if (error.status === 404) return "not_found";
465
+ return error.status === 422 ? "invalid" : "failed";
466
+ }
457
467
  var POLL_DELAYS_MS = [1e3, 2e3, 4e3, 8e3, 15e3];
458
468
  var INVALID_DETAILS = "Please check your details and try again.";
459
469
  var newBookingAttemptKey = uuidV4;
@@ -638,6 +648,26 @@ function createSalesBookingsClient(config, firing) {
638
648
  onPending?.(outcome);
639
649
  return withHandoff(await poll(outcome.id, outcome.mode), input);
640
650
  },
651
+ async updateBooking(bookingId, details, { attemptKey }) {
652
+ const body = {
653
+ idempotency_key: attemptKey,
654
+ vehicle: details.vehicle ?? null,
655
+ notes: details.notes?.trim() || null,
656
+ heard_via: details.heardVia?.trim() || null
657
+ };
658
+ try {
659
+ const response = await salesRequest(
660
+ config,
661
+ "POST",
662
+ `/bookings/${encodeURIComponent(bookingId)}/details`,
663
+ body
664
+ );
665
+ return { status: response.status, id: response.id };
666
+ } catch (error) {
667
+ const message = error instanceof Error ? error.message : String(error);
668
+ return { status: detailsFailure(error), id: bookingId, message };
669
+ }
670
+ },
641
671
  async status(id) {
642
672
  return outcomeOf(
643
673
  await salesRequest(
@@ -871,6 +901,7 @@ var zErrorCode = z.enum([
871
901
  "booking_unavailable",
872
902
  "booking_config_stale",
873
903
  "booking_rejected",
904
+ "booking_attempt_mismatch",
874
905
  "calendar_not_owned",
875
906
  "calendar_is_sandbox",
876
907
  "sandbox_exists",
@@ -951,7 +982,6 @@ var zSmsWithheldReason = z.enum([
951
982
  "confirmed_by_integration",
952
983
  "test_or_bot_session",
953
984
  "invalid_phone",
954
- "quiet_hours",
955
985
  "recently_texted"
956
986
  ]);
957
987
  var zSaleSmsStatusSchema = z.object({