@aranova/tracking-react 1.11.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.
@@ -51,6 +51,40 @@ interface ConversionConfig {
51
51
  interface LeadFormsConfig {
52
52
  /** The registry version the object was published under. */
53
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;
54
88
  }
55
89
  /** Bookable start hours on one weekday, shop wall time (8 = 08:00); both empty = closed. */
56
90
  interface BookingDayWindows {
@@ -51,6 +51,40 @@ interface ConversionConfig {
51
51
  interface LeadFormsConfig {
52
52
  /** The registry version the object was published under. */
53
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;
54
88
  }
55
89
  /** Bookable start hours on one weekday, shop wall time (8 = 08:00); both empty = closed. */
56
90
  interface BookingDayWindows {
package/dist/client.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent, AnchorHTMLAttributes } from 'react';
3
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-BnXZGgwr.mjs';
5
- import { X as TriggerRegistryConfig, Z as TypedTrackingClient, a as BookingHandoffPrefill, b as BookingIntegration, B as BookableDay } from './ingest-typed-TI6KqVzL.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
7
  import './form-submit-CX-CxJjQ.mjs';
8
8
  import 'zod/mini';
package/dist/client.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ChangeEvent, FocusEvent, AnchorHTMLAttributes } from 'react';
3
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-vM_aCNOS.js';
5
- import { X as TriggerRegistryConfig, Z as TypedTrackingClient, a as BookingHandoffPrefill, b as BookingIntegration, B as BookableDay } from './ingest-typed-BS9agXM5.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
7
  import './form-submit-CX-CxJjQ.js';
8
8
  import 'zod/mini';
package/dist/client.js CHANGED
@@ -1133,9 +1133,58 @@ function parseConversionConfig(raw) {
1133
1133
  };
1134
1134
  }
1135
1135
  function parseLeadForms(value) {
1136
- if (!value || typeof value !== "object") return null;
1137
- const version2 = value.registry_version;
1138
- return typeof version2 === "number" ? { registry_version: version2 } : null;
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") : [];
1139
1188
  }
1140
1189
  var CACHE_PREFIX = "_aranova_cfg_";
1141
1190
  function cacheKey(url) {
@@ -4031,7 +4080,7 @@ function GoogleAdsTracking(props) {
4031
4080
  var import_react6 = require("react");
4032
4081
 
4033
4082
  // package.json
4034
- var version = "1.11.0";
4083
+ var version = "1.12.0";
4035
4084
 
4036
4085
  // ../tracking-core/src/phone-react.tsx
4037
4086
  var import_react5 = require("react");