@aranova/tracking-react 1.12.0 → 1.14.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/README.md +31 -3
- package/dist/{bookings-v_ucn93l.d.ts → bookings-Bw2ImtPd.d.ts} +3 -1
- package/dist/{bookings-Lmi0o_PA.d.mts → bookings-CDGNZUaH.d.mts} +3 -1
- package/dist/client.d.mts +5 -4
- package/dist/client.d.ts +5 -4
- package/dist/client.js +369 -40
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +367 -39
- package/dist/client.mjs.map +1 -1
- package/dist/{form-submit-CX-CxJjQ.d.mts → form-submit-C_vJXCxh.d.mts} +11 -1
- package/dist/{form-submit-CX-CxJjQ.d.ts → form-submit-C_vJXCxh.d.ts} +11 -1
- package/dist/index.d.mts +9 -180
- package/dist/index.d.ts +9 -180
- package/dist/index.js +332 -285
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +329 -285
- package/dist/index.mjs.map +1 -1
- package/dist/{phone-utils-D12FW8tT.d.ts → phone-utils-Cfdx474X.d.mts} +178 -3
- package/dist/{phone-utils-BNiSqeF7.d.mts → phone-utils-D2TGPCQW.d.ts} +178 -3
- package/dist/phone.d.mts +2 -2
- package/dist/phone.d.ts +2 -2
- package/dist/phone.js +2 -2
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs +2 -2
- package/dist/phone.mjs.map +1 -1
- package/dist/{sales-6vMEcopj.d.mts → sales-D4aU73mR.d.mts} +1 -1
- package/dist/{sales-DXLGjJQ6.d.ts → sales-DkdrGIUS.d.ts} +1 -1
- package/dist/sales.d.mts +3 -3
- package/dist/sales.d.ts +3 -3
- package/dist/sales.js +193 -171
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +193 -171
- package/dist/sales.mjs.map +1 -1
- package/dist/{ingest-typed-B9I1c7jr.d.ts → submit-DuvP5AGN.d.ts} +161 -4
- package/dist/{ingest-typed-PKFEuJ8E.d.mts → submit-rqgXl-Wg.d.mts} +161 -4
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { p as BookingDayWindows, h as BookingMode, q as ConversionIntegrations } from './bookings-
|
|
1
|
+
import { p as BookingDayWindows, h as BookingMode, q as ConversionIntegrations, T as TrackingConfigReference } from './bookings-Bw2ImtPd.js';
|
|
2
2
|
import * as zod_v4_core from 'zod/v4/core';
|
|
3
3
|
import * as z from 'zod/mini';
|
|
4
|
-
import { J as JsonValue,
|
|
5
|
-
import './phone-utils-
|
|
4
|
+
import { J as JsonValue, a as FormSubmitConfig, b as FormSubmitMetadata } from './form-submit-C_vJXCxh.js';
|
|
5
|
+
import { n as LeadFormKind, p as LeadFormRole, m as LEAD_FORM_ROLE_SPECS, l as LEAD_FORM_ROLES, b as TrackingEnvironment } from './phone-utils-D2TGPCQW.js';
|
|
6
6
|
|
|
7
7
|
type BookingProvider = "autoleap";
|
|
8
8
|
/** One service choice on the booking form, by the site's own key. */
|
|
@@ -779,6 +779,10 @@ declare const EVENT_REGISTRY: {
|
|
|
779
779
|
label: z.ZodMiniString<string>;
|
|
780
780
|
value: z.ZodMiniType<JsonValue, unknown, zod_v4_core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
781
781
|
}, zod_v4_core.$strict>>>>;
|
|
782
|
+
contract_violations: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniArray<z.ZodMiniObject<{
|
|
783
|
+
role: z.ZodMiniNullable<z.ZodMiniString<string>>;
|
|
784
|
+
rule: z.ZodMiniString<string>;
|
|
785
|
+
}, zod_v4_core.$strict>>>>;
|
|
782
786
|
}, zod_v4_core.$strict>;
|
|
783
787
|
page: z.ZodMiniObject<{
|
|
784
788
|
path: z.ZodMiniString<string>;
|
|
@@ -1026,4 +1030,157 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
|
|
|
1026
1030
|
getVisitorId(): string;
|
|
1027
1031
|
}
|
|
1028
1032
|
|
|
1029
|
-
|
|
1033
|
+
/** One required role; `requiredWhen` is the one-level condition (ADR-0024 §3). */
|
|
1034
|
+
interface LeadFormRequirementDecl {
|
|
1035
|
+
readonly role: LeadFormRole;
|
|
1036
|
+
readonly requiredWhen: {
|
|
1037
|
+
readonly role: LeadFormRole;
|
|
1038
|
+
readonly anyOf: readonly string[];
|
|
1039
|
+
} | null;
|
|
1040
|
+
/** An operator recorded a waiver: optional in the type, still reported when missing. */
|
|
1041
|
+
readonly waived?: boolean;
|
|
1042
|
+
}
|
|
1043
|
+
/** What one kind of form must collect, as generated for the site. */
|
|
1044
|
+
interface LeadFormKindDecl {
|
|
1045
|
+
/** The published contract hash; null when nothing is bound for the kind. */
|
|
1046
|
+
readonly hash: string | null;
|
|
1047
|
+
readonly requires: readonly LeadFormRequirementDecl[];
|
|
1048
|
+
/** Each group is satisfied by any one of its roles. */
|
|
1049
|
+
readonly requiresAny: readonly (readonly LeadFormRole[])[];
|
|
1050
|
+
/** Live option keys per choice role; deprecated keys are left out. */
|
|
1051
|
+
readonly options: {
|
|
1052
|
+
readonly [role: string]: readonly string[];
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
/** The module `aranova-tracking forms gen` writes: `ARANOVA_LEAD_FORMS`. */
|
|
1056
|
+
interface LeadFormContracts {
|
|
1057
|
+
readonly registryVersion: number;
|
|
1058
|
+
readonly siteId: string | null;
|
|
1059
|
+
readonly contracts: {
|
|
1060
|
+
readonly [K in LeadFormKind]?: LeadFormKindDecl;
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
/** `{ start: "HH:MM", end: "HH:MM" | null, label? }`, business-local; pinned to the zod by test. */
|
|
1064
|
+
interface LeadFormTimeWindow {
|
|
1065
|
+
start: string;
|
|
1066
|
+
end: string | null;
|
|
1067
|
+
label?: string;
|
|
1068
|
+
}
|
|
1069
|
+
interface LeadFormAddress {
|
|
1070
|
+
line1: string;
|
|
1071
|
+
line2?: string;
|
|
1072
|
+
city?: string;
|
|
1073
|
+
region?: string;
|
|
1074
|
+
postal_code?: string;
|
|
1075
|
+
country?: string;
|
|
1076
|
+
}
|
|
1077
|
+
type Specs = typeof LEAD_FORM_ROLE_SPECS;
|
|
1078
|
+
type RegistryRole = (typeof LEAD_FORM_ROLES)[number];
|
|
1079
|
+
type AddOnRole = `add_on:${string}`;
|
|
1080
|
+
type SpecOf<R> = R extends AddOnRole ? Specs["add_on"] : R extends keyof Specs ? Specs[R] : never;
|
|
1081
|
+
type PrimitiveOf<R> = SpecOf<R>["primitive"];
|
|
1082
|
+
type EmptyKind = {
|
|
1083
|
+
hash: null;
|
|
1084
|
+
requires: readonly [];
|
|
1085
|
+
requiresAny: readonly [];
|
|
1086
|
+
options: Record<string, never>;
|
|
1087
|
+
};
|
|
1088
|
+
type KindOf<C extends LeadFormContracts, K extends LeadFormKind> = C["contracts"][K] extends LeadFormKindDecl ? C["contracts"][K] : EmptyKind;
|
|
1089
|
+
/** The site's live keys for a choice role, else the registry's fixed ones, else any key. */
|
|
1090
|
+
type OptionKey<D extends LeadFormKindDecl, R> = R extends keyof D["options"] ? D["options"][R][number] : SpecOf<R> extends {
|
|
1091
|
+
options: readonly {
|
|
1092
|
+
key: infer Key;
|
|
1093
|
+
}[];
|
|
1094
|
+
} ? Key : string;
|
|
1095
|
+
interface PrimitiveValues {
|
|
1096
|
+
string: string;
|
|
1097
|
+
text: string;
|
|
1098
|
+
phone: string;
|
|
1099
|
+
email: string;
|
|
1100
|
+
date: string;
|
|
1101
|
+
bool: boolean;
|
|
1102
|
+
number: number;
|
|
1103
|
+
time_window: LeadFormTimeWindow;
|
|
1104
|
+
address: LeadFormAddress;
|
|
1105
|
+
}
|
|
1106
|
+
/** The value a role takes: option keys for a choice role, never labels. */
|
|
1107
|
+
type LeadFormValue<D extends LeadFormKindDecl, R> = PrimitiveOf<R> extends "enum" ? OptionKey<D, R> : PrimitiveOf<R> extends "multi_enum" ? readonly OptionKey<D, R>[] : PrimitiveValues[Extract<PrimitiveOf<R>, keyof PrimitiveValues>];
|
|
1108
|
+
type Blank = null | undefined;
|
|
1109
|
+
type RequiredRoles<D extends LeadFormKindDecl> = Exclude<Extract<D["requires"][number], {
|
|
1110
|
+
readonly requiredWhen: null;
|
|
1111
|
+
}>, {
|
|
1112
|
+
readonly waived: true;
|
|
1113
|
+
}>["role"];
|
|
1114
|
+
type AnyOf<D extends LeadFormKindDecl, G extends readonly string[]> = {
|
|
1115
|
+
[R in G[number]]: {
|
|
1116
|
+
[P in R]: LeadFormValue<D, P>;
|
|
1117
|
+
};
|
|
1118
|
+
}[G[number]];
|
|
1119
|
+
type AllGroups<D extends LeadFormKindDecl, Gs> = Gs extends readonly [
|
|
1120
|
+
infer H extends readonly string[],
|
|
1121
|
+
...infer T
|
|
1122
|
+
] ? AnyOf<D, H> & AllGroups<D, T> : unknown;
|
|
1123
|
+
/**
|
|
1124
|
+
* The `fields` of one kind's submit: unconditionally required roles are required keys, each
|
|
1125
|
+
* any-of group needs one of its roles, everything else in the registry is optional (blank is
|
|
1126
|
+
* omitted); a `required_when` role is optional here and checked at runtime.
|
|
1127
|
+
*/
|
|
1128
|
+
type LeadFormFields<C extends LeadFormContracts, K extends LeadFormKind> = {
|
|
1129
|
+
[R in RequiredRoles<KindOf<C, K>>]: LeadFormValue<KindOf<C, K>, R>;
|
|
1130
|
+
} & {
|
|
1131
|
+
[R in Exclude<RegistryRole, RequiredRoles<KindOf<C, K>>>]?: LeadFormValue<KindOf<C, K>, R> | Blank;
|
|
1132
|
+
} & {
|
|
1133
|
+
[R in AddOnRole]?: boolean | Blank;
|
|
1134
|
+
} & AllGroups<KindOf<C, K>, KindOf<C, K>["requiresAny"]>;
|
|
1135
|
+
interface LeadFormExtraField {
|
|
1136
|
+
key: string;
|
|
1137
|
+
label: string;
|
|
1138
|
+
value: JsonValue;
|
|
1139
|
+
}
|
|
1140
|
+
interface LeadFormSubmitInput<C extends LeadFormContracts, K extends LeadFormKind> {
|
|
1141
|
+
/** The `<form id>`, so `form_start` and `form_submit` line up. */
|
|
1142
|
+
formId: string;
|
|
1143
|
+
kind: K;
|
|
1144
|
+
fields: LeadFormFields<C, K>;
|
|
1145
|
+
/** Questions with no registry role yet: shown beside the contract, never texted. */
|
|
1146
|
+
extra?: LeadFormExtraField[];
|
|
1147
|
+
action?: string | null;
|
|
1148
|
+
}
|
|
1149
|
+
/** Anything that can send a `form_submit`: `useTracking()` with `form_submit` registered. */
|
|
1150
|
+
interface LeadFormTracking {
|
|
1151
|
+
trackEvent(eventType: "form_submit", metadata: FormSubmitMetadata): void;
|
|
1152
|
+
}
|
|
1153
|
+
interface LeadFormSubmitOptions {
|
|
1154
|
+
/** Defaults to the tracking client's `createTracking({ debug })`. Throws on a violation. */
|
|
1155
|
+
debug?: boolean;
|
|
1156
|
+
/** Defaults to the tracking client's; `development` logs every violation. */
|
|
1157
|
+
environment?: TrackingEnvironment;
|
|
1158
|
+
/** Defaults to the tracking client's; validation and the hash use its live contracts. */
|
|
1159
|
+
trackingConfig?: TrackingConfigReference;
|
|
1160
|
+
}
|
|
1161
|
+
interface LeadFormSubmitter<C extends LeadFormContracts> {
|
|
1162
|
+
/** Send one typed `form_submit`; returns the metadata sent, violations included. */
|
|
1163
|
+
submit<K extends LeadFormKind>(input: LeadFormSubmitInput<C, K>): FormSubmitMetadata;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Bind a tracking client to the site's generated contracts (`ARANOVA_LEAD_FORMS`).
|
|
1167
|
+
*
|
|
1168
|
+
* @example
|
|
1169
|
+
* ```ts
|
|
1170
|
+
* const leadForms = createLeadFormSubmit(useTracking(), ARANOVA_LEAD_FORMS);
|
|
1171
|
+
* leadForms.submit({ formId: "booking-form", kind: "booking", fields: { given_name, phone } });
|
|
1172
|
+
* ```
|
|
1173
|
+
*/
|
|
1174
|
+
declare function createLeadFormSubmit<C extends LeadFormContracts>(tracking: LeadFormTracking, contracts: C, options?: LeadFormSubmitOptions): LeadFormSubmitter<C>;
|
|
1175
|
+
/**
|
|
1176
|
+
* A picked slot as `preferred_date` + `preferred_time`, in the business's wall time.
|
|
1177
|
+
* Takes `YYYY-MM-DD[T ]HH:MM` with no offset; a `Z`/`±HH:MM` instant or a `Date` would be re-zoned.
|
|
1178
|
+
*/
|
|
1179
|
+
declare function slotFields(dateTime: string): {
|
|
1180
|
+
preferred_date: string;
|
|
1181
|
+
preferred_time: LeadFormTimeWindow;
|
|
1182
|
+
};
|
|
1183
|
+
/** A `time_window` value: `timeWindow("09:00", "12:00", "Morning")`; an exact time has no end. */
|
|
1184
|
+
declare function timeWindow(start: string, end?: string | null, label?: string): LeadFormTimeWindow;
|
|
1185
|
+
|
|
1186
|
+
export { type SiteLinkClickConfig as $, type AutomaticEventName as A, type BookableDay as B, type CtaClickConfig as C, type LeadFormTimeWindow as D, EVENT_SEMANTICS as E, type FormStartConfig as F, type LeadFormTracking as G, type LeadFormValue as H, type MultiPageSessionConfig as I, type MultiPageSessionMetadata as J, type PageExitMetadata as K, type LeadFormAddress as L, type ManualEventName as M, type PageIdentity as N, type PageViewConfig as O, type PageExitConfig as P, type PageViewMetadata as Q, type PhoneClickConfig as R, type PhoneClickMetadata as S, type RegisteredAutomaticEvents as T, type RegisteredManualEvents as U, type ScrollDepthConfig as V, type ScrollDepthMetadata as W, type SdkHeartbeatConfig as X, type SdkHeartbeatMetadata as Y, type SiteLinkArrivalConfig as Z, type SiteLinkArrivalMetadata as _, type BookingHandoffPrefill as a, type SiteLinkClickMetadata as a0, type SpecificPageName as a1, type SpecificPageVisitConfig as a2, type SpecificPageVisitMetadata as a3, type TimeOnSiteConfig as a4, type TimeOnSiteMetadata as a5, type TrackableEvent as a6, type TriggerRegistryConfig as a7, type TypedTrackEventOptions as a8, type TypedTrackingClient as a9, bookableSlots as aa, buildBookingHandoffUrl as ab, getBookingIntegration as ac, getEventSemantics as ad, groupBookingOptions as ae, shopToday as af, slotFields as ag, timeWindow as ah, createLeadFormSubmit as ai, type BookingIntegration as b, type BookingOption as c, type BookingOptionGroup as d, type BookingProvider as e, type BookingRules as f, type CtaClickMetadata as g, type EventCategory as h, type EventClientVisibility as i, type EventConfig as j, type EventKind as k, type EventMetadata as l, type EventName as m, type EventOutcomeRole as n, type EventSemantics as o, type FormStartMetadata as p, type FormStepConfig as q, type FormStepMetadata as r, type LeadFormContracts as s, type LeadFormExtraField as t, type LeadFormFields as u, type LeadFormKindDecl as v, type LeadFormRequirementDecl as w, type LeadFormSubmitInput as x, type LeadFormSubmitOptions as y, type LeadFormSubmitter as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { p as BookingDayWindows, h as BookingMode, q as ConversionIntegrations } from './bookings-
|
|
1
|
+
import { p as BookingDayWindows, h as BookingMode, q as ConversionIntegrations, T as TrackingConfigReference } from './bookings-CDGNZUaH.mjs';
|
|
2
2
|
import * as zod_v4_core from 'zod/v4/core';
|
|
3
3
|
import * as z from 'zod/mini';
|
|
4
|
-
import { J as JsonValue,
|
|
5
|
-
import './phone-utils-
|
|
4
|
+
import { J as JsonValue, a as FormSubmitConfig, b as FormSubmitMetadata } from './form-submit-C_vJXCxh.mjs';
|
|
5
|
+
import { n as LeadFormKind, p as LeadFormRole, m as LEAD_FORM_ROLE_SPECS, l as LEAD_FORM_ROLES, b as TrackingEnvironment } from './phone-utils-Cfdx474X.mjs';
|
|
6
6
|
|
|
7
7
|
type BookingProvider = "autoleap";
|
|
8
8
|
/** One service choice on the booking form, by the site's own key. */
|
|
@@ -779,6 +779,10 @@ declare const EVENT_REGISTRY: {
|
|
|
779
779
|
label: z.ZodMiniString<string>;
|
|
780
780
|
value: z.ZodMiniType<JsonValue, unknown, zod_v4_core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
781
781
|
}, zod_v4_core.$strict>>>>;
|
|
782
|
+
contract_violations: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniArray<z.ZodMiniObject<{
|
|
783
|
+
role: z.ZodMiniNullable<z.ZodMiniString<string>>;
|
|
784
|
+
rule: z.ZodMiniString<string>;
|
|
785
|
+
}, zod_v4_core.$strict>>>>;
|
|
782
786
|
}, zod_v4_core.$strict>;
|
|
783
787
|
page: z.ZodMiniObject<{
|
|
784
788
|
path: z.ZodMiniString<string>;
|
|
@@ -1026,4 +1030,157 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
|
|
|
1026
1030
|
getVisitorId(): string;
|
|
1027
1031
|
}
|
|
1028
1032
|
|
|
1029
|
-
|
|
1033
|
+
/** One required role; `requiredWhen` is the one-level condition (ADR-0024 §3). */
|
|
1034
|
+
interface LeadFormRequirementDecl {
|
|
1035
|
+
readonly role: LeadFormRole;
|
|
1036
|
+
readonly requiredWhen: {
|
|
1037
|
+
readonly role: LeadFormRole;
|
|
1038
|
+
readonly anyOf: readonly string[];
|
|
1039
|
+
} | null;
|
|
1040
|
+
/** An operator recorded a waiver: optional in the type, still reported when missing. */
|
|
1041
|
+
readonly waived?: boolean;
|
|
1042
|
+
}
|
|
1043
|
+
/** What one kind of form must collect, as generated for the site. */
|
|
1044
|
+
interface LeadFormKindDecl {
|
|
1045
|
+
/** The published contract hash; null when nothing is bound for the kind. */
|
|
1046
|
+
readonly hash: string | null;
|
|
1047
|
+
readonly requires: readonly LeadFormRequirementDecl[];
|
|
1048
|
+
/** Each group is satisfied by any one of its roles. */
|
|
1049
|
+
readonly requiresAny: readonly (readonly LeadFormRole[])[];
|
|
1050
|
+
/** Live option keys per choice role; deprecated keys are left out. */
|
|
1051
|
+
readonly options: {
|
|
1052
|
+
readonly [role: string]: readonly string[];
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
/** The module `aranova-tracking forms gen` writes: `ARANOVA_LEAD_FORMS`. */
|
|
1056
|
+
interface LeadFormContracts {
|
|
1057
|
+
readonly registryVersion: number;
|
|
1058
|
+
readonly siteId: string | null;
|
|
1059
|
+
readonly contracts: {
|
|
1060
|
+
readonly [K in LeadFormKind]?: LeadFormKindDecl;
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
/** `{ start: "HH:MM", end: "HH:MM" | null, label? }`, business-local; pinned to the zod by test. */
|
|
1064
|
+
interface LeadFormTimeWindow {
|
|
1065
|
+
start: string;
|
|
1066
|
+
end: string | null;
|
|
1067
|
+
label?: string;
|
|
1068
|
+
}
|
|
1069
|
+
interface LeadFormAddress {
|
|
1070
|
+
line1: string;
|
|
1071
|
+
line2?: string;
|
|
1072
|
+
city?: string;
|
|
1073
|
+
region?: string;
|
|
1074
|
+
postal_code?: string;
|
|
1075
|
+
country?: string;
|
|
1076
|
+
}
|
|
1077
|
+
type Specs = typeof LEAD_FORM_ROLE_SPECS;
|
|
1078
|
+
type RegistryRole = (typeof LEAD_FORM_ROLES)[number];
|
|
1079
|
+
type AddOnRole = `add_on:${string}`;
|
|
1080
|
+
type SpecOf<R> = R extends AddOnRole ? Specs["add_on"] : R extends keyof Specs ? Specs[R] : never;
|
|
1081
|
+
type PrimitiveOf<R> = SpecOf<R>["primitive"];
|
|
1082
|
+
type EmptyKind = {
|
|
1083
|
+
hash: null;
|
|
1084
|
+
requires: readonly [];
|
|
1085
|
+
requiresAny: readonly [];
|
|
1086
|
+
options: Record<string, never>;
|
|
1087
|
+
};
|
|
1088
|
+
type KindOf<C extends LeadFormContracts, K extends LeadFormKind> = C["contracts"][K] extends LeadFormKindDecl ? C["contracts"][K] : EmptyKind;
|
|
1089
|
+
/** The site's live keys for a choice role, else the registry's fixed ones, else any key. */
|
|
1090
|
+
type OptionKey<D extends LeadFormKindDecl, R> = R extends keyof D["options"] ? D["options"][R][number] : SpecOf<R> extends {
|
|
1091
|
+
options: readonly {
|
|
1092
|
+
key: infer Key;
|
|
1093
|
+
}[];
|
|
1094
|
+
} ? Key : string;
|
|
1095
|
+
interface PrimitiveValues {
|
|
1096
|
+
string: string;
|
|
1097
|
+
text: string;
|
|
1098
|
+
phone: string;
|
|
1099
|
+
email: string;
|
|
1100
|
+
date: string;
|
|
1101
|
+
bool: boolean;
|
|
1102
|
+
number: number;
|
|
1103
|
+
time_window: LeadFormTimeWindow;
|
|
1104
|
+
address: LeadFormAddress;
|
|
1105
|
+
}
|
|
1106
|
+
/** The value a role takes: option keys for a choice role, never labels. */
|
|
1107
|
+
type LeadFormValue<D extends LeadFormKindDecl, R> = PrimitiveOf<R> extends "enum" ? OptionKey<D, R> : PrimitiveOf<R> extends "multi_enum" ? readonly OptionKey<D, R>[] : PrimitiveValues[Extract<PrimitiveOf<R>, keyof PrimitiveValues>];
|
|
1108
|
+
type Blank = null | undefined;
|
|
1109
|
+
type RequiredRoles<D extends LeadFormKindDecl> = Exclude<Extract<D["requires"][number], {
|
|
1110
|
+
readonly requiredWhen: null;
|
|
1111
|
+
}>, {
|
|
1112
|
+
readonly waived: true;
|
|
1113
|
+
}>["role"];
|
|
1114
|
+
type AnyOf<D extends LeadFormKindDecl, G extends readonly string[]> = {
|
|
1115
|
+
[R in G[number]]: {
|
|
1116
|
+
[P in R]: LeadFormValue<D, P>;
|
|
1117
|
+
};
|
|
1118
|
+
}[G[number]];
|
|
1119
|
+
type AllGroups<D extends LeadFormKindDecl, Gs> = Gs extends readonly [
|
|
1120
|
+
infer H extends readonly string[],
|
|
1121
|
+
...infer T
|
|
1122
|
+
] ? AnyOf<D, H> & AllGroups<D, T> : unknown;
|
|
1123
|
+
/**
|
|
1124
|
+
* The `fields` of one kind's submit: unconditionally required roles are required keys, each
|
|
1125
|
+
* any-of group needs one of its roles, everything else in the registry is optional (blank is
|
|
1126
|
+
* omitted); a `required_when` role is optional here and checked at runtime.
|
|
1127
|
+
*/
|
|
1128
|
+
type LeadFormFields<C extends LeadFormContracts, K extends LeadFormKind> = {
|
|
1129
|
+
[R in RequiredRoles<KindOf<C, K>>]: LeadFormValue<KindOf<C, K>, R>;
|
|
1130
|
+
} & {
|
|
1131
|
+
[R in Exclude<RegistryRole, RequiredRoles<KindOf<C, K>>>]?: LeadFormValue<KindOf<C, K>, R> | Blank;
|
|
1132
|
+
} & {
|
|
1133
|
+
[R in AddOnRole]?: boolean | Blank;
|
|
1134
|
+
} & AllGroups<KindOf<C, K>, KindOf<C, K>["requiresAny"]>;
|
|
1135
|
+
interface LeadFormExtraField {
|
|
1136
|
+
key: string;
|
|
1137
|
+
label: string;
|
|
1138
|
+
value: JsonValue;
|
|
1139
|
+
}
|
|
1140
|
+
interface LeadFormSubmitInput<C extends LeadFormContracts, K extends LeadFormKind> {
|
|
1141
|
+
/** The `<form id>`, so `form_start` and `form_submit` line up. */
|
|
1142
|
+
formId: string;
|
|
1143
|
+
kind: K;
|
|
1144
|
+
fields: LeadFormFields<C, K>;
|
|
1145
|
+
/** Questions with no registry role yet: shown beside the contract, never texted. */
|
|
1146
|
+
extra?: LeadFormExtraField[];
|
|
1147
|
+
action?: string | null;
|
|
1148
|
+
}
|
|
1149
|
+
/** Anything that can send a `form_submit`: `useTracking()` with `form_submit` registered. */
|
|
1150
|
+
interface LeadFormTracking {
|
|
1151
|
+
trackEvent(eventType: "form_submit", metadata: FormSubmitMetadata): void;
|
|
1152
|
+
}
|
|
1153
|
+
interface LeadFormSubmitOptions {
|
|
1154
|
+
/** Defaults to the tracking client's `createTracking({ debug })`. Throws on a violation. */
|
|
1155
|
+
debug?: boolean;
|
|
1156
|
+
/** Defaults to the tracking client's; `development` logs every violation. */
|
|
1157
|
+
environment?: TrackingEnvironment;
|
|
1158
|
+
/** Defaults to the tracking client's; validation and the hash use its live contracts. */
|
|
1159
|
+
trackingConfig?: TrackingConfigReference;
|
|
1160
|
+
}
|
|
1161
|
+
interface LeadFormSubmitter<C extends LeadFormContracts> {
|
|
1162
|
+
/** Send one typed `form_submit`; returns the metadata sent, violations included. */
|
|
1163
|
+
submit<K extends LeadFormKind>(input: LeadFormSubmitInput<C, K>): FormSubmitMetadata;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Bind a tracking client to the site's generated contracts (`ARANOVA_LEAD_FORMS`).
|
|
1167
|
+
*
|
|
1168
|
+
* @example
|
|
1169
|
+
* ```ts
|
|
1170
|
+
* const leadForms = createLeadFormSubmit(useTracking(), ARANOVA_LEAD_FORMS);
|
|
1171
|
+
* leadForms.submit({ formId: "booking-form", kind: "booking", fields: { given_name, phone } });
|
|
1172
|
+
* ```
|
|
1173
|
+
*/
|
|
1174
|
+
declare function createLeadFormSubmit<C extends LeadFormContracts>(tracking: LeadFormTracking, contracts: C, options?: LeadFormSubmitOptions): LeadFormSubmitter<C>;
|
|
1175
|
+
/**
|
|
1176
|
+
* A picked slot as `preferred_date` + `preferred_time`, in the business's wall time.
|
|
1177
|
+
* Takes `YYYY-MM-DD[T ]HH:MM` with no offset; a `Z`/`±HH:MM` instant or a `Date` would be re-zoned.
|
|
1178
|
+
*/
|
|
1179
|
+
declare function slotFields(dateTime: string): {
|
|
1180
|
+
preferred_date: string;
|
|
1181
|
+
preferred_time: LeadFormTimeWindow;
|
|
1182
|
+
};
|
|
1183
|
+
/** A `time_window` value: `timeWindow("09:00", "12:00", "Morning")`; an exact time has no end. */
|
|
1184
|
+
declare function timeWindow(start: string, end?: string | null, label?: string): LeadFormTimeWindow;
|
|
1185
|
+
|
|
1186
|
+
export { type SiteLinkClickConfig as $, type AutomaticEventName as A, type BookableDay as B, type CtaClickConfig as C, type LeadFormTimeWindow as D, EVENT_SEMANTICS as E, type FormStartConfig as F, type LeadFormTracking as G, type LeadFormValue as H, type MultiPageSessionConfig as I, type MultiPageSessionMetadata as J, type PageExitMetadata as K, type LeadFormAddress as L, type ManualEventName as M, type PageIdentity as N, type PageViewConfig as O, type PageExitConfig as P, type PageViewMetadata as Q, type PhoneClickConfig as R, type PhoneClickMetadata as S, type RegisteredAutomaticEvents as T, type RegisteredManualEvents as U, type ScrollDepthConfig as V, type ScrollDepthMetadata as W, type SdkHeartbeatConfig as X, type SdkHeartbeatMetadata as Y, type SiteLinkArrivalConfig as Z, type SiteLinkArrivalMetadata as _, type BookingHandoffPrefill as a, type SiteLinkClickMetadata as a0, type SpecificPageName as a1, type SpecificPageVisitConfig as a2, type SpecificPageVisitMetadata as a3, type TimeOnSiteConfig as a4, type TimeOnSiteMetadata as a5, type TrackableEvent as a6, type TriggerRegistryConfig as a7, type TypedTrackEventOptions as a8, type TypedTrackingClient as a9, bookableSlots as aa, buildBookingHandoffUrl as ab, getBookingIntegration as ac, getEventSemantics as ad, groupBookingOptions as ae, shopToday as af, slotFields as ag, timeWindow as ah, createLeadFormSubmit as ai, type BookingIntegration as b, type BookingOption as c, type BookingOptionGroup as d, type BookingProvider as e, type BookingRules as f, type CtaClickMetadata as g, type EventCategory as h, type EventClientVisibility as i, type EventConfig as j, type EventKind as k, type EventMetadata as l, type EventName as m, type EventOutcomeRole as n, type EventSemantics as o, type FormStartMetadata as p, type FormStepConfig as q, type FormStepMetadata as r, type LeadFormContracts as s, type LeadFormExtraField as t, type LeadFormFields as u, type LeadFormKindDecl as v, type LeadFormRequirementDecl as w, type LeadFormSubmitInput as x, type LeadFormSubmitOptions as y, type LeadFormSubmitter as z };
|