@aranova/tracking-react 1.10.0 → 1.12.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
@@ -815,9 +815,64 @@ function parseConversionConfig(raw) {
815
815
  services,
816
816
  goals,
817
817
  linked_hostnames: Array.isArray(obj.linked_hostnames) ? obj.linked_hostnames.filter((h) => typeof h === "string" && h.length > 0) : [],
818
- integrations: parseIntegrations(obj.integrations)
818
+ integrations: parseIntegrations(obj.integrations),
819
+ lead_forms: parseLeadForms(obj.lead_forms)
819
820
  };
820
821
  }
822
+ function parseLeadForms(value) {
823
+ if (!isRecord(value) || typeof value.registry_version !== "number") return null;
824
+ return {
825
+ registry_version: value.registry_version,
826
+ contracts: records(value.contracts).flatMap(
827
+ (c) => typeof c.form_kind === "string" && typeof c.contract_hash === "string" ? [
828
+ {
829
+ form_kind: c.form_kind,
830
+ requires: records(c.requires).flatMap(
831
+ (r) => typeof r.role === "string" ? [
832
+ {
833
+ role: r.role,
834
+ required_when: parseCondition(r.required_when),
835
+ waived: r.waived === true
836
+ }
837
+ ] : []
838
+ ),
839
+ requires_any: records(c.requires_any).map((g) => ({
840
+ roles: strings(g.roles),
841
+ waived: g.waived === true
842
+ })),
843
+ options: records(c.options).flatMap(
844
+ (o) => typeof o.role === "string" ? [{ role: o.role, options: records(o.options).flatMap(parseContractOption) }] : []
845
+ ),
846
+ contract_hash: c.contract_hash
847
+ }
848
+ ] : []
849
+ )
850
+ };
851
+ }
852
+ function parseCondition(value) {
853
+ if (!isRecord(value) || typeof value.role !== "string") return null;
854
+ return { role: value.role, any_of: strings(value.any_of) };
855
+ }
856
+ function parseContractOption(value) {
857
+ if (typeof value.key !== "string" || typeof value.label !== "string") return [];
858
+ return [
859
+ {
860
+ key: value.key,
861
+ label: value.label,
862
+ is_non_answer: value.is_non_answer === true,
863
+ deprecated: value.deprecated === true
864
+ }
865
+ ];
866
+ }
867
+ function isRecord(value) {
868
+ return !!value && typeof value === "object" && !Array.isArray(value);
869
+ }
870
+ function records(value) {
871
+ return Array.isArray(value) ? value.filter(isRecord) : [];
872
+ }
873
+ function strings(value) {
874
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
875
+ }
821
876
  var CACHE_PREFIX = "_aranova_cfg_";
822
877
  function cacheKey(url) {
823
878
  return `${CACHE_PREFIX}${url}`;
@@ -2450,6 +2505,118 @@ function phoneField(name, raw, country) {
2450
2505
  return { name, type: "phone", value: toE164(raw, country) };
2451
2506
  }
2452
2507
 
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
+
2453
2620
  // src/index.ts
2454
2621
  import {
2455
2622
  PhoneField,
@@ -2472,6 +2639,11 @@ export {
2472
2639
  DEFAULT_PHONE_COUNTRY,
2473
2640
  EVENT_SEMANTICS,
2474
2641
  GoogleAdsTracking,
2642
+ LEAD_FORM_KINDS,
2643
+ LEAD_FORM_PRIMITIVES,
2644
+ LEAD_FORM_REGISTRY_VERSION,
2645
+ LEAD_FORM_ROLES,
2646
+ LEAD_FORM_ROLE_SPECS,
2475
2647
  NAMED_RANGES,
2476
2648
  PhoneField,
2477
2649
  SALE_SOURCES,
@@ -2500,6 +2672,7 @@ export {
2500
2672
  getEventSemantics,
2501
2673
  getTrackingConfigRuntime,
2502
2674
  groupBookingOptions,
2675
+ leadFormPrimitiveSchemas,
2503
2676
  newBookingAttemptKey,
2504
2677
  onConsentChange,
2505
2678
  optIn,