@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/client.mjs CHANGED
@@ -1077,9 +1077,64 @@ function parseConversionConfig(raw) {
1077
1077
  services,
1078
1078
  goals,
1079
1079
  linked_hostnames: Array.isArray(obj.linked_hostnames) ? obj.linked_hostnames.filter((h) => typeof h === "string" && h.length > 0) : [],
1080
- integrations: parseIntegrations(obj.integrations)
1080
+ integrations: parseIntegrations(obj.integrations),
1081
+ lead_forms: parseLeadForms(obj.lead_forms)
1081
1082
  };
1082
1083
  }
1084
+ function parseLeadForms(value) {
1085
+ if (!isRecord(value) || typeof value.registry_version !== "number") return null;
1086
+ return {
1087
+ registry_version: value.registry_version,
1088
+ contracts: records(value.contracts).flatMap(
1089
+ (c) => typeof c.form_kind === "string" && typeof c.contract_hash === "string" ? [
1090
+ {
1091
+ form_kind: c.form_kind,
1092
+ requires: records(c.requires).flatMap(
1093
+ (r) => typeof r.role === "string" ? [
1094
+ {
1095
+ role: r.role,
1096
+ required_when: parseCondition(r.required_when),
1097
+ waived: r.waived === true
1098
+ }
1099
+ ] : []
1100
+ ),
1101
+ requires_any: records(c.requires_any).map((g) => ({
1102
+ roles: strings(g.roles),
1103
+ waived: g.waived === true
1104
+ })),
1105
+ options: records(c.options).flatMap(
1106
+ (o) => typeof o.role === "string" ? [{ role: o.role, options: records(o.options).flatMap(parseContractOption) }] : []
1107
+ ),
1108
+ contract_hash: c.contract_hash
1109
+ }
1110
+ ] : []
1111
+ )
1112
+ };
1113
+ }
1114
+ function parseCondition(value) {
1115
+ if (!isRecord(value) || typeof value.role !== "string") return null;
1116
+ return { role: value.role, any_of: strings(value.any_of) };
1117
+ }
1118
+ function parseContractOption(value) {
1119
+ if (typeof value.key !== "string" || typeof value.label !== "string") return [];
1120
+ return [
1121
+ {
1122
+ key: value.key,
1123
+ label: value.label,
1124
+ is_non_answer: value.is_non_answer === true,
1125
+ deprecated: value.deprecated === true
1126
+ }
1127
+ ];
1128
+ }
1129
+ function isRecord(value) {
1130
+ return !!value && typeof value === "object" && !Array.isArray(value);
1131
+ }
1132
+ function records(value) {
1133
+ return Array.isArray(value) ? value.filter(isRecord) : [];
1134
+ }
1135
+ function strings(value) {
1136
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
1137
+ }
1083
1138
  var CACHE_PREFIX = "_aranova_cfg_";
1084
1139
  function cacheKey(url) {
1085
1140
  return `${CACHE_PREFIX}${url}`;
@@ -2660,6 +2715,7 @@ var jsonValueSchema = z7.lazy(
2660
2715
  z7.record(z7.string(), jsonValueSchema)
2661
2716
  ])
2662
2717
  ).register(z7.globalRegistry, { id: "JsonSerializableValue" });
2718
+ var contractName = z7.string().check(z7.regex(/^[a-z][a-z0-9_]{0,47}(:[a-z0-9_-]{1,48})?$/));
2663
2719
  var formSubmitMetadataSchema = z7.strictObject({
2664
2720
  form: z7.strictObject({
2665
2721
  id: z7.string(),
@@ -2670,9 +2726,24 @@ var formSubmitMetadataSchema = z7.strictObject({
2670
2726
  name: z7.string(),
2671
2727
  type: z7.string(),
2672
2728
  label: z7.nullable(z7.string()),
2673
- value: jsonValueSchema
2729
+ value: jsonValueSchema,
2730
+ role: z7.optional(z7.nullable(contractName))
2674
2731
  })
2675
2732
  )
2733
+ ),
2734
+ kind: z7.optional(z7.nullable(contractName)),
2735
+ contract_version: z7.optional(z7.nullable(z7.int().check(z7.gte(1)))),
2736
+ contract_hash: z7.optional(z7.nullable(z7.string().check(z7.maxLength(64)))),
2737
+ extra: z7.optional(
2738
+ z7.nullable(
2739
+ z7.array(
2740
+ z7.strictObject({
2741
+ key: z7.string().check(z7.maxLength(64)),
2742
+ label: z7.string().check(z7.maxLength(200)),
2743
+ value: jsonValueSchema
2744
+ })
2745
+ ).check(z7.maxLength(20))
2746
+ )
2676
2747
  )
2677
2748
  }),
2678
2749
  page: z7.strictObject({
@@ -3958,7 +4029,7 @@ function GoogleAdsTracking(props) {
3958
4029
  import { createContext as createContext2, useContext as useContext2, useEffect as useEffect5, useMemo as useMemo4 } from "react";
3959
4030
 
3960
4031
  // package.json
3961
- var version = "1.10.0";
4032
+ var version = "1.12.0";
3962
4033
 
3963
4034
  // ../tracking-core/src/phone-react.tsx
3964
4035
  import {