@aranova/tracking-react 1.12.0 → 1.13.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/index.js CHANGED
@@ -1419,6 +1419,10 @@ var TrackingConfigRuntime = class {
1419
1419
  integrations() {
1420
1420
  return this.current?.integrations ?? null;
1421
1421
  }
1422
+ /** The lead-form contracts, from the cached object like `integrations()`. */
1423
+ leadForms() {
1424
+ return this.current?.lead_forms ?? null;
1425
+ }
1422
1426
  async revalidateNow() {
1423
1427
  try {
1424
1428
  const headers = {};
@@ -1801,6 +1805,118 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
1801
1805
  var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
1802
1806
  var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
1803
1807
 
1808
+ // ../tracking-core/src/lead-forms/lead-forms.gen.ts
1809
+ var z2 = __toESM(require("zod/mini"));
1810
+ var LEAD_FORM_REGISTRY_VERSION = 2;
1811
+ var LEAD_FORM_KINDS = ["booking", "quote", "contact", "consult", "callback"];
1812
+ var LEAD_FORM_ROLES = [
1813
+ "given_name",
1814
+ "family_name",
1815
+ "phone",
1816
+ "email",
1817
+ "service",
1818
+ "preferred_date",
1819
+ "preferred_time",
1820
+ "note",
1821
+ "visit",
1822
+ "intent",
1823
+ "vehicle",
1824
+ "drop_off",
1825
+ "address",
1826
+ "patient_type",
1827
+ "matter",
1828
+ "language",
1829
+ "products",
1830
+ "goal",
1831
+ "business_type",
1832
+ "lead_volume",
1833
+ "attribution"
1834
+ ];
1835
+ var LEAD_FORM_PRIMITIVES = [
1836
+ "string",
1837
+ "text",
1838
+ "enum",
1839
+ "multi_enum",
1840
+ "bool",
1841
+ "date",
1842
+ "time_window",
1843
+ "phone",
1844
+ "email",
1845
+ "address",
1846
+ "number"
1847
+ ];
1848
+ var leadFormPrimitiveSchemas = /* @__PURE__ */ (() => ({
1849
+ string: z2.string().check(z2.maxLength(120)),
1850
+ text: z2.string().check(z2.maxLength(2e3)),
1851
+ enum: z2.string().check(z2.regex(/^[a-z0-9-]{1,48}$/)),
1852
+ multi_enum: z2.array(z2.string().check(z2.regex(/^[a-z0-9-]{1,48}$/))).check(z2.maxLength(10)),
1853
+ bool: z2.boolean(),
1854
+ date: z2.string().check(z2.regex(/^\d{4}-\d{2}-\d{2}$/)),
1855
+ time_window: z2.strictObject({
1856
+ start: z2.string().check(z2.regex(/^([01]\d|2[0-3]):[0-5]\d$/)),
1857
+ end: z2.nullable(z2.string().check(z2.regex(/^([01]\d|2[0-3]):[0-5]\d$/))),
1858
+ label: z2.optional(z2.string().check(z2.maxLength(60)))
1859
+ }),
1860
+ phone: z2.string().check(z2.regex(/^\+[1-9]\d{6,14}$/)),
1861
+ email: z2.string().check(z2.maxLength(320), z2.regex(/^[^\s@]+@[^\s@]+$/)),
1862
+ address: z2.strictObject({
1863
+ line1: z2.string().check(z2.maxLength(120)),
1864
+ line2: z2.optional(z2.string().check(z2.maxLength(120))),
1865
+ city: z2.optional(z2.string().check(z2.maxLength(120))),
1866
+ region: z2.optional(z2.string().check(z2.maxLength(120))),
1867
+ postal_code: z2.optional(z2.string().check(z2.maxLength(120))),
1868
+ country: z2.optional(z2.string().check(z2.maxLength(120)))
1869
+ }),
1870
+ number: z2.number()
1871
+ }))();
1872
+ var LEAD_FORM_ROLE_SPECS = {
1873
+ given_name: { primitive: "string", smsLabel: "", contactIdentity: true },
1874
+ family_name: { primitive: "string", smsLabel: "", contactIdentity: true },
1875
+ phone: { primitive: "phone", smsLabel: "", contactIdentity: true },
1876
+ email: { primitive: "email", smsLabel: "", contactIdentity: true },
1877
+ service: { primitive: "multi_enum", smsLabel: "Service" },
1878
+ preferred_date: { primitive: "date", smsLabel: "Date" },
1879
+ preferred_time: { primitive: "time_window", smsLabel: "Time" },
1880
+ note: { primitive: "text", smsLabel: "Note" },
1881
+ visit: {
1882
+ primitive: "enum",
1883
+ smsLabel: "Visit",
1884
+ options: [
1885
+ { key: "in-shop", label: "In shop" },
1886
+ { key: "in-home", label: "In home" },
1887
+ { key: "remote", label: "Remote" },
1888
+ { key: "on-site", label: "On site" }
1889
+ ]
1890
+ },
1891
+ intent: {
1892
+ primitive: "enum",
1893
+ smsLabel: "Wants",
1894
+ options: [
1895
+ { key: "book", label: "Book" },
1896
+ { key: "quote", label: "Quote" }
1897
+ ]
1898
+ },
1899
+ vehicle: { primitive: "string", smsLabel: "Vehicle" },
1900
+ drop_off: {
1901
+ primitive: "enum",
1902
+ smsLabel: "Drop-off",
1903
+ options: [
1904
+ { key: "wait-for-it", label: "Waiting" },
1905
+ { key: "drop-off", label: "Dropping off" }
1906
+ ]
1907
+ },
1908
+ address: { primitive: "address", smsLabel: "Address" },
1909
+ patient_type: { primitive: "enum", smsLabel: "Patient" },
1910
+ matter: { primitive: "enum", smsLabel: "Matter" },
1911
+ language: { primitive: "enum", smsLabel: "Language" },
1912
+ products: { primitive: "multi_enum", smsLabel: "Products" },
1913
+ goal: { primitive: "enum", smsLabel: "Goal" },
1914
+ business_type: { primitive: "enum", smsLabel: "Business" },
1915
+ lead_volume: { primitive: "enum", smsLabel: "Lead volume" },
1916
+ add_on: { primitive: "bool", smsLabel: "" },
1917
+ attribution: { primitive: "enum", smsLabel: "", uninteresting: true }
1918
+ };
1919
+
1804
1920
  // ../tracking-core/src/resources/http/errors.ts
1805
1921
  var AranovaApiError = class extends Error {
1806
1922
  constructor(message, options) {
@@ -1894,39 +2010,54 @@ function outcomeOf(body) {
1894
2010
  if (body.status === "pending") return { status: "pending", id: body.id, mode };
1895
2011
  return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
1896
2012
  }
1897
- function formSubmitPayload(input, formSubmit, labels) {
1898
- const vehicle = input.vehicle ? `${input.vehicle.year} ${input.vehicle.make} ${input.vehicle.model}` : "";
1899
- const field = (name, type, label, value) => ({
1900
- name,
1901
- type,
1902
- label,
1903
- value
1904
- });
1905
- const fields = [
1906
- field("first_name", "text", "First name", input.firstName),
1907
- field("last_name", "text", "Last name", input.lastName),
2013
+ var DROP_OFF_KEYS = {
2014
+ waitForIt: "wait-for-it",
2015
+ dropOff: "drop-off"
2016
+ };
2017
+ function formSubmitPayload(input, formSubmit, contractHash) {
2018
+ const field = (role, name, type, label, value) => ({ name, type, label, value, role });
2019
+ const text = (value) => value?.trim() || void 0;
2020
+ const { vehicle, dropOff } = input;
2021
+ const entries = [
2022
+ field("given_name", "first_name", "text", "First name", text(input.firstName)),
2023
+ field("family_name", "last_name", "text", "Last name", text(input.lastName)),
1908
2024
  // E.164 on the wire: it keys the customer and enhanced-conversion matching.
1909
- field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
1910
- field("email", "email", "Email", input.email ?? ""),
2025
+ field("phone", "phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
2026
+ field("email", "email", "email", "Email", text(input.email)),
2027
+ field("service", "service", "select", "Service", input.services),
1911
2028
  field(
1912
- "service",
1913
- "select",
1914
- "Service",
1915
- input.services.map((key) => labels.get(key) ?? key).join(", ")
2029
+ "vehicle",
2030
+ "vehicle",
2031
+ "text",
2032
+ "Vehicle",
2033
+ vehicle ? `${vehicle.year} ${vehicle.make} ${vehicle.model}` : void 0
1916
2034
  ),
1917
- field("vehicle", "text", "Vehicle", vehicle),
1918
2035
  field(
1919
- "start",
1920
- "text",
1921
- "Requested time",
1922
- `${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
2036
+ "drop_off",
2037
+ "drop_off",
2038
+ "select",
2039
+ "Drop-off",
2040
+ dropOff ? DROP_OFF_KEYS[dropOff] : void 0
1923
2041
  ),
1924
- field("note", "textarea", "Notes", input.notes ?? "")
2042
+ field("preferred_date", "preferred_date", "date", "Date", input.startDate),
2043
+ field("preferred_time", "preferred_time", "time", "Time", {
2044
+ start: `${String(input.startHour).padStart(2, "0")}:00`,
2045
+ end: null
2046
+ }),
2047
+ field("note", "note", "textarea", "Notes", text(input.notes))
1925
2048
  ];
1926
- const reported = new Set(fields.map((item) => item.name));
2049
+ const reported = new Set(entries.map((item) => item.name));
2050
+ const fields = entries.filter((item) => item.value !== void 0);
1927
2051
  const extra = (formSubmit.extraFields ?? []).filter((item) => !reported.has(item.name));
1928
2052
  return {
1929
- form: { id: formSubmit.formId, action: "/tracking/bookings", fields: [...fields, ...extra] },
2053
+ form: {
2054
+ id: formSubmit.formId,
2055
+ action: "/tracking/bookings",
2056
+ fields: [...fields, ...extra],
2057
+ kind: "booking",
2058
+ contract_version: LEAD_FORM_REGISTRY_VERSION,
2059
+ ...contractHash ? { contract_hash: contractHash } : {}
2060
+ },
1930
2061
  page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
1931
2062
  };
1932
2063
  }
@@ -2024,8 +2155,11 @@ function createSalesBookingsClient(config, firing) {
2024
2155
  }
2025
2156
  if (formSubmit && !submittedForms.has(attemptKey)) {
2026
2157
  submittedForms.add(attemptKey);
2027
- const labels = new Map(booking.options.map((option) => [option.key, option.label]));
2028
- formSubmit.tracking.trackEvent("form_submit", formSubmitPayload(input, formSubmit, labels));
2158
+ const contract = runtime?.leadForms()?.contracts.find((c) => c.form_kind === "booking");
2159
+ formSubmit.tracking.trackEvent(
2160
+ "form_submit",
2161
+ formSubmitPayload(input, formSubmit, contract?.contract_hash ?? null)
2162
+ );
2029
2163
  }
2030
2164
  const body = {
2031
2165
  idempotency_key: attemptKey,
@@ -2275,17 +2409,17 @@ function createSalesClient(config) {
2275
2409
  }
2276
2410
 
2277
2411
  // ../tracking-core/src/resources/sales/schema.ts
2278
- var z3 = __toESM(require("zod/mini"));
2412
+ var z4 = __toESM(require("zod/mini"));
2279
2413
 
2280
2414
  // ../tracking-core/src/resources/sales/generated/zod.gen.ts
2281
- var z2 = __toESM(require("zod/mini"));
2282
- var zAutoLeapSaleFacts = z2.object({
2283
- first_order: z2.boolean(),
2284
- fleet_customer: z2.boolean(),
2285
- invoice_code: z2.string(),
2286
- invoice_id: z2.string()
2415
+ var z3 = __toESM(require("zod/mini"));
2416
+ var zAutoLeapSaleFacts = z3.object({
2417
+ first_order: z3.boolean(),
2418
+ fleet_customer: z3.boolean(),
2419
+ invoice_code: z3.string(),
2420
+ invoice_id: z3.string()
2287
2421
  });
2288
- var zErrorCode = z2.enum([
2422
+ var zErrorCode = z3.enum([
2289
2423
  "missing_credentials",
2290
2424
  "invalid_api_key",
2291
2425
  "not_authenticated",
@@ -2329,37 +2463,37 @@ var zErrorCode = z2.enum([
2329
2463
  "rate_limited",
2330
2464
  "internal_error"
2331
2465
  ]);
2332
- var zSaleItemEntitySchema = z2.object({
2333
- category: z2.nullable(z2.string()),
2334
- external_item_id: z2.nullable(z2.string()),
2335
- id: z2.uuid(),
2336
- name: z2.nullable(z2.string()),
2337
- quantity: z2.string().check(z2.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
2338
- unit_cost_cents: z2.nullable(z2.int()),
2339
- unit_price_cents: z2.int()
2466
+ var zSaleItemEntitySchema = z3.object({
2467
+ category: z3.nullable(z3.string()),
2468
+ external_item_id: z3.nullable(z3.string()),
2469
+ id: z3.uuid(),
2470
+ name: z3.nullable(z3.string()),
2471
+ quantity: z3.string().check(z3.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
2472
+ unit_cost_cents: z3.nullable(z3.int()),
2473
+ unit_price_cents: z3.int()
2340
2474
  });
2341
- var zSaleItemInputSchema = z2.strictObject({
2342
- category: z2.nullish(z2.string()),
2343
- external_item_id: z2.nullish(z2.string()),
2344
- name: z2.nullish(z2.string()),
2345
- quantity: z2.string().check(z2.regex(/^\d+(\.\d{1,3})?$/)),
2346
- unit_cost_cents: z2.nullish(z2.int().check(z2.gte(0))),
2347
- unit_price_cents: z2.int().check(z2.gte(0))
2475
+ var zSaleItemInputSchema = z3.strictObject({
2476
+ category: z3.nullish(z3.string()),
2477
+ external_item_id: z3.nullish(z3.string()),
2478
+ name: z3.nullish(z3.string()),
2479
+ quantity: z3.string().check(z3.regex(/^\d+(\.\d{1,3})?$/)),
2480
+ unit_cost_cents: z3.nullish(z3.int().check(z3.gte(0))),
2481
+ unit_price_cents: z3.int().check(z3.gte(0))
2348
2482
  });
2349
- var zSaleServiceEntitySchema = z2.object({
2350
- amount_cents: z2.int(),
2351
- id: z2.uuid(),
2352
- mapped: z2.nullable(z2.boolean()),
2353
- service_id: z2.uuid(),
2354
- service_key: z2.string(),
2355
- service_label: z2.string()
2483
+ var zSaleServiceEntitySchema = z3.object({
2484
+ amount_cents: z3.int(),
2485
+ id: z3.uuid(),
2486
+ mapped: z3.nullable(z3.boolean()),
2487
+ service_id: z3.uuid(),
2488
+ service_key: z3.string(),
2489
+ service_label: z3.string()
2356
2490
  });
2357
- var zSaleServiceInputSchema = z2.strictObject({
2358
- amount_cents: z2.int().check(z2.gte(0)),
2359
- service: z2.string()
2491
+ var zSaleServiceInputSchema = z3.strictObject({
2492
+ amount_cents: z3.int().check(z3.gte(0)),
2493
+ service: z3.string()
2360
2494
  });
2361
- var zSaleSource = z2.enum(["api", "admin", "autoleap"]);
2362
- var zSmsAutomationState = z2.enum([
2495
+ var zSaleSource = z3.enum(["api", "admin", "autoleap"]);
2496
+ var zSmsAutomationState = z3.enum([
2363
2497
  "needs_check",
2364
2498
  "failed",
2365
2499
  "undelivered",
@@ -2371,7 +2505,7 @@ var zSmsAutomationState = z2.enum([
2371
2505
  "eligible",
2372
2506
  "not_applicable"
2373
2507
  ]);
2374
- var zSmsWithheldReason = z2.enum([
2508
+ var zSmsWithheldReason = z3.enum([
2375
2509
  "automation_disabled",
2376
2510
  "sms_disabled",
2377
2511
  "no_phone",
@@ -2399,75 +2533,75 @@ var zSmsWithheldReason = z2.enum([
2399
2533
  "invalid_phone",
2400
2534
  "recently_texted"
2401
2535
  ]);
2402
- var zSaleSmsStatusSchema = z2.object({
2403
- can_send_now: z2._default(z2.boolean(), false),
2404
- last_message_at: z2.nullable(z2.iso.datetime({ offset: true })),
2405
- reason_detail: z2.nullable(z2.string()),
2536
+ var zSaleSmsStatusSchema = z3.object({
2537
+ can_send_now: z3._default(z3.boolean(), false),
2538
+ last_message_at: z3.nullable(z3.iso.datetime({ offset: true })),
2539
+ reason_detail: z3.nullable(z3.string()),
2406
2540
  state: zSmsAutomationState,
2407
- suppressed_by_other_sale: z2._default(z2.boolean(), false),
2408
- withheld_reason: z2.nullable(zSmsWithheldReason)
2541
+ suppressed_by_other_sale: z3._default(z3.boolean(), false),
2542
+ withheld_reason: z3.nullable(zSmsWithheldReason)
2409
2543
  });
2410
- var zSupportedCurrency = z2.enum(["USD", "CAD"]);
2411
- var zTrackingEnvironment = z2.enum(["production", "development"]);
2412
- var zSaleCreateSchema = z2.strictObject({
2413
- amount_total_cents: z2.nullish(z2.int().check(z2.gte(0))),
2544
+ var zSupportedCurrency = z3.enum(["USD", "CAD"]);
2545
+ var zTrackingEnvironment = z3.enum(["production", "development"]);
2546
+ var zSaleCreateSchema = z3.strictObject({
2547
+ amount_total_cents: z3.nullish(z3.int().check(z3.gte(0))),
2414
2548
  currency: zSupportedCurrency,
2415
- customer_email: z2.nullish(z2.email().check(z2.maxLength(320))),
2416
- customer_name: z2.nullish(z2.string().check(z2.maxLength(200))),
2417
- customer_phone: z2.nullish(z2.string().check(z2.maxLength(64))),
2418
- description: z2.nullish(z2.string()),
2419
- environment: z2._default(z2.optional(zTrackingEnvironment), "production"),
2420
- external_id: z2.nullish(z2.string()),
2421
- items: z2.optional(z2.array(zSaleItemInputSchema)),
2422
- metadata: z2.nullish(z2.record(z2.string(), z2.unknown())),
2423
- occurred_at: z2.iso.datetime({ offset: true }),
2424
- service: z2.nullish(z2.string()),
2425
- services: z2.nullish(z2.array(zSaleServiceInputSchema)),
2426
- sms_consent: z2.nullish(z2.boolean())
2549
+ customer_email: z3.nullish(z3.email().check(z3.maxLength(320))),
2550
+ customer_name: z3.nullish(z3.string().check(z3.maxLength(200))),
2551
+ customer_phone: z3.nullish(z3.string().check(z3.maxLength(64))),
2552
+ description: z3.nullish(z3.string()),
2553
+ environment: z3._default(z3.optional(zTrackingEnvironment), "production"),
2554
+ external_id: z3.nullish(z3.string()),
2555
+ items: z3.optional(z3.array(zSaleItemInputSchema)),
2556
+ metadata: z3.nullish(z3.record(z3.string(), z3.unknown())),
2557
+ occurred_at: z3.iso.datetime({ offset: true }),
2558
+ service: z3.nullish(z3.string()),
2559
+ services: z3.nullish(z3.array(zSaleServiceInputSchema)),
2560
+ sms_consent: z3.nullish(z3.boolean())
2427
2561
  });
2428
- var zValidationError = z2.object({
2429
- ctx: z2.optional(z2.record(z2.string(), z2.unknown())),
2430
- input: z2.optional(z2.unknown()),
2431
- loc: z2.array(z2.union([z2.string(), z2.int()])),
2432
- msg: z2.string(),
2433
- type: z2.string()
2562
+ var zValidationError = z3.object({
2563
+ ctx: z3.optional(z3.record(z3.string(), z3.unknown())),
2564
+ input: z3.optional(z3.unknown()),
2565
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2566
+ msg: z3.string(),
2567
+ type: z3.string()
2434
2568
  });
2435
- var zHttpValidationError = z2.object({
2436
- detail: z2.optional(z2.array(zValidationError))
2569
+ var zHttpValidationError = z3.object({
2570
+ detail: z3.optional(z3.array(zValidationError))
2437
2571
  });
2438
- var zValidationErrorItem = z2.object({
2439
- loc: z2.array(z2.union([z2.string(), z2.int()])),
2440
- msg: z2.string(),
2441
- type: z2.string()
2572
+ var zValidationErrorItem = z3.object({
2573
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2574
+ msg: z3.string(),
2575
+ type: z3.string()
2442
2576
  });
2443
- var zApiErrorSchema = z2.object({
2577
+ var zApiErrorSchema = z3.object({
2444
2578
  code: zErrorCode,
2445
- context: z2._default(z2.nullish(z2.record(z2.string(), z2.unknown())), null),
2446
- detail: z2.string(),
2447
- errors: z2._default(z2.nullish(z2.array(zValidationErrorItem)), null),
2448
- request_id: z2._default(z2.nullish(z2.string()), null)
2579
+ context: z3._default(z3.nullish(z3.record(z3.string(), z3.unknown())), null),
2580
+ detail: z3.string(),
2581
+ errors: z3._default(z3.nullish(z3.array(zValidationErrorItem)), null),
2582
+ request_id: z3._default(z3.nullish(z3.string()), null)
2449
2583
  });
2450
- var zWritebackEmailSource = z2.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
2451
- var zWritebackEnrichmentStatus = z2.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
2452
- var zWritebackSaleUploadCounts = z2.object({
2453
- failed: z2._default(z2.int(), 0),
2454
- pending: z2._default(z2.int(), 0),
2455
- skipped: z2._default(z2.int(), 0),
2456
- submitted: z2._default(z2.int(), 0),
2457
- total: z2._default(z2.int(), 0),
2458
- uploaded: z2._default(z2.int(), 0)
2584
+ var zWritebackEmailSource = z3.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
2585
+ var zWritebackEnrichmentStatus = z3.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
2586
+ var zWritebackSaleUploadCounts = z3.object({
2587
+ failed: z3._default(z3.int(), 0),
2588
+ pending: z3._default(z3.int(), 0),
2589
+ skipped: z3._default(z3.int(), 0),
2590
+ submitted: z3._default(z3.int(), 0),
2591
+ total: z3._default(z3.int(), 0),
2592
+ uploaded: z3._default(z3.int(), 0)
2459
2593
  });
2460
- var zSaleWritebackStatusSchema = z2.object({
2461
- blocked_reason: z2.nullable(z2.string()),
2462
- can_dispatch: z2._default(z2.boolean(), false),
2463
- email_source: z2.nullable(zWritebackEmailSource),
2464
- enrichment_status: z2.nullable(zWritebackEnrichmentStatus),
2465
- gclid_attached: z2._default(z2.boolean(), false),
2466
- identifiers_sent: z2.nullable(z2.string()),
2467
- mapped_service_ids: z2.array(z2.uuid()),
2468
- matched_submit_count: z2.nullable(z2.int()),
2469
- needs_force: z2._default(z2.boolean(), false),
2470
- rollup: z2.enum([
2594
+ var zSaleWritebackStatusSchema = z3.object({
2595
+ blocked_reason: z3.nullable(z3.string()),
2596
+ can_dispatch: z3._default(z3.boolean(), false),
2597
+ email_source: z3.nullable(zWritebackEmailSource),
2598
+ enrichment_status: z3.nullable(zWritebackEnrichmentStatus),
2599
+ gclid_attached: z3._default(z3.boolean(), false),
2600
+ identifiers_sent: z3.nullable(z3.string()),
2601
+ mapped_service_ids: z3.array(z3.uuid()),
2602
+ matched_submit_count: z3.nullable(z3.int()),
2603
+ needs_force: z3._default(z3.boolean(), false),
2604
+ rollup: z3.enum([
2471
2605
  "failed",
2472
2606
  "skipped",
2473
2607
  "pending",
@@ -2477,39 +2611,39 @@ var zSaleWritebackStatusSchema = z2.object({
2477
2611
  "out_of_window",
2478
2612
  "blocked"
2479
2613
  ]),
2480
- stale: z2._default(z2.boolean(), false),
2481
- uncovered_service_ids: z2.array(z2.uuid()),
2614
+ stale: z3._default(z3.boolean(), false),
2615
+ uncovered_service_ids: z3.array(z3.uuid()),
2482
2616
  uploads: zWritebackSaleUploadCounts
2483
2617
  });
2484
- var zSaleEntitySchema = z2.object({
2485
- amount_total_cents: z2.int(),
2486
- business_id: z2.uuid(),
2487
- business_name: z2.nullable(z2.string()),
2488
- created_at: z2.iso.datetime({ offset: true }),
2489
- currency: z2.string(),
2490
- customer_email: z2.nullable(z2.string()),
2491
- customer_name: z2.nullable(z2.string()),
2492
- customer_name_placeholder_confirmed: z2._default(z2.boolean(), false),
2493
- customer_name_placeholder_confirmed_at: z2.nullable(z2.iso.datetime({ offset: true })),
2494
- customer_phone: z2.nullable(z2.string()),
2495
- description: z2.nullable(z2.string()),
2618
+ var zSaleEntitySchema = z3.object({
2619
+ amount_total_cents: z3.int(),
2620
+ business_id: z3.uuid(),
2621
+ business_name: z3.nullable(z3.string()),
2622
+ created_at: z3.iso.datetime({ offset: true }),
2623
+ currency: z3.string(),
2624
+ customer_email: z3.nullable(z3.string()),
2625
+ customer_name: z3.nullable(z3.string()),
2626
+ customer_name_placeholder_confirmed: z3._default(z3.boolean(), false),
2627
+ customer_name_placeholder_confirmed_at: z3.nullable(z3.iso.datetime({ offset: true })),
2628
+ customer_phone: z3.nullable(z3.string()),
2629
+ description: z3.nullable(z3.string()),
2496
2630
  environment: zTrackingEnvironment,
2497
- external_id: z2.nullable(z2.string()),
2498
- id: z2.uuid(),
2499
- items: z2.array(zSaleItemEntitySchema),
2500
- metadata: z2.nullable(z2.record(z2.string(), z2.unknown())),
2501
- occurred_at: z2.iso.datetime({ offset: true }),
2502
- service_id: z2.nullable(z2.uuid()),
2503
- service_key: z2.nullable(z2.string()),
2504
- service_label: z2.nullable(z2.string()),
2505
- services: z2.array(zSaleServiceEntitySchema),
2506
- sms_automation: z2.nullable(zSaleSmsStatusSchema),
2507
- sms_consent: z2._default(z2.boolean(), false),
2508
- sms_consent_granted_at: z2.nullable(z2.iso.datetime({ offset: true })),
2631
+ external_id: z3.nullable(z3.string()),
2632
+ id: z3.uuid(),
2633
+ items: z3.array(zSaleItemEntitySchema),
2634
+ metadata: z3.nullable(z3.record(z3.string(), z3.unknown())),
2635
+ occurred_at: z3.iso.datetime({ offset: true }),
2636
+ service_id: z3.nullable(z3.uuid()),
2637
+ service_key: z3.nullable(z3.string()),
2638
+ service_label: z3.nullable(z3.string()),
2639
+ services: z3.array(zSaleServiceEntitySchema),
2640
+ sms_automation: z3.nullable(zSaleSmsStatusSchema),
2641
+ sms_consent: z3._default(z3.boolean(), false),
2642
+ sms_consent_granted_at: z3.nullable(z3.iso.datetime({ offset: true })),
2509
2643
  source: zSaleSource,
2510
- source_facts: z2.nullable(zAutoLeapSaleFacts),
2511
- updated_at: z2.iso.datetime({ offset: true }),
2512
- writeback: z2.nullable(zSaleWritebackStatusSchema)
2644
+ source_facts: z3.nullable(zAutoLeapSaleFacts),
2645
+ updated_at: z3.iso.datetime({ offset: true }),
2646
+ writeback: z3.nullable(zSaleWritebackStatusSchema)
2513
2647
  });
2514
2648
 
2515
2649
  // ../tracking-core/src/resources/sales/schema.ts
@@ -2518,11 +2652,11 @@ var saleServiceSchema = zSaleServiceInputSchema;
2518
2652
  var currencySchema = zSupportedCurrency;
2519
2653
  var SUPPORTED_CURRENCIES = currencySchema.options;
2520
2654
  var SALE_SOURCES = zSaleSource.options;
2521
- var centsSchema = z3.int().check(z3.gte(0));
2522
- var metadataSchema = z3.record(z3.string(), z3.unknown());
2523
- var customerNameSchema = z3.string().check(z3.maxLength(200));
2524
- var customerPhoneSchema = z3.string().check(z3.maxLength(64));
2525
- var customerEmailSchema = z3.email().check(z3.maxLength(320));
2655
+ var centsSchema = z4.int().check(z4.gte(0));
2656
+ var metadataSchema = z4.record(z4.string(), z4.unknown());
2657
+ var customerNameSchema = z4.string().check(z4.maxLength(200));
2658
+ var customerPhoneSchema = z4.string().check(z4.maxLength(64));
2659
+ var customerEmailSchema = z4.email().check(z4.maxLength(320));
2526
2660
  function addIssue(ctx, path, message) {
2527
2661
  ctx.issues.push({ code: "custom", input: ctx.value, path, message });
2528
2662
  }
@@ -2556,24 +2690,24 @@ function refineServiceXor(val, ctx, { requireAmount }) {
2556
2690
  );
2557
2691
  }
2558
2692
  }
2559
- var saleCreateSchema = z3.extend(zSaleCreateSchema, { items: z3._default(z3.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
2560
- var saleUpdateSchema = z3.strictObject({
2561
- description: z3.nullish(z3.string()),
2562
- service: z3.nullish(z3.string()),
2563
- services: z3.nullish(z3.array(saleServiceSchema)),
2564
- currency: z3.optional(currencySchema),
2565
- amount_total_cents: z3.optional(centsSchema),
2566
- occurred_at: z3.optional(z3.iso.datetime()),
2567
- items: z3.optional(z3.array(saleItemSchema)),
2568
- metadata: z3.nullish(metadataSchema),
2569
- customer_name: z3.nullish(customerNameSchema),
2693
+ var saleCreateSchema = z4.extend(zSaleCreateSchema, { items: z4._default(z4.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
2694
+ var saleUpdateSchema = z4.strictObject({
2695
+ description: z4.nullish(z4.string()),
2696
+ service: z4.nullish(z4.string()),
2697
+ services: z4.nullish(z4.array(saleServiceSchema)),
2698
+ currency: z4.optional(currencySchema),
2699
+ amount_total_cents: z4.optional(centsSchema),
2700
+ occurred_at: z4.optional(z4.iso.datetime()),
2701
+ items: z4.optional(z4.array(saleItemSchema)),
2702
+ metadata: z4.nullish(metadataSchema),
2703
+ customer_name: z4.nullish(customerNameSchema),
2570
2704
  // Re-attest when changing a filler-looking name; the server clears the
2571
2705
  // prior attestation whenever `customer_name` changes.
2572
- customer_name_placeholder_confirmed: z3.optional(z3.boolean()),
2573
- customer_phone: z3.nullish(customerPhoneSchema),
2574
- customer_email: z3.nullish(customerEmailSchema),
2706
+ customer_name_placeholder_confirmed: z4.optional(z4.boolean()),
2707
+ customer_phone: z4.nullish(customerPhoneSchema),
2708
+ customer_email: z4.nullish(customerEmailSchema),
2575
2709
  // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
2576
- sms_consent: z3.optional(z3.boolean())
2710
+ sms_consent: z4.optional(z4.boolean())
2577
2711
  }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
2578
2712
  var TRACKING_RANGES = ["24h", "7d", "30d"];
2579
2713
  var NAMED_RANGES = [
@@ -2600,118 +2734,6 @@ function phoneField(name, raw, country) {
2600
2734
  return { name, type: "phone", value: toE164(raw, country) };
2601
2735
  }
2602
2736
 
2603
- // ../tracking-core/src/lead-forms/lead-forms.gen.ts
2604
- var z4 = __toESM(require("zod/mini"));
2605
- var LEAD_FORM_REGISTRY_VERSION = 1;
2606
- var LEAD_FORM_KINDS = ["booking", "quote", "contact", "consult", "callback"];
2607
- var LEAD_FORM_ROLES = [
2608
- "given_name",
2609
- "family_name",
2610
- "phone",
2611
- "email",
2612
- "service",
2613
- "preferred_date",
2614
- "preferred_time",
2615
- "note",
2616
- "visit",
2617
- "intent",
2618
- "vehicle",
2619
- "drop_off",
2620
- "address",
2621
- "patient_type",
2622
- "matter",
2623
- "language",
2624
- "products",
2625
- "goal",
2626
- "business_type",
2627
- "lead_volume",
2628
- "attribution"
2629
- ];
2630
- var LEAD_FORM_PRIMITIVES = [
2631
- "string",
2632
- "text",
2633
- "enum",
2634
- "multi_enum",
2635
- "bool",
2636
- "date",
2637
- "time_window",
2638
- "phone",
2639
- "email",
2640
- "address",
2641
- "number"
2642
- ];
2643
- var leadFormPrimitiveSchemas = {
2644
- string: z4.string().check(z4.maxLength(120)),
2645
- text: z4.string().check(z4.maxLength(2e3)),
2646
- enum: z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/)),
2647
- multi_enum: z4.array(z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/))).check(z4.maxLength(10)),
2648
- bool: z4.boolean(),
2649
- date: z4.string().check(z4.regex(/^\d{4}-\d{2}-\d{2}$/)),
2650
- time_window: z4.strictObject({
2651
- start: z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/)),
2652
- end: z4.nullable(z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/))),
2653
- label: z4.optional(z4.string().check(z4.maxLength(60)))
2654
- }),
2655
- phone: z4.string().check(z4.regex(/^\+[1-9]\d{6,14}$/)),
2656
- email: z4.string().check(z4.maxLength(320), z4.regex(/^[^\s@]+@[^\s@]+$/)),
2657
- address: z4.strictObject({
2658
- line1: z4.string().check(z4.maxLength(120)),
2659
- line2: z4.optional(z4.string().check(z4.maxLength(120))),
2660
- city: z4.optional(z4.string().check(z4.maxLength(120))),
2661
- region: z4.optional(z4.string().check(z4.maxLength(120))),
2662
- postal_code: z4.optional(z4.string().check(z4.maxLength(120))),
2663
- country: z4.optional(z4.string().check(z4.maxLength(120)))
2664
- }),
2665
- number: z4.number()
2666
- };
2667
- var LEAD_FORM_ROLE_SPECS = {
2668
- given_name: { primitive: "string", smsLabel: "", contactIdentity: true },
2669
- family_name: { primitive: "string", smsLabel: "", contactIdentity: true },
2670
- phone: { primitive: "phone", smsLabel: "", contactIdentity: true },
2671
- email: { primitive: "email", smsLabel: "", contactIdentity: true },
2672
- service: { primitive: "enum", smsLabel: "Service" },
2673
- preferred_date: { primitive: "date", smsLabel: "Date" },
2674
- preferred_time: { primitive: "time_window", smsLabel: "Time" },
2675
- note: { primitive: "text", smsLabel: "Note" },
2676
- visit: {
2677
- primitive: "enum",
2678
- smsLabel: "Visit",
2679
- options: [
2680
- { key: "in-shop", label: "In shop" },
2681
- { key: "in-home", label: "In home" },
2682
- { key: "remote", label: "Remote" },
2683
- { key: "on-site", label: "On site" }
2684
- ]
2685
- },
2686
- intent: {
2687
- primitive: "enum",
2688
- smsLabel: "Wants",
2689
- options: [
2690
- { key: "book", label: "Book" },
2691
- { key: "quote", label: "Quote" }
2692
- ]
2693
- },
2694
- vehicle: { primitive: "string", smsLabel: "Vehicle" },
2695
- drop_off: {
2696
- primitive: "enum",
2697
- smsLabel: "Drop-off",
2698
- options: [
2699
- { key: "wait-for-it", label: "Waiting" },
2700
- { key: "drop-off", label: "Dropping off" }
2701
- ]
2702
- },
2703
- address: { primitive: "address", smsLabel: "Address" },
2704
- patient_type: { primitive: "enum", smsLabel: "Patient" },
2705
- matter: { primitive: "enum", smsLabel: "Matter" },
2706
- language: { primitive: "enum", smsLabel: "Language" },
2707
- products: { primitive: "multi_enum", smsLabel: "Products" },
2708
- goal: { primitive: "enum", smsLabel: "Goal" },
2709
- business_type: { primitive: "enum", smsLabel: "Business" },
2710
- lead_volume: { primitive: "enum", smsLabel: "Lead volume" },
2711
- add_on: { primitive: "bool", smsLabel: "" },
2712
- attribution: { primitive: "enum", smsLabel: "", uninteresting: true }
2713
- };
2714
-
2715
2737
  // src/index.ts
2716
2738
  var import_client2 = require("@aranova/tracking-react/client");
2717
2739
  var import_client3 = require("@aranova/tracking-react/client");