@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.
@@ -1,4 +1,4 @@
1
- import { a as FormSubmitMetadata } from './form-submit-BLb28aCk.mjs';
1
+ import { a as FormSubmitMetadata } from './form-submit-CX-CxJjQ.mjs';
2
2
 
3
3
  interface ServiceFiring {
4
4
  send_to: string;
@@ -45,6 +45,46 @@ interface ConversionConfig {
45
45
  linked_hostnames?: string[];
46
46
  /** Third-party integrations the site renders UI for; a missing provider means none. */
47
47
  integrations?: ConversionIntegrations;
48
+ /** The lead-form contract (ADR-0024); null from an API that predates it. */
49
+ lead_forms?: LeadFormsConfig | null;
50
+ }
51
+ interface LeadFormsConfig {
52
+ /** The registry version the object was published under. */
53
+ registry_version: number;
54
+ /** One per form kind a bound consumer needs something from; an absent kind needs nothing. */
55
+ contracts: LeadFormContract[];
56
+ }
57
+ /** What one kind of form must collect for this business, derived server-side. */
58
+ interface LeadFormContract {
59
+ form_kind: string;
60
+ requires: LeadFormRequirement[];
61
+ /** Each group is satisfied by any one of its roles. */
62
+ requires_any: Array<{
63
+ roles: string[];
64
+ waived: boolean;
65
+ }>;
66
+ options: Array<{
67
+ role: string;
68
+ options: LeadFormContractOption[];
69
+ }>;
70
+ /** Echo on `form_submit` as `form.contract_hash`. */
71
+ contract_hash: string;
72
+ }
73
+ interface LeadFormRequirement {
74
+ role: string;
75
+ /** Required only when `role` holds one of `any_of`; never nested. */
76
+ required_when: {
77
+ role: string;
78
+ any_of: string[];
79
+ } | null;
80
+ waived: boolean;
81
+ }
82
+ interface LeadFormContractOption {
83
+ key: string;
84
+ label: string;
85
+ is_non_answer: boolean;
86
+ /** Dropped from the form; still accepted from a cached config. */
87
+ deprecated: boolean;
48
88
  }
49
89
  /** Bookable start hours on one weekday, shop wall time (8 = 08:00); both empty = closed. */
50
90
  interface BookingDayWindows {
@@ -1,4 +1,4 @@
1
- import { a as FormSubmitMetadata } from './form-submit-BLb28aCk.js';
1
+ import { a as FormSubmitMetadata } from './form-submit-CX-CxJjQ.js';
2
2
 
3
3
  interface ServiceFiring {
4
4
  send_to: string;
@@ -45,6 +45,46 @@ interface ConversionConfig {
45
45
  linked_hostnames?: string[];
46
46
  /** Third-party integrations the site renders UI for; a missing provider means none. */
47
47
  integrations?: ConversionIntegrations;
48
+ /** The lead-form contract (ADR-0024); null from an API that predates it. */
49
+ lead_forms?: LeadFormsConfig | null;
50
+ }
51
+ interface LeadFormsConfig {
52
+ /** The registry version the object was published under. */
53
+ registry_version: number;
54
+ /** One per form kind a bound consumer needs something from; an absent kind needs nothing. */
55
+ contracts: LeadFormContract[];
56
+ }
57
+ /** What one kind of form must collect for this business, derived server-side. */
58
+ interface LeadFormContract {
59
+ form_kind: string;
60
+ requires: LeadFormRequirement[];
61
+ /** Each group is satisfied by any one of its roles. */
62
+ requires_any: Array<{
63
+ roles: string[];
64
+ waived: boolean;
65
+ }>;
66
+ options: Array<{
67
+ role: string;
68
+ options: LeadFormContractOption[];
69
+ }>;
70
+ /** Echo on `form_submit` as `form.contract_hash`. */
71
+ contract_hash: string;
72
+ }
73
+ interface LeadFormRequirement {
74
+ role: string;
75
+ /** Required only when `role` holds one of `any_of`; never nested. */
76
+ required_when: {
77
+ role: string;
78
+ any_of: string[];
79
+ } | null;
80
+ waived: boolean;
81
+ }
82
+ interface LeadFormContractOption {
83
+ key: string;
84
+ label: string;
85
+ is_non_answer: boolean;
86
+ /** Dropped from the form; still accepted from a cached config. */
87
+ deprecated: boolean;
48
88
  }
49
89
  /** Bookable start hours on one weekday, shop wall time (8 = 08:00); both empty = closed. */
50
90
  interface BookingDayWindows {
package/dist/client.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent, AnchorHTMLAttributes } from 'react';
3
- import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, j as PhoneConfig, P as ParsedPhone, k as PhoneDisplayFormat } from './phone-utils-CM8eUPz8.mjs';
4
- import { T as TrackingConfigReference, C as ConversionConfig, i as BookingOutcome, g as BookingInput, a as BookingDetailsInput, c as BookingDetailsOutcome, S as SalesBookingsClient, f as BookingFormSubmit, j as BookingSimulation } from './bookings-CUes6H05.mjs';
5
- import { X as TriggerRegistryConfig, Z as TypedTrackingClient, a as BookingHandoffPrefill, b as BookingIntegration, B as BookableDay } from './ingest-typed-CfjE2F18.mjs';
3
+ import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, j as PhoneConfig, P as ParsedPhone, k as PhoneDisplayFormat } from './phone-utils-BNiSqeF7.mjs';
4
+ import { T as TrackingConfigReference, C as ConversionConfig, i as BookingOutcome, g as BookingInput, a as BookingDetailsInput, c as BookingDetailsOutcome, S as SalesBookingsClient, f as BookingFormSubmit, j as BookingSimulation } from './bookings-Lmi0o_PA.mjs';
5
+ import { X as TriggerRegistryConfig, Z as TypedTrackingClient, a as BookingHandoffPrefill, b as BookingIntegration, B as BookableDay } from './ingest-typed-PKFEuJ8E.mjs';
6
6
  import { CountryCode } from 'libphonenumber-js';
7
- import './form-submit-BLb28aCk.mjs';
7
+ import './form-submit-CX-CxJjQ.mjs';
8
8
  import 'zod/mini';
9
9
  import 'zod/v4/core';
10
10
 
package/dist/client.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent, AnchorHTMLAttributes } from 'react';
3
- import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, j as PhoneConfig, P as ParsedPhone, k as PhoneDisplayFormat } from './phone-utils-l8ey3Zdm.js';
4
- import { T as TrackingConfigReference, C as ConversionConfig, i as BookingOutcome, g as BookingInput, a as BookingDetailsInput, c as BookingDetailsOutcome, S as SalesBookingsClient, f as BookingFormSubmit, j as BookingSimulation } from './bookings-D5TT6D8w.js';
5
- import { X as TriggerRegistryConfig, Z as TypedTrackingClient, a as BookingHandoffPrefill, b as BookingIntegration, B as BookableDay } from './ingest-typed-CNeWyI0U.js';
3
+ import { G as GtagEnvironmentMap, M as MetaPixelEnvironmentMap, h as ConsentState, f as ConsentChoiceState, g as ConsentSource, T as TrackingParams, b as TrackingEnvironment, j as PhoneConfig, P as ParsedPhone, k as PhoneDisplayFormat } from './phone-utils-D12FW8tT.js';
4
+ import { T as TrackingConfigReference, C as ConversionConfig, i as BookingOutcome, g as BookingInput, a as BookingDetailsInput, c as BookingDetailsOutcome, S as SalesBookingsClient, f as BookingFormSubmit, j as BookingSimulation } from './bookings-v_ucn93l.js';
5
+ import { X as TriggerRegistryConfig, Z as TypedTrackingClient, a as BookingHandoffPrefill, b as BookingIntegration, B as BookableDay } from './ingest-typed-B9I1c7jr.js';
6
6
  import { CountryCode } from 'libphonenumber-js';
7
- import './form-submit-BLb28aCk.js';
7
+ import './form-submit-CX-CxJjQ.js';
8
8
  import 'zod/mini';
9
9
  import 'zod/v4/core';
10
10
 
package/dist/client.js CHANGED
@@ -1128,9 +1128,64 @@ function parseConversionConfig(raw) {
1128
1128
  services,
1129
1129
  goals,
1130
1130
  linked_hostnames: Array.isArray(obj.linked_hostnames) ? obj.linked_hostnames.filter((h) => typeof h === "string" && h.length > 0) : [],
1131
- integrations: parseIntegrations(obj.integrations)
1131
+ integrations: parseIntegrations(obj.integrations),
1132
+ lead_forms: parseLeadForms(obj.lead_forms)
1132
1133
  };
1133
1134
  }
1135
+ function parseLeadForms(value) {
1136
+ if (!isRecord(value) || typeof value.registry_version !== "number") return null;
1137
+ return {
1138
+ registry_version: value.registry_version,
1139
+ contracts: records(value.contracts).flatMap(
1140
+ (c) => typeof c.form_kind === "string" && typeof c.contract_hash === "string" ? [
1141
+ {
1142
+ form_kind: c.form_kind,
1143
+ requires: records(c.requires).flatMap(
1144
+ (r) => typeof r.role === "string" ? [
1145
+ {
1146
+ role: r.role,
1147
+ required_when: parseCondition(r.required_when),
1148
+ waived: r.waived === true
1149
+ }
1150
+ ] : []
1151
+ ),
1152
+ requires_any: records(c.requires_any).map((g) => ({
1153
+ roles: strings(g.roles),
1154
+ waived: g.waived === true
1155
+ })),
1156
+ options: records(c.options).flatMap(
1157
+ (o) => typeof o.role === "string" ? [{ role: o.role, options: records(o.options).flatMap(parseContractOption) }] : []
1158
+ ),
1159
+ contract_hash: c.contract_hash
1160
+ }
1161
+ ] : []
1162
+ )
1163
+ };
1164
+ }
1165
+ function parseCondition(value) {
1166
+ if (!isRecord(value) || typeof value.role !== "string") return null;
1167
+ return { role: value.role, any_of: strings(value.any_of) };
1168
+ }
1169
+ function parseContractOption(value) {
1170
+ if (typeof value.key !== "string" || typeof value.label !== "string") return [];
1171
+ return [
1172
+ {
1173
+ key: value.key,
1174
+ label: value.label,
1175
+ is_non_answer: value.is_non_answer === true,
1176
+ deprecated: value.deprecated === true
1177
+ }
1178
+ ];
1179
+ }
1180
+ function isRecord(value) {
1181
+ return !!value && typeof value === "object" && !Array.isArray(value);
1182
+ }
1183
+ function records(value) {
1184
+ return Array.isArray(value) ? value.filter(isRecord) : [];
1185
+ }
1186
+ function strings(value) {
1187
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
1188
+ }
1134
1189
  var CACHE_PREFIX = "_aranova_cfg_";
1135
1190
  function cacheKey(url) {
1136
1191
  return `${CACHE_PREFIX}${url}`;
@@ -2711,6 +2766,7 @@ var jsonValueSchema = z7.lazy(
2711
2766
  z7.record(z7.string(), jsonValueSchema)
2712
2767
  ])
2713
2768
  ).register(z7.globalRegistry, { id: "JsonSerializableValue" });
2769
+ var contractName = z7.string().check(z7.regex(/^[a-z][a-z0-9_]{0,47}(:[a-z0-9_-]{1,48})?$/));
2714
2770
  var formSubmitMetadataSchema = z7.strictObject({
2715
2771
  form: z7.strictObject({
2716
2772
  id: z7.string(),
@@ -2721,9 +2777,24 @@ var formSubmitMetadataSchema = z7.strictObject({
2721
2777
  name: z7.string(),
2722
2778
  type: z7.string(),
2723
2779
  label: z7.nullable(z7.string()),
2724
- value: jsonValueSchema
2780
+ value: jsonValueSchema,
2781
+ role: z7.optional(z7.nullable(contractName))
2725
2782
  })
2726
2783
  )
2784
+ ),
2785
+ kind: z7.optional(z7.nullable(contractName)),
2786
+ contract_version: z7.optional(z7.nullable(z7.int().check(z7.gte(1)))),
2787
+ contract_hash: z7.optional(z7.nullable(z7.string().check(z7.maxLength(64)))),
2788
+ extra: z7.optional(
2789
+ z7.nullable(
2790
+ z7.array(
2791
+ z7.strictObject({
2792
+ key: z7.string().check(z7.maxLength(64)),
2793
+ label: z7.string().check(z7.maxLength(200)),
2794
+ value: jsonValueSchema
2795
+ })
2796
+ ).check(z7.maxLength(20))
2797
+ )
2727
2798
  )
2728
2799
  }),
2729
2800
  page: z7.strictObject({
@@ -4009,7 +4080,7 @@ function GoogleAdsTracking(props) {
4009
4080
  var import_react6 = require("react");
4010
4081
 
4011
4082
  // package.json
4012
- var version = "1.10.0";
4083
+ var version = "1.12.0";
4013
4084
 
4014
4085
  // ../tracking-core/src/phone-react.tsx
4015
4086
  var import_react5 = require("react");