@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.mjs CHANGED
@@ -1324,6 +1324,10 @@ var TrackingConfigRuntime = class {
1324
1324
  integrations() {
1325
1325
  return this.current?.integrations ?? null;
1326
1326
  }
1327
+ /** The lead-form contracts, from the cached object like `integrations()`. */
1328
+ leadForms() {
1329
+ return this.current?.lead_forms ?? null;
1330
+ }
1327
1331
  async revalidateNow() {
1328
1332
  try {
1329
1333
  const headers = {};
@@ -1706,6 +1710,118 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
1706
1710
  var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
1707
1711
  var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
1708
1712
 
1713
+ // ../tracking-core/src/lead-forms/lead-forms.gen.ts
1714
+ import * as z2 from "zod/mini";
1715
+ var LEAD_FORM_REGISTRY_VERSION = 2;
1716
+ var LEAD_FORM_KINDS = ["booking", "quote", "contact", "consult", "callback"];
1717
+ var LEAD_FORM_ROLES = [
1718
+ "given_name",
1719
+ "family_name",
1720
+ "phone",
1721
+ "email",
1722
+ "service",
1723
+ "preferred_date",
1724
+ "preferred_time",
1725
+ "note",
1726
+ "visit",
1727
+ "intent",
1728
+ "vehicle",
1729
+ "drop_off",
1730
+ "address",
1731
+ "patient_type",
1732
+ "matter",
1733
+ "language",
1734
+ "products",
1735
+ "goal",
1736
+ "business_type",
1737
+ "lead_volume",
1738
+ "attribution"
1739
+ ];
1740
+ var LEAD_FORM_PRIMITIVES = [
1741
+ "string",
1742
+ "text",
1743
+ "enum",
1744
+ "multi_enum",
1745
+ "bool",
1746
+ "date",
1747
+ "time_window",
1748
+ "phone",
1749
+ "email",
1750
+ "address",
1751
+ "number"
1752
+ ];
1753
+ var leadFormPrimitiveSchemas = /* @__PURE__ */ (() => ({
1754
+ string: z2.string().check(z2.maxLength(120)),
1755
+ text: z2.string().check(z2.maxLength(2e3)),
1756
+ enum: z2.string().check(z2.regex(/^[a-z0-9-]{1,48}$/)),
1757
+ multi_enum: z2.array(z2.string().check(z2.regex(/^[a-z0-9-]{1,48}$/))).check(z2.maxLength(10)),
1758
+ bool: z2.boolean(),
1759
+ date: z2.string().check(z2.regex(/^\d{4}-\d{2}-\d{2}$/)),
1760
+ time_window: z2.strictObject({
1761
+ start: z2.string().check(z2.regex(/^([01]\d|2[0-3]):[0-5]\d$/)),
1762
+ end: z2.nullable(z2.string().check(z2.regex(/^([01]\d|2[0-3]):[0-5]\d$/))),
1763
+ label: z2.optional(z2.string().check(z2.maxLength(60)))
1764
+ }),
1765
+ phone: z2.string().check(z2.regex(/^\+[1-9]\d{6,14}$/)),
1766
+ email: z2.string().check(z2.maxLength(320), z2.regex(/^[^\s@]+@[^\s@]+$/)),
1767
+ address: z2.strictObject({
1768
+ line1: z2.string().check(z2.maxLength(120)),
1769
+ line2: z2.optional(z2.string().check(z2.maxLength(120))),
1770
+ city: z2.optional(z2.string().check(z2.maxLength(120))),
1771
+ region: z2.optional(z2.string().check(z2.maxLength(120))),
1772
+ postal_code: z2.optional(z2.string().check(z2.maxLength(120))),
1773
+ country: z2.optional(z2.string().check(z2.maxLength(120)))
1774
+ }),
1775
+ number: z2.number()
1776
+ }))();
1777
+ var LEAD_FORM_ROLE_SPECS = {
1778
+ given_name: { primitive: "string", smsLabel: "", contactIdentity: true },
1779
+ family_name: { primitive: "string", smsLabel: "", contactIdentity: true },
1780
+ phone: { primitive: "phone", smsLabel: "", contactIdentity: true },
1781
+ email: { primitive: "email", smsLabel: "", contactIdentity: true },
1782
+ service: { primitive: "multi_enum", smsLabel: "Service" },
1783
+ preferred_date: { primitive: "date", smsLabel: "Date" },
1784
+ preferred_time: { primitive: "time_window", smsLabel: "Time" },
1785
+ note: { primitive: "text", smsLabel: "Note" },
1786
+ visit: {
1787
+ primitive: "enum",
1788
+ smsLabel: "Visit",
1789
+ options: [
1790
+ { key: "in-shop", label: "In shop" },
1791
+ { key: "in-home", label: "In home" },
1792
+ { key: "remote", label: "Remote" },
1793
+ { key: "on-site", label: "On site" }
1794
+ ]
1795
+ },
1796
+ intent: {
1797
+ primitive: "enum",
1798
+ smsLabel: "Wants",
1799
+ options: [
1800
+ { key: "book", label: "Book" },
1801
+ { key: "quote", label: "Quote" }
1802
+ ]
1803
+ },
1804
+ vehicle: { primitive: "string", smsLabel: "Vehicle" },
1805
+ drop_off: {
1806
+ primitive: "enum",
1807
+ smsLabel: "Drop-off",
1808
+ options: [
1809
+ { key: "wait-for-it", label: "Waiting" },
1810
+ { key: "drop-off", label: "Dropping off" }
1811
+ ]
1812
+ },
1813
+ address: { primitive: "address", smsLabel: "Address" },
1814
+ patient_type: { primitive: "enum", smsLabel: "Patient" },
1815
+ matter: { primitive: "enum", smsLabel: "Matter" },
1816
+ language: { primitive: "enum", smsLabel: "Language" },
1817
+ products: { primitive: "multi_enum", smsLabel: "Products" },
1818
+ goal: { primitive: "enum", smsLabel: "Goal" },
1819
+ business_type: { primitive: "enum", smsLabel: "Business" },
1820
+ lead_volume: { primitive: "enum", smsLabel: "Lead volume" },
1821
+ add_on: { primitive: "bool", smsLabel: "" },
1822
+ attribution: { primitive: "enum", smsLabel: "", uninteresting: true }
1823
+ };
1824
+
1709
1825
  // ../tracking-core/src/resources/http/errors.ts
1710
1826
  var AranovaApiError = class extends Error {
1711
1827
  constructor(message, options) {
@@ -1799,39 +1915,54 @@ function outcomeOf(body) {
1799
1915
  if (body.status === "pending") return { status: "pending", id: body.id, mode };
1800
1916
  return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
1801
1917
  }
1802
- function formSubmitPayload(input, formSubmit, labels) {
1803
- const vehicle = input.vehicle ? `${input.vehicle.year} ${input.vehicle.make} ${input.vehicle.model}` : "";
1804
- const field = (name, type, label, value) => ({
1805
- name,
1806
- type,
1807
- label,
1808
- value
1809
- });
1810
- const fields = [
1811
- field("first_name", "text", "First name", input.firstName),
1812
- field("last_name", "text", "Last name", input.lastName),
1918
+ var DROP_OFF_KEYS = {
1919
+ waitForIt: "wait-for-it",
1920
+ dropOff: "drop-off"
1921
+ };
1922
+ function formSubmitPayload(input, formSubmit, contractHash) {
1923
+ const field = (role, name, type, label, value) => ({ name, type, label, value, role });
1924
+ const text = (value) => value?.trim() || void 0;
1925
+ const { vehicle, dropOff } = input;
1926
+ const entries = [
1927
+ field("given_name", "first_name", "text", "First name", text(input.firstName)),
1928
+ field("family_name", "last_name", "text", "Last name", text(input.lastName)),
1813
1929
  // E.164 on the wire: it keys the customer and enhanced-conversion matching.
1814
- field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
1815
- field("email", "email", "Email", input.email ?? ""),
1930
+ field("phone", "phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
1931
+ field("email", "email", "email", "Email", text(input.email)),
1932
+ field("service", "service", "select", "Service", input.services),
1816
1933
  field(
1817
- "service",
1818
- "select",
1819
- "Service",
1820
- input.services.map((key) => labels.get(key) ?? key).join(", ")
1934
+ "vehicle",
1935
+ "vehicle",
1936
+ "text",
1937
+ "Vehicle",
1938
+ vehicle ? `${vehicle.year} ${vehicle.make} ${vehicle.model}` : void 0
1821
1939
  ),
1822
- field("vehicle", "text", "Vehicle", vehicle),
1823
1940
  field(
1824
- "start",
1825
- "text",
1826
- "Requested time",
1827
- `${input.startDate} ${String(input.startHour).padStart(2, "0")}:00`
1941
+ "drop_off",
1942
+ "drop_off",
1943
+ "select",
1944
+ "Drop-off",
1945
+ dropOff ? DROP_OFF_KEYS[dropOff] : void 0
1828
1946
  ),
1829
- field("note", "textarea", "Notes", input.notes ?? "")
1947
+ field("preferred_date", "preferred_date", "date", "Date", input.startDate),
1948
+ field("preferred_time", "preferred_time", "time", "Time", {
1949
+ start: `${String(input.startHour).padStart(2, "0")}:00`,
1950
+ end: null
1951
+ }),
1952
+ field("note", "note", "textarea", "Notes", text(input.notes))
1830
1953
  ];
1831
- const reported = new Set(fields.map((item) => item.name));
1954
+ const reported = new Set(entries.map((item) => item.name));
1955
+ const fields = entries.filter((item) => item.value !== void 0);
1832
1956
  const extra = (formSubmit.extraFields ?? []).filter((item) => !reported.has(item.name));
1833
1957
  return {
1834
- form: { id: formSubmit.formId, action: "/tracking/bookings", fields: [...fields, ...extra] },
1958
+ form: {
1959
+ id: formSubmit.formId,
1960
+ action: "/tracking/bookings",
1961
+ fields: [...fields, ...extra],
1962
+ kind: "booking",
1963
+ contract_version: LEAD_FORM_REGISTRY_VERSION,
1964
+ ...contractHash ? { contract_hash: contractHash } : {}
1965
+ },
1835
1966
  page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
1836
1967
  };
1837
1968
  }
@@ -1929,8 +2060,11 @@ function createSalesBookingsClient(config, firing) {
1929
2060
  }
1930
2061
  if (formSubmit && !submittedForms.has(attemptKey)) {
1931
2062
  submittedForms.add(attemptKey);
1932
- const labels = new Map(booking.options.map((option) => [option.key, option.label]));
1933
- formSubmit.tracking.trackEvent("form_submit", formSubmitPayload(input, formSubmit, labels));
2063
+ const contract = runtime?.leadForms()?.contracts.find((c) => c.form_kind === "booking");
2064
+ formSubmit.tracking.trackEvent(
2065
+ "form_submit",
2066
+ formSubmitPayload(input, formSubmit, contract?.contract_hash ?? null)
2067
+ );
1934
2068
  }
1935
2069
  const body = {
1936
2070
  idempotency_key: attemptKey,
@@ -2180,17 +2314,17 @@ function createSalesClient(config) {
2180
2314
  }
2181
2315
 
2182
2316
  // ../tracking-core/src/resources/sales/schema.ts
2183
- import * as z3 from "zod/mini";
2317
+ import * as z4 from "zod/mini";
2184
2318
 
2185
2319
  // ../tracking-core/src/resources/sales/generated/zod.gen.ts
2186
- import * as z2 from "zod/mini";
2187
- var zAutoLeapSaleFacts = z2.object({
2188
- first_order: z2.boolean(),
2189
- fleet_customer: z2.boolean(),
2190
- invoice_code: z2.string(),
2191
- invoice_id: z2.string()
2320
+ import * as z3 from "zod/mini";
2321
+ var zAutoLeapSaleFacts = z3.object({
2322
+ first_order: z3.boolean(),
2323
+ fleet_customer: z3.boolean(),
2324
+ invoice_code: z3.string(),
2325
+ invoice_id: z3.string()
2192
2326
  });
2193
- var zErrorCode = z2.enum([
2327
+ var zErrorCode = z3.enum([
2194
2328
  "missing_credentials",
2195
2329
  "invalid_api_key",
2196
2330
  "not_authenticated",
@@ -2234,37 +2368,37 @@ var zErrorCode = z2.enum([
2234
2368
  "rate_limited",
2235
2369
  "internal_error"
2236
2370
  ]);
2237
- var zSaleItemEntitySchema = z2.object({
2238
- category: z2.nullable(z2.string()),
2239
- external_item_id: z2.nullable(z2.string()),
2240
- id: z2.uuid(),
2241
- name: z2.nullable(z2.string()),
2242
- quantity: z2.string().check(z2.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
2243
- unit_cost_cents: z2.nullable(z2.int()),
2244
- unit_price_cents: z2.int()
2371
+ var zSaleItemEntitySchema = z3.object({
2372
+ category: z3.nullable(z3.string()),
2373
+ external_item_id: z3.nullable(z3.string()),
2374
+ id: z3.uuid(),
2375
+ name: z3.nullable(z3.string()),
2376
+ quantity: z3.string().check(z3.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
2377
+ unit_cost_cents: z3.nullable(z3.int()),
2378
+ unit_price_cents: z3.int()
2245
2379
  });
2246
- var zSaleItemInputSchema = z2.strictObject({
2247
- category: z2.nullish(z2.string()),
2248
- external_item_id: z2.nullish(z2.string()),
2249
- name: z2.nullish(z2.string()),
2250
- quantity: z2.string().check(z2.regex(/^\d+(\.\d{1,3})?$/)),
2251
- unit_cost_cents: z2.nullish(z2.int().check(z2.gte(0))),
2252
- unit_price_cents: z2.int().check(z2.gte(0))
2380
+ var zSaleItemInputSchema = z3.strictObject({
2381
+ category: z3.nullish(z3.string()),
2382
+ external_item_id: z3.nullish(z3.string()),
2383
+ name: z3.nullish(z3.string()),
2384
+ quantity: z3.string().check(z3.regex(/^\d+(\.\d{1,3})?$/)),
2385
+ unit_cost_cents: z3.nullish(z3.int().check(z3.gte(0))),
2386
+ unit_price_cents: z3.int().check(z3.gte(0))
2253
2387
  });
2254
- var zSaleServiceEntitySchema = z2.object({
2255
- amount_cents: z2.int(),
2256
- id: z2.uuid(),
2257
- mapped: z2.nullable(z2.boolean()),
2258
- service_id: z2.uuid(),
2259
- service_key: z2.string(),
2260
- service_label: z2.string()
2388
+ var zSaleServiceEntitySchema = z3.object({
2389
+ amount_cents: z3.int(),
2390
+ id: z3.uuid(),
2391
+ mapped: z3.nullable(z3.boolean()),
2392
+ service_id: z3.uuid(),
2393
+ service_key: z3.string(),
2394
+ service_label: z3.string()
2261
2395
  });
2262
- var zSaleServiceInputSchema = z2.strictObject({
2263
- amount_cents: z2.int().check(z2.gte(0)),
2264
- service: z2.string()
2396
+ var zSaleServiceInputSchema = z3.strictObject({
2397
+ amount_cents: z3.int().check(z3.gte(0)),
2398
+ service: z3.string()
2265
2399
  });
2266
- var zSaleSource = z2.enum(["api", "admin", "autoleap"]);
2267
- var zSmsAutomationState = z2.enum([
2400
+ var zSaleSource = z3.enum(["api", "admin", "autoleap"]);
2401
+ var zSmsAutomationState = z3.enum([
2268
2402
  "needs_check",
2269
2403
  "failed",
2270
2404
  "undelivered",
@@ -2276,7 +2410,7 @@ var zSmsAutomationState = z2.enum([
2276
2410
  "eligible",
2277
2411
  "not_applicable"
2278
2412
  ]);
2279
- var zSmsWithheldReason = z2.enum([
2413
+ var zSmsWithheldReason = z3.enum([
2280
2414
  "automation_disabled",
2281
2415
  "sms_disabled",
2282
2416
  "no_phone",
@@ -2304,75 +2438,75 @@ var zSmsWithheldReason = z2.enum([
2304
2438
  "invalid_phone",
2305
2439
  "recently_texted"
2306
2440
  ]);
2307
- var zSaleSmsStatusSchema = z2.object({
2308
- can_send_now: z2._default(z2.boolean(), false),
2309
- last_message_at: z2.nullable(z2.iso.datetime({ offset: true })),
2310
- reason_detail: z2.nullable(z2.string()),
2441
+ var zSaleSmsStatusSchema = z3.object({
2442
+ can_send_now: z3._default(z3.boolean(), false),
2443
+ last_message_at: z3.nullable(z3.iso.datetime({ offset: true })),
2444
+ reason_detail: z3.nullable(z3.string()),
2311
2445
  state: zSmsAutomationState,
2312
- suppressed_by_other_sale: z2._default(z2.boolean(), false),
2313
- withheld_reason: z2.nullable(zSmsWithheldReason)
2446
+ suppressed_by_other_sale: z3._default(z3.boolean(), false),
2447
+ withheld_reason: z3.nullable(zSmsWithheldReason)
2314
2448
  });
2315
- var zSupportedCurrency = z2.enum(["USD", "CAD"]);
2316
- var zTrackingEnvironment = z2.enum(["production", "development"]);
2317
- var zSaleCreateSchema = z2.strictObject({
2318
- amount_total_cents: z2.nullish(z2.int().check(z2.gte(0))),
2449
+ var zSupportedCurrency = z3.enum(["USD", "CAD"]);
2450
+ var zTrackingEnvironment = z3.enum(["production", "development"]);
2451
+ var zSaleCreateSchema = z3.strictObject({
2452
+ amount_total_cents: z3.nullish(z3.int().check(z3.gte(0))),
2319
2453
  currency: zSupportedCurrency,
2320
- customer_email: z2.nullish(z2.email().check(z2.maxLength(320))),
2321
- customer_name: z2.nullish(z2.string().check(z2.maxLength(200))),
2322
- customer_phone: z2.nullish(z2.string().check(z2.maxLength(64))),
2323
- description: z2.nullish(z2.string()),
2324
- environment: z2._default(z2.optional(zTrackingEnvironment), "production"),
2325
- external_id: z2.nullish(z2.string()),
2326
- items: z2.optional(z2.array(zSaleItemInputSchema)),
2327
- metadata: z2.nullish(z2.record(z2.string(), z2.unknown())),
2328
- occurred_at: z2.iso.datetime({ offset: true }),
2329
- service: z2.nullish(z2.string()),
2330
- services: z2.nullish(z2.array(zSaleServiceInputSchema)),
2331
- sms_consent: z2.nullish(z2.boolean())
2454
+ customer_email: z3.nullish(z3.email().check(z3.maxLength(320))),
2455
+ customer_name: z3.nullish(z3.string().check(z3.maxLength(200))),
2456
+ customer_phone: z3.nullish(z3.string().check(z3.maxLength(64))),
2457
+ description: z3.nullish(z3.string()),
2458
+ environment: z3._default(z3.optional(zTrackingEnvironment), "production"),
2459
+ external_id: z3.nullish(z3.string()),
2460
+ items: z3.optional(z3.array(zSaleItemInputSchema)),
2461
+ metadata: z3.nullish(z3.record(z3.string(), z3.unknown())),
2462
+ occurred_at: z3.iso.datetime({ offset: true }),
2463
+ service: z3.nullish(z3.string()),
2464
+ services: z3.nullish(z3.array(zSaleServiceInputSchema)),
2465
+ sms_consent: z3.nullish(z3.boolean())
2332
2466
  });
2333
- var zValidationError = z2.object({
2334
- ctx: z2.optional(z2.record(z2.string(), z2.unknown())),
2335
- input: z2.optional(z2.unknown()),
2336
- loc: z2.array(z2.union([z2.string(), z2.int()])),
2337
- msg: z2.string(),
2338
- type: z2.string()
2467
+ var zValidationError = z3.object({
2468
+ ctx: z3.optional(z3.record(z3.string(), z3.unknown())),
2469
+ input: z3.optional(z3.unknown()),
2470
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2471
+ msg: z3.string(),
2472
+ type: z3.string()
2339
2473
  });
2340
- var zHttpValidationError = z2.object({
2341
- detail: z2.optional(z2.array(zValidationError))
2474
+ var zHttpValidationError = z3.object({
2475
+ detail: z3.optional(z3.array(zValidationError))
2342
2476
  });
2343
- var zValidationErrorItem = z2.object({
2344
- loc: z2.array(z2.union([z2.string(), z2.int()])),
2345
- msg: z2.string(),
2346
- type: z2.string()
2477
+ var zValidationErrorItem = z3.object({
2478
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2479
+ msg: z3.string(),
2480
+ type: z3.string()
2347
2481
  });
2348
- var zApiErrorSchema = z2.object({
2482
+ var zApiErrorSchema = z3.object({
2349
2483
  code: zErrorCode,
2350
- context: z2._default(z2.nullish(z2.record(z2.string(), z2.unknown())), null),
2351
- detail: z2.string(),
2352
- errors: z2._default(z2.nullish(z2.array(zValidationErrorItem)), null),
2353
- request_id: z2._default(z2.nullish(z2.string()), null)
2484
+ context: z3._default(z3.nullish(z3.record(z3.string(), z3.unknown())), null),
2485
+ detail: z3.string(),
2486
+ errors: z3._default(z3.nullish(z3.array(zValidationErrorItem)), null),
2487
+ request_id: z3._default(z3.nullish(z3.string()), null)
2354
2488
  });
2355
- var zWritebackEmailSource = z2.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
2356
- var zWritebackEnrichmentStatus = z2.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
2357
- var zWritebackSaleUploadCounts = z2.object({
2358
- failed: z2._default(z2.int(), 0),
2359
- pending: z2._default(z2.int(), 0),
2360
- skipped: z2._default(z2.int(), 0),
2361
- submitted: z2._default(z2.int(), 0),
2362
- total: z2._default(z2.int(), 0),
2363
- uploaded: z2._default(z2.int(), 0)
2489
+ var zWritebackEmailSource = z3.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
2490
+ var zWritebackEnrichmentStatus = z3.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
2491
+ var zWritebackSaleUploadCounts = z3.object({
2492
+ failed: z3._default(z3.int(), 0),
2493
+ pending: z3._default(z3.int(), 0),
2494
+ skipped: z3._default(z3.int(), 0),
2495
+ submitted: z3._default(z3.int(), 0),
2496
+ total: z3._default(z3.int(), 0),
2497
+ uploaded: z3._default(z3.int(), 0)
2364
2498
  });
2365
- var zSaleWritebackStatusSchema = z2.object({
2366
- blocked_reason: z2.nullable(z2.string()),
2367
- can_dispatch: z2._default(z2.boolean(), false),
2368
- email_source: z2.nullable(zWritebackEmailSource),
2369
- enrichment_status: z2.nullable(zWritebackEnrichmentStatus),
2370
- gclid_attached: z2._default(z2.boolean(), false),
2371
- identifiers_sent: z2.nullable(z2.string()),
2372
- mapped_service_ids: z2.array(z2.uuid()),
2373
- matched_submit_count: z2.nullable(z2.int()),
2374
- needs_force: z2._default(z2.boolean(), false),
2375
- rollup: z2.enum([
2499
+ var zSaleWritebackStatusSchema = z3.object({
2500
+ blocked_reason: z3.nullable(z3.string()),
2501
+ can_dispatch: z3._default(z3.boolean(), false),
2502
+ email_source: z3.nullable(zWritebackEmailSource),
2503
+ enrichment_status: z3.nullable(zWritebackEnrichmentStatus),
2504
+ gclid_attached: z3._default(z3.boolean(), false),
2505
+ identifiers_sent: z3.nullable(z3.string()),
2506
+ mapped_service_ids: z3.array(z3.uuid()),
2507
+ matched_submit_count: z3.nullable(z3.int()),
2508
+ needs_force: z3._default(z3.boolean(), false),
2509
+ rollup: z3.enum([
2376
2510
  "failed",
2377
2511
  "skipped",
2378
2512
  "pending",
@@ -2382,39 +2516,39 @@ var zSaleWritebackStatusSchema = z2.object({
2382
2516
  "out_of_window",
2383
2517
  "blocked"
2384
2518
  ]),
2385
- stale: z2._default(z2.boolean(), false),
2386
- uncovered_service_ids: z2.array(z2.uuid()),
2519
+ stale: z3._default(z3.boolean(), false),
2520
+ uncovered_service_ids: z3.array(z3.uuid()),
2387
2521
  uploads: zWritebackSaleUploadCounts
2388
2522
  });
2389
- var zSaleEntitySchema = z2.object({
2390
- amount_total_cents: z2.int(),
2391
- business_id: z2.uuid(),
2392
- business_name: z2.nullable(z2.string()),
2393
- created_at: z2.iso.datetime({ offset: true }),
2394
- currency: z2.string(),
2395
- customer_email: z2.nullable(z2.string()),
2396
- customer_name: z2.nullable(z2.string()),
2397
- customer_name_placeholder_confirmed: z2._default(z2.boolean(), false),
2398
- customer_name_placeholder_confirmed_at: z2.nullable(z2.iso.datetime({ offset: true })),
2399
- customer_phone: z2.nullable(z2.string()),
2400
- description: z2.nullable(z2.string()),
2523
+ var zSaleEntitySchema = z3.object({
2524
+ amount_total_cents: z3.int(),
2525
+ business_id: z3.uuid(),
2526
+ business_name: z3.nullable(z3.string()),
2527
+ created_at: z3.iso.datetime({ offset: true }),
2528
+ currency: z3.string(),
2529
+ customer_email: z3.nullable(z3.string()),
2530
+ customer_name: z3.nullable(z3.string()),
2531
+ customer_name_placeholder_confirmed: z3._default(z3.boolean(), false),
2532
+ customer_name_placeholder_confirmed_at: z3.nullable(z3.iso.datetime({ offset: true })),
2533
+ customer_phone: z3.nullable(z3.string()),
2534
+ description: z3.nullable(z3.string()),
2401
2535
  environment: zTrackingEnvironment,
2402
- external_id: z2.nullable(z2.string()),
2403
- id: z2.uuid(),
2404
- items: z2.array(zSaleItemEntitySchema),
2405
- metadata: z2.nullable(z2.record(z2.string(), z2.unknown())),
2406
- occurred_at: z2.iso.datetime({ offset: true }),
2407
- service_id: z2.nullable(z2.uuid()),
2408
- service_key: z2.nullable(z2.string()),
2409
- service_label: z2.nullable(z2.string()),
2410
- services: z2.array(zSaleServiceEntitySchema),
2411
- sms_automation: z2.nullable(zSaleSmsStatusSchema),
2412
- sms_consent: z2._default(z2.boolean(), false),
2413
- sms_consent_granted_at: z2.nullable(z2.iso.datetime({ offset: true })),
2536
+ external_id: z3.nullable(z3.string()),
2537
+ id: z3.uuid(),
2538
+ items: z3.array(zSaleItemEntitySchema),
2539
+ metadata: z3.nullable(z3.record(z3.string(), z3.unknown())),
2540
+ occurred_at: z3.iso.datetime({ offset: true }),
2541
+ service_id: z3.nullable(z3.uuid()),
2542
+ service_key: z3.nullable(z3.string()),
2543
+ service_label: z3.nullable(z3.string()),
2544
+ services: z3.array(zSaleServiceEntitySchema),
2545
+ sms_automation: z3.nullable(zSaleSmsStatusSchema),
2546
+ sms_consent: z3._default(z3.boolean(), false),
2547
+ sms_consent_granted_at: z3.nullable(z3.iso.datetime({ offset: true })),
2414
2548
  source: zSaleSource,
2415
- source_facts: z2.nullable(zAutoLeapSaleFacts),
2416
- updated_at: z2.iso.datetime({ offset: true }),
2417
- writeback: z2.nullable(zSaleWritebackStatusSchema)
2549
+ source_facts: z3.nullable(zAutoLeapSaleFacts),
2550
+ updated_at: z3.iso.datetime({ offset: true }),
2551
+ writeback: z3.nullable(zSaleWritebackStatusSchema)
2418
2552
  });
2419
2553
 
2420
2554
  // ../tracking-core/src/resources/sales/schema.ts
@@ -2423,11 +2557,11 @@ var saleServiceSchema = zSaleServiceInputSchema;
2423
2557
  var currencySchema = zSupportedCurrency;
2424
2558
  var SUPPORTED_CURRENCIES = currencySchema.options;
2425
2559
  var SALE_SOURCES = zSaleSource.options;
2426
- var centsSchema = z3.int().check(z3.gte(0));
2427
- var metadataSchema = z3.record(z3.string(), z3.unknown());
2428
- var customerNameSchema = z3.string().check(z3.maxLength(200));
2429
- var customerPhoneSchema = z3.string().check(z3.maxLength(64));
2430
- var customerEmailSchema = z3.email().check(z3.maxLength(320));
2560
+ var centsSchema = z4.int().check(z4.gte(0));
2561
+ var metadataSchema = z4.record(z4.string(), z4.unknown());
2562
+ var customerNameSchema = z4.string().check(z4.maxLength(200));
2563
+ var customerPhoneSchema = z4.string().check(z4.maxLength(64));
2564
+ var customerEmailSchema = z4.email().check(z4.maxLength(320));
2431
2565
  function addIssue(ctx, path, message) {
2432
2566
  ctx.issues.push({ code: "custom", input: ctx.value, path, message });
2433
2567
  }
@@ -2461,24 +2595,24 @@ function refineServiceXor(val, ctx, { requireAmount }) {
2461
2595
  );
2462
2596
  }
2463
2597
  }
2464
- var saleCreateSchema = z3.extend(zSaleCreateSchema, { items: z3._default(z3.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
2465
- var saleUpdateSchema = z3.strictObject({
2466
- description: z3.nullish(z3.string()),
2467
- service: z3.nullish(z3.string()),
2468
- services: z3.nullish(z3.array(saleServiceSchema)),
2469
- currency: z3.optional(currencySchema),
2470
- amount_total_cents: z3.optional(centsSchema),
2471
- occurred_at: z3.optional(z3.iso.datetime()),
2472
- items: z3.optional(z3.array(saleItemSchema)),
2473
- metadata: z3.nullish(metadataSchema),
2474
- customer_name: z3.nullish(customerNameSchema),
2598
+ var saleCreateSchema = z4.extend(zSaleCreateSchema, { items: z4._default(z4.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
2599
+ var saleUpdateSchema = z4.strictObject({
2600
+ description: z4.nullish(z4.string()),
2601
+ service: z4.nullish(z4.string()),
2602
+ services: z4.nullish(z4.array(saleServiceSchema)),
2603
+ currency: z4.optional(currencySchema),
2604
+ amount_total_cents: z4.optional(centsSchema),
2605
+ occurred_at: z4.optional(z4.iso.datetime()),
2606
+ items: z4.optional(z4.array(saleItemSchema)),
2607
+ metadata: z4.nullish(metadataSchema),
2608
+ customer_name: z4.nullish(customerNameSchema),
2475
2609
  // Re-attest when changing a filler-looking name; the server clears the
2476
2610
  // prior attestation whenever `customer_name` changes.
2477
- customer_name_placeholder_confirmed: z3.optional(z3.boolean()),
2478
- customer_phone: z3.nullish(customerPhoneSchema),
2479
- customer_email: z3.nullish(customerEmailSchema),
2611
+ customer_name_placeholder_confirmed: z4.optional(z4.boolean()),
2612
+ customer_phone: z4.nullish(customerPhoneSchema),
2613
+ customer_email: z4.nullish(customerEmailSchema),
2480
2614
  // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
2481
- sms_consent: z3.optional(z3.boolean())
2615
+ sms_consent: z4.optional(z4.boolean())
2482
2616
  }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
2483
2617
  var TRACKING_RANGES = ["24h", "7d", "30d"];
2484
2618
  var NAMED_RANGES = [
@@ -2505,118 +2639,6 @@ function phoneField(name, raw, country) {
2505
2639
  return { name, type: "phone", value: toE164(raw, country) };
2506
2640
  }
2507
2641
 
2508
- // ../tracking-core/src/lead-forms/lead-forms.gen.ts
2509
- import * as z4 from "zod/mini";
2510
- var LEAD_FORM_REGISTRY_VERSION = 1;
2511
- var LEAD_FORM_KINDS = ["booking", "quote", "contact", "consult", "callback"];
2512
- var LEAD_FORM_ROLES = [
2513
- "given_name",
2514
- "family_name",
2515
- "phone",
2516
- "email",
2517
- "service",
2518
- "preferred_date",
2519
- "preferred_time",
2520
- "note",
2521
- "visit",
2522
- "intent",
2523
- "vehicle",
2524
- "drop_off",
2525
- "address",
2526
- "patient_type",
2527
- "matter",
2528
- "language",
2529
- "products",
2530
- "goal",
2531
- "business_type",
2532
- "lead_volume",
2533
- "attribution"
2534
- ];
2535
- var LEAD_FORM_PRIMITIVES = [
2536
- "string",
2537
- "text",
2538
- "enum",
2539
- "multi_enum",
2540
- "bool",
2541
- "date",
2542
- "time_window",
2543
- "phone",
2544
- "email",
2545
- "address",
2546
- "number"
2547
- ];
2548
- var leadFormPrimitiveSchemas = {
2549
- string: z4.string().check(z4.maxLength(120)),
2550
- text: z4.string().check(z4.maxLength(2e3)),
2551
- enum: z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/)),
2552
- multi_enum: z4.array(z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/))).check(z4.maxLength(10)),
2553
- bool: z4.boolean(),
2554
- date: z4.string().check(z4.regex(/^\d{4}-\d{2}-\d{2}$/)),
2555
- time_window: z4.strictObject({
2556
- start: z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/)),
2557
- end: z4.nullable(z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/))),
2558
- label: z4.optional(z4.string().check(z4.maxLength(60)))
2559
- }),
2560
- phone: z4.string().check(z4.regex(/^\+[1-9]\d{6,14}$/)),
2561
- email: z4.string().check(z4.maxLength(320), z4.regex(/^[^\s@]+@[^\s@]+$/)),
2562
- address: z4.strictObject({
2563
- line1: z4.string().check(z4.maxLength(120)),
2564
- line2: z4.optional(z4.string().check(z4.maxLength(120))),
2565
- city: z4.optional(z4.string().check(z4.maxLength(120))),
2566
- region: z4.optional(z4.string().check(z4.maxLength(120))),
2567
- postal_code: z4.optional(z4.string().check(z4.maxLength(120))),
2568
- country: z4.optional(z4.string().check(z4.maxLength(120)))
2569
- }),
2570
- number: z4.number()
2571
- };
2572
- var LEAD_FORM_ROLE_SPECS = {
2573
- given_name: { primitive: "string", smsLabel: "", contactIdentity: true },
2574
- family_name: { primitive: "string", smsLabel: "", contactIdentity: true },
2575
- phone: { primitive: "phone", smsLabel: "", contactIdentity: true },
2576
- email: { primitive: "email", smsLabel: "", contactIdentity: true },
2577
- service: { primitive: "enum", smsLabel: "Service" },
2578
- preferred_date: { primitive: "date", smsLabel: "Date" },
2579
- preferred_time: { primitive: "time_window", smsLabel: "Time" },
2580
- note: { primitive: "text", smsLabel: "Note" },
2581
- visit: {
2582
- primitive: "enum",
2583
- smsLabel: "Visit",
2584
- options: [
2585
- { key: "in-shop", label: "In shop" },
2586
- { key: "in-home", label: "In home" },
2587
- { key: "remote", label: "Remote" },
2588
- { key: "on-site", label: "On site" }
2589
- ]
2590
- },
2591
- intent: {
2592
- primitive: "enum",
2593
- smsLabel: "Wants",
2594
- options: [
2595
- { key: "book", label: "Book" },
2596
- { key: "quote", label: "Quote" }
2597
- ]
2598
- },
2599
- vehicle: { primitive: "string", smsLabel: "Vehicle" },
2600
- drop_off: {
2601
- primitive: "enum",
2602
- smsLabel: "Drop-off",
2603
- options: [
2604
- { key: "wait-for-it", label: "Waiting" },
2605
- { key: "drop-off", label: "Dropping off" }
2606
- ]
2607
- },
2608
- address: { primitive: "address", smsLabel: "Address" },
2609
- patient_type: { primitive: "enum", smsLabel: "Patient" },
2610
- matter: { primitive: "enum", smsLabel: "Matter" },
2611
- language: { primitive: "enum", smsLabel: "Language" },
2612
- products: { primitive: "multi_enum", smsLabel: "Products" },
2613
- goal: { primitive: "enum", smsLabel: "Goal" },
2614
- business_type: { primitive: "enum", smsLabel: "Business" },
2615
- lead_volume: { primitive: "enum", smsLabel: "Lead volume" },
2616
- add_on: { primitive: "bool", smsLabel: "" },
2617
- attribution: { primitive: "enum", smsLabel: "", uninteresting: true }
2618
- };
2619
-
2620
2642
  // src/index.ts
2621
2643
  import {
2622
2644
  PhoneField,