@aranova/tracking-react 1.11.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
@@ -915,9 +915,58 @@ function parseConversionConfig(raw) {
915
915
  };
916
916
  }
917
917
  function parseLeadForms(value) {
918
- if (!value || typeof value !== "object") return null;
919
- const version = value.registry_version;
920
- return typeof version === "number" ? { registry_version: version } : null;
918
+ if (!isRecord(value) || typeof value.registry_version !== "number") return null;
919
+ return {
920
+ registry_version: value.registry_version,
921
+ contracts: records(value.contracts).flatMap(
922
+ (c) => typeof c.form_kind === "string" && typeof c.contract_hash === "string" ? [
923
+ {
924
+ form_kind: c.form_kind,
925
+ requires: records(c.requires).flatMap(
926
+ (r) => typeof r.role === "string" ? [
927
+ {
928
+ role: r.role,
929
+ required_when: parseCondition(r.required_when),
930
+ waived: r.waived === true
931
+ }
932
+ ] : []
933
+ ),
934
+ requires_any: records(c.requires_any).map((g) => ({
935
+ roles: strings(g.roles),
936
+ waived: g.waived === true
937
+ })),
938
+ options: records(c.options).flatMap(
939
+ (o) => typeof o.role === "string" ? [{ role: o.role, options: records(o.options).flatMap(parseContractOption) }] : []
940
+ ),
941
+ contract_hash: c.contract_hash
942
+ }
943
+ ] : []
944
+ )
945
+ };
946
+ }
947
+ function parseCondition(value) {
948
+ if (!isRecord(value) || typeof value.role !== "string") return null;
949
+ return { role: value.role, any_of: strings(value.any_of) };
950
+ }
951
+ function parseContractOption(value) {
952
+ if (typeof value.key !== "string" || typeof value.label !== "string") return [];
953
+ return [
954
+ {
955
+ key: value.key,
956
+ label: value.label,
957
+ is_non_answer: value.is_non_answer === true,
958
+ deprecated: value.deprecated === true
959
+ }
960
+ ];
961
+ }
962
+ function isRecord(value) {
963
+ return !!value && typeof value === "object" && !Array.isArray(value);
964
+ }
965
+ function records(value) {
966
+ return Array.isArray(value) ? value.filter(isRecord) : [];
967
+ }
968
+ function strings(value) {
969
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
921
970
  }
922
971
  var CACHE_PREFIX = "_aranova_cfg_";
923
972
  function cacheKey(url) {
@@ -1370,6 +1419,10 @@ var TrackingConfigRuntime = class {
1370
1419
  integrations() {
1371
1420
  return this.current?.integrations ?? null;
1372
1421
  }
1422
+ /** The lead-form contracts, from the cached object like `integrations()`. */
1423
+ leadForms() {
1424
+ return this.current?.lead_forms ?? null;
1425
+ }
1373
1426
  async revalidateNow() {
1374
1427
  try {
1375
1428
  const headers = {};
@@ -1752,6 +1805,118 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
1752
1805
  var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
1753
1806
  var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
1754
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
+
1755
1920
  // ../tracking-core/src/resources/http/errors.ts
1756
1921
  var AranovaApiError = class extends Error {
1757
1922
  constructor(message, options) {
@@ -1845,39 +2010,54 @@ function outcomeOf(body) {
1845
2010
  if (body.status === "pending") return { status: "pending", id: body.id, mode };
1846
2011
  return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
1847
2012
  }
1848
- function formSubmitPayload(input, formSubmit, labels) {
1849
- const vehicle = input.vehicle ? `${input.vehicle.year} ${input.vehicle.make} ${input.vehicle.model}` : "";
1850
- const field = (name, type, label, value) => ({
1851
- name,
1852
- type,
1853
- label,
1854
- value
1855
- });
1856
- const fields = [
1857
- field("first_name", "text", "First name", input.firstName),
1858
- 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)),
1859
2024
  // E.164 on the wire: it keys the customer and enhanced-conversion matching.
1860
- field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
1861
- 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),
1862
2028
  field(
1863
- "service",
1864
- "select",
1865
- "Service",
1866
- 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
1867
2034
  ),
1868
- field("vehicle", "text", "Vehicle", vehicle),
1869
2035
  field(
1870
- "start",
1871
- "text",
1872
- "Requested time",
1873
- `${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
1874
2041
  ),
1875
- 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))
1876
2048
  ];
1877
- 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);
1878
2051
  const extra = (formSubmit.extraFields ?? []).filter((item) => !reported.has(item.name));
1879
2052
  return {
1880
- 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
+ },
1881
2061
  page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
1882
2062
  };
1883
2063
  }
@@ -1975,8 +2155,11 @@ function createSalesBookingsClient(config, firing) {
1975
2155
  }
1976
2156
  if (formSubmit && !submittedForms.has(attemptKey)) {
1977
2157
  submittedForms.add(attemptKey);
1978
- const labels = new Map(booking.options.map((option) => [option.key, option.label]));
1979
- 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
+ );
1980
2163
  }
1981
2164
  const body = {
1982
2165
  idempotency_key: attemptKey,
@@ -2226,17 +2409,17 @@ function createSalesClient(config) {
2226
2409
  }
2227
2410
 
2228
2411
  // ../tracking-core/src/resources/sales/schema.ts
2229
- var z3 = __toESM(require("zod/mini"));
2412
+ var z4 = __toESM(require("zod/mini"));
2230
2413
 
2231
2414
  // ../tracking-core/src/resources/sales/generated/zod.gen.ts
2232
- var z2 = __toESM(require("zod/mini"));
2233
- var zAutoLeapSaleFacts = z2.object({
2234
- first_order: z2.boolean(),
2235
- fleet_customer: z2.boolean(),
2236
- invoice_code: z2.string(),
2237
- 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()
2238
2421
  });
2239
- var zErrorCode = z2.enum([
2422
+ var zErrorCode = z3.enum([
2240
2423
  "missing_credentials",
2241
2424
  "invalid_api_key",
2242
2425
  "not_authenticated",
@@ -2280,37 +2463,37 @@ var zErrorCode = z2.enum([
2280
2463
  "rate_limited",
2281
2464
  "internal_error"
2282
2465
  ]);
2283
- var zSaleItemEntitySchema = z2.object({
2284
- category: z2.nullable(z2.string()),
2285
- external_item_id: z2.nullable(z2.string()),
2286
- id: z2.uuid(),
2287
- name: z2.nullable(z2.string()),
2288
- quantity: z2.string().check(z2.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
2289
- unit_cost_cents: z2.nullable(z2.int()),
2290
- 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()
2291
2474
  });
2292
- var zSaleItemInputSchema = z2.strictObject({
2293
- category: z2.nullish(z2.string()),
2294
- external_item_id: z2.nullish(z2.string()),
2295
- name: z2.nullish(z2.string()),
2296
- quantity: z2.string().check(z2.regex(/^\d+(\.\d{1,3})?$/)),
2297
- unit_cost_cents: z2.nullish(z2.int().check(z2.gte(0))),
2298
- 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))
2299
2482
  });
2300
- var zSaleServiceEntitySchema = z2.object({
2301
- amount_cents: z2.int(),
2302
- id: z2.uuid(),
2303
- mapped: z2.nullable(z2.boolean()),
2304
- service_id: z2.uuid(),
2305
- service_key: z2.string(),
2306
- 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()
2307
2490
  });
2308
- var zSaleServiceInputSchema = z2.strictObject({
2309
- amount_cents: z2.int().check(z2.gte(0)),
2310
- service: z2.string()
2491
+ var zSaleServiceInputSchema = z3.strictObject({
2492
+ amount_cents: z3.int().check(z3.gte(0)),
2493
+ service: z3.string()
2311
2494
  });
2312
- var zSaleSource = z2.enum(["api", "admin", "autoleap"]);
2313
- var zSmsAutomationState = z2.enum([
2495
+ var zSaleSource = z3.enum(["api", "admin", "autoleap"]);
2496
+ var zSmsAutomationState = z3.enum([
2314
2497
  "needs_check",
2315
2498
  "failed",
2316
2499
  "undelivered",
@@ -2322,7 +2505,7 @@ var zSmsAutomationState = z2.enum([
2322
2505
  "eligible",
2323
2506
  "not_applicable"
2324
2507
  ]);
2325
- var zSmsWithheldReason = z2.enum([
2508
+ var zSmsWithheldReason = z3.enum([
2326
2509
  "automation_disabled",
2327
2510
  "sms_disabled",
2328
2511
  "no_phone",
@@ -2350,75 +2533,75 @@ var zSmsWithheldReason = z2.enum([
2350
2533
  "invalid_phone",
2351
2534
  "recently_texted"
2352
2535
  ]);
2353
- var zSaleSmsStatusSchema = z2.object({
2354
- can_send_now: z2._default(z2.boolean(), false),
2355
- last_message_at: z2.nullable(z2.iso.datetime({ offset: true })),
2356
- 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()),
2357
2540
  state: zSmsAutomationState,
2358
- suppressed_by_other_sale: z2._default(z2.boolean(), false),
2359
- withheld_reason: z2.nullable(zSmsWithheldReason)
2541
+ suppressed_by_other_sale: z3._default(z3.boolean(), false),
2542
+ withheld_reason: z3.nullable(zSmsWithheldReason)
2360
2543
  });
2361
- var zSupportedCurrency = z2.enum(["USD", "CAD"]);
2362
- var zTrackingEnvironment = z2.enum(["production", "development"]);
2363
- var zSaleCreateSchema = z2.strictObject({
2364
- 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))),
2365
2548
  currency: zSupportedCurrency,
2366
- customer_email: z2.nullish(z2.email().check(z2.maxLength(320))),
2367
- customer_name: z2.nullish(z2.string().check(z2.maxLength(200))),
2368
- customer_phone: z2.nullish(z2.string().check(z2.maxLength(64))),
2369
- description: z2.nullish(z2.string()),
2370
- environment: z2._default(z2.optional(zTrackingEnvironment), "production"),
2371
- external_id: z2.nullish(z2.string()),
2372
- items: z2.optional(z2.array(zSaleItemInputSchema)),
2373
- metadata: z2.nullish(z2.record(z2.string(), z2.unknown())),
2374
- occurred_at: z2.iso.datetime({ offset: true }),
2375
- service: z2.nullish(z2.string()),
2376
- services: z2.nullish(z2.array(zSaleServiceInputSchema)),
2377
- 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())
2378
2561
  });
2379
- var zValidationError = z2.object({
2380
- ctx: z2.optional(z2.record(z2.string(), z2.unknown())),
2381
- input: z2.optional(z2.unknown()),
2382
- loc: z2.array(z2.union([z2.string(), z2.int()])),
2383
- msg: z2.string(),
2384
- 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()
2385
2568
  });
2386
- var zHttpValidationError = z2.object({
2387
- detail: z2.optional(z2.array(zValidationError))
2569
+ var zHttpValidationError = z3.object({
2570
+ detail: z3.optional(z3.array(zValidationError))
2388
2571
  });
2389
- var zValidationErrorItem = z2.object({
2390
- loc: z2.array(z2.union([z2.string(), z2.int()])),
2391
- msg: z2.string(),
2392
- 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()
2393
2576
  });
2394
- var zApiErrorSchema = z2.object({
2577
+ var zApiErrorSchema = z3.object({
2395
2578
  code: zErrorCode,
2396
- context: z2._default(z2.nullish(z2.record(z2.string(), z2.unknown())), null),
2397
- detail: z2.string(),
2398
- errors: z2._default(z2.nullish(z2.array(zValidationErrorItem)), null),
2399
- 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)
2400
2583
  });
2401
- var zWritebackEmailSource = z2.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
2402
- var zWritebackEnrichmentStatus = z2.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
2403
- var zWritebackSaleUploadCounts = z2.object({
2404
- failed: z2._default(z2.int(), 0),
2405
- pending: z2._default(z2.int(), 0),
2406
- skipped: z2._default(z2.int(), 0),
2407
- submitted: z2._default(z2.int(), 0),
2408
- total: z2._default(z2.int(), 0),
2409
- 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)
2410
2593
  });
2411
- var zSaleWritebackStatusSchema = z2.object({
2412
- blocked_reason: z2.nullable(z2.string()),
2413
- can_dispatch: z2._default(z2.boolean(), false),
2414
- email_source: z2.nullable(zWritebackEmailSource),
2415
- enrichment_status: z2.nullable(zWritebackEnrichmentStatus),
2416
- gclid_attached: z2._default(z2.boolean(), false),
2417
- identifiers_sent: z2.nullable(z2.string()),
2418
- mapped_service_ids: z2.array(z2.uuid()),
2419
- matched_submit_count: z2.nullable(z2.int()),
2420
- needs_force: z2._default(z2.boolean(), false),
2421
- 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([
2422
2605
  "failed",
2423
2606
  "skipped",
2424
2607
  "pending",
@@ -2428,39 +2611,39 @@ var zSaleWritebackStatusSchema = z2.object({
2428
2611
  "out_of_window",
2429
2612
  "blocked"
2430
2613
  ]),
2431
- stale: z2._default(z2.boolean(), false),
2432
- uncovered_service_ids: z2.array(z2.uuid()),
2614
+ stale: z3._default(z3.boolean(), false),
2615
+ uncovered_service_ids: z3.array(z3.uuid()),
2433
2616
  uploads: zWritebackSaleUploadCounts
2434
2617
  });
2435
- var zSaleEntitySchema = z2.object({
2436
- amount_total_cents: z2.int(),
2437
- business_id: z2.uuid(),
2438
- business_name: z2.nullable(z2.string()),
2439
- created_at: z2.iso.datetime({ offset: true }),
2440
- currency: z2.string(),
2441
- customer_email: z2.nullable(z2.string()),
2442
- customer_name: z2.nullable(z2.string()),
2443
- customer_name_placeholder_confirmed: z2._default(z2.boolean(), false),
2444
- customer_name_placeholder_confirmed_at: z2.nullable(z2.iso.datetime({ offset: true })),
2445
- customer_phone: z2.nullable(z2.string()),
2446
- 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()),
2447
2630
  environment: zTrackingEnvironment,
2448
- external_id: z2.nullable(z2.string()),
2449
- id: z2.uuid(),
2450
- items: z2.array(zSaleItemEntitySchema),
2451
- metadata: z2.nullable(z2.record(z2.string(), z2.unknown())),
2452
- occurred_at: z2.iso.datetime({ offset: true }),
2453
- service_id: z2.nullable(z2.uuid()),
2454
- service_key: z2.nullable(z2.string()),
2455
- service_label: z2.nullable(z2.string()),
2456
- services: z2.array(zSaleServiceEntitySchema),
2457
- sms_automation: z2.nullable(zSaleSmsStatusSchema),
2458
- sms_consent: z2._default(z2.boolean(), false),
2459
- 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 })),
2460
2643
  source: zSaleSource,
2461
- source_facts: z2.nullable(zAutoLeapSaleFacts),
2462
- updated_at: z2.iso.datetime({ offset: true }),
2463
- writeback: z2.nullable(zSaleWritebackStatusSchema)
2644
+ source_facts: z3.nullable(zAutoLeapSaleFacts),
2645
+ updated_at: z3.iso.datetime({ offset: true }),
2646
+ writeback: z3.nullable(zSaleWritebackStatusSchema)
2464
2647
  });
2465
2648
 
2466
2649
  // ../tracking-core/src/resources/sales/schema.ts
@@ -2469,11 +2652,11 @@ var saleServiceSchema = zSaleServiceInputSchema;
2469
2652
  var currencySchema = zSupportedCurrency;
2470
2653
  var SUPPORTED_CURRENCIES = currencySchema.options;
2471
2654
  var SALE_SOURCES = zSaleSource.options;
2472
- var centsSchema = z3.int().check(z3.gte(0));
2473
- var metadataSchema = z3.record(z3.string(), z3.unknown());
2474
- var customerNameSchema = z3.string().check(z3.maxLength(200));
2475
- var customerPhoneSchema = z3.string().check(z3.maxLength(64));
2476
- 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));
2477
2660
  function addIssue(ctx, path, message) {
2478
2661
  ctx.issues.push({ code: "custom", input: ctx.value, path, message });
2479
2662
  }
@@ -2507,24 +2690,24 @@ function refineServiceXor(val, ctx, { requireAmount }) {
2507
2690
  );
2508
2691
  }
2509
2692
  }
2510
- var saleCreateSchema = z3.extend(zSaleCreateSchema, { items: z3._default(z3.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
2511
- var saleUpdateSchema = z3.strictObject({
2512
- description: z3.nullish(z3.string()),
2513
- service: z3.nullish(z3.string()),
2514
- services: z3.nullish(z3.array(saleServiceSchema)),
2515
- currency: z3.optional(currencySchema),
2516
- amount_total_cents: z3.optional(centsSchema),
2517
- occurred_at: z3.optional(z3.iso.datetime()),
2518
- items: z3.optional(z3.array(saleItemSchema)),
2519
- metadata: z3.nullish(metadataSchema),
2520
- 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),
2521
2704
  // Re-attest when changing a filler-looking name; the server clears the
2522
2705
  // prior attestation whenever `customer_name` changes.
2523
- customer_name_placeholder_confirmed: z3.optional(z3.boolean()),
2524
- customer_phone: z3.nullish(customerPhoneSchema),
2525
- 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),
2526
2709
  // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
2527
- sms_consent: z3.optional(z3.boolean())
2710
+ sms_consent: z4.optional(z4.boolean())
2528
2711
  }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
2529
2712
  var TRACKING_RANGES = ["24h", "7d", "30d"];
2530
2713
  var NAMED_RANGES = [
@@ -2551,118 +2734,6 @@ function phoneField(name, raw, country) {
2551
2734
  return { name, type: "phone", value: toE164(raw, country) };
2552
2735
  }
2553
2736
 
2554
- // ../tracking-core/src/lead-forms/lead-forms.gen.ts
2555
- var z4 = __toESM(require("zod/mini"));
2556
- var LEAD_FORM_REGISTRY_VERSION = 1;
2557
- var LEAD_FORM_KINDS = ["booking", "quote", "contact", "consult", "callback"];
2558
- var LEAD_FORM_ROLES = [
2559
- "given_name",
2560
- "family_name",
2561
- "phone",
2562
- "email",
2563
- "service",
2564
- "preferred_date",
2565
- "preferred_time",
2566
- "note",
2567
- "visit",
2568
- "intent",
2569
- "vehicle",
2570
- "drop_off",
2571
- "address",
2572
- "patient_type",
2573
- "matter",
2574
- "language",
2575
- "products",
2576
- "goal",
2577
- "business_type",
2578
- "lead_volume",
2579
- "attribution"
2580
- ];
2581
- var LEAD_FORM_PRIMITIVES = [
2582
- "string",
2583
- "text",
2584
- "enum",
2585
- "multi_enum",
2586
- "bool",
2587
- "date",
2588
- "time_window",
2589
- "phone",
2590
- "email",
2591
- "address",
2592
- "number"
2593
- ];
2594
- var leadFormPrimitiveSchemas = {
2595
- string: z4.string().check(z4.maxLength(120)),
2596
- text: z4.string().check(z4.maxLength(2e3)),
2597
- enum: z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/)),
2598
- multi_enum: z4.array(z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/))).check(z4.maxLength(10)),
2599
- bool: z4.boolean(),
2600
- date: z4.string().check(z4.regex(/^\d{4}-\d{2}-\d{2}$/)),
2601
- time_window: z4.strictObject({
2602
- start: z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/)),
2603
- end: z4.nullable(z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/))),
2604
- label: z4.optional(z4.string().check(z4.maxLength(60)))
2605
- }),
2606
- phone: z4.string().check(z4.regex(/^\+[1-9]\d{6,14}$/)),
2607
- email: z4.string().check(z4.maxLength(320), z4.regex(/^[^\s@]+@[^\s@]+$/)),
2608
- address: z4.strictObject({
2609
- line1: z4.string().check(z4.maxLength(120)),
2610
- line2: z4.optional(z4.string().check(z4.maxLength(120))),
2611
- city: z4.optional(z4.string().check(z4.maxLength(120))),
2612
- region: z4.optional(z4.string().check(z4.maxLength(120))),
2613
- postal_code: z4.optional(z4.string().check(z4.maxLength(120))),
2614
- country: z4.optional(z4.string().check(z4.maxLength(120)))
2615
- }),
2616
- number: z4.number()
2617
- };
2618
- var LEAD_FORM_ROLE_SPECS = {
2619
- given_name: { primitive: "string", smsLabel: "", contactIdentity: true },
2620
- family_name: { primitive: "string", smsLabel: "", contactIdentity: true },
2621
- phone: { primitive: "phone", smsLabel: "", contactIdentity: true },
2622
- email: { primitive: "email", smsLabel: "", contactIdentity: true },
2623
- service: { primitive: "enum", smsLabel: "Service" },
2624
- preferred_date: { primitive: "date", smsLabel: "Date" },
2625
- preferred_time: { primitive: "time_window", smsLabel: "Time" },
2626
- note: { primitive: "text", smsLabel: "Note" },
2627
- visit: {
2628
- primitive: "enum",
2629
- smsLabel: "Visit",
2630
- options: [
2631
- { key: "in-shop", label: "In shop" },
2632
- { key: "in-home", label: "In home" },
2633
- { key: "remote", label: "Remote" },
2634
- { key: "on-site", label: "On site" }
2635
- ]
2636
- },
2637
- intent: {
2638
- primitive: "enum",
2639
- smsLabel: "Wants",
2640
- options: [
2641
- { key: "book", label: "Book" },
2642
- { key: "quote", label: "Quote" }
2643
- ]
2644
- },
2645
- vehicle: { primitive: "string", smsLabel: "Vehicle" },
2646
- drop_off: {
2647
- primitive: "enum",
2648
- smsLabel: "Drop-off",
2649
- options: [
2650
- { key: "wait-for-it", label: "Waiting" },
2651
- { key: "drop-off", label: "Dropping off" }
2652
- ]
2653
- },
2654
- address: { primitive: "address", smsLabel: "Address" },
2655
- patient_type: { primitive: "enum", smsLabel: "Patient" },
2656
- matter: { primitive: "enum", smsLabel: "Matter" },
2657
- language: { primitive: "enum", smsLabel: "Language" },
2658
- products: { primitive: "multi_enum", smsLabel: "Products" },
2659
- goal: { primitive: "enum", smsLabel: "Goal" },
2660
- business_type: { primitive: "enum", smsLabel: "Business" },
2661
- lead_volume: { primitive: "enum", smsLabel: "Lead volume" },
2662
- add_on: { primitive: "bool", smsLabel: "" },
2663
- attribution: { primitive: "enum", smsLabel: "", uninteresting: true }
2664
- };
2665
-
2666
2737
  // src/index.ts
2667
2738
  var import_client2 = require("@aranova/tracking-react/client");
2668
2739
  var import_client3 = require("@aranova/tracking-react/client");