@aranova/tracking-react 1.11.0 → 1.13.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 +5 -3
- package/dist/{bookings-vM_aCNOS.d.ts → bookings-C1HMPjQl.d.ts} +36 -0
- package/dist/{bookings-BnXZGgwr.d.mts → bookings-CHpplXU7.d.mts} +36 -0
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +57 -4
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +57 -4
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +357 -286
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +357 -286
- package/dist/index.mjs.map +1 -1
- package/dist/{ingest-typed-TI6KqVzL.d.mts → ingest-typed-Ckt4R731.d.mts} +1 -1
- package/dist/{ingest-typed-BS9agXM5.d.ts → ingest-typed-sCDoPInT.d.ts} +1 -1
- package/dist/{sales-BegN5t_z.d.ts → sales-CNvzyF5T.d.ts} +1 -1
- package/dist/{sales-CSV0H3iG.d.mts → sales-YUH3bQl9.d.mts} +1 -1
- package/dist/sales.d.mts +2 -2
- package/dist/sales.d.ts +2 -2
- 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/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -915,9 +915,58 @@ function parseConversionConfig(raw) {
|
|
|
915
915
|
};
|
|
916
916
|
}
|
|
917
917
|
function parseLeadForms(value) {
|
|
918
|
-
if (!value || typeof value !== "
|
|
919
|
-
|
|
920
|
-
|
|
918
|
+
if (!isRecord(value) || typeof value.registry_version !== "number") return null;
|
|
919
|
+
return {
|
|
920
|
+
registry_version: value.registry_version,
|
|
921
|
+
contracts: records(value.contracts).flatMap(
|
|
922
|
+
(c) => typeof c.form_kind === "string" && typeof c.contract_hash === "string" ? [
|
|
923
|
+
{
|
|
924
|
+
form_kind: c.form_kind,
|
|
925
|
+
requires: records(c.requires).flatMap(
|
|
926
|
+
(r) => typeof r.role === "string" ? [
|
|
927
|
+
{
|
|
928
|
+
role: r.role,
|
|
929
|
+
required_when: parseCondition(r.required_when),
|
|
930
|
+
waived: r.waived === true
|
|
931
|
+
}
|
|
932
|
+
] : []
|
|
933
|
+
),
|
|
934
|
+
requires_any: records(c.requires_any).map((g) => ({
|
|
935
|
+
roles: strings(g.roles),
|
|
936
|
+
waived: g.waived === true
|
|
937
|
+
})),
|
|
938
|
+
options: records(c.options).flatMap(
|
|
939
|
+
(o) => typeof o.role === "string" ? [{ role: o.role, options: records(o.options).flatMap(parseContractOption) }] : []
|
|
940
|
+
),
|
|
941
|
+
contract_hash: c.contract_hash
|
|
942
|
+
}
|
|
943
|
+
] : []
|
|
944
|
+
)
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
function parseCondition(value) {
|
|
948
|
+
if (!isRecord(value) || typeof value.role !== "string") return null;
|
|
949
|
+
return { role: value.role, any_of: strings(value.any_of) };
|
|
950
|
+
}
|
|
951
|
+
function parseContractOption(value) {
|
|
952
|
+
if (typeof value.key !== "string" || typeof value.label !== "string") return [];
|
|
953
|
+
return [
|
|
954
|
+
{
|
|
955
|
+
key: value.key,
|
|
956
|
+
label: value.label,
|
|
957
|
+
is_non_answer: value.is_non_answer === true,
|
|
958
|
+
deprecated: value.deprecated === true
|
|
959
|
+
}
|
|
960
|
+
];
|
|
961
|
+
}
|
|
962
|
+
function isRecord(value) {
|
|
963
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
964
|
+
}
|
|
965
|
+
function records(value) {
|
|
966
|
+
return Array.isArray(value) ? value.filter(isRecord) : [];
|
|
967
|
+
}
|
|
968
|
+
function strings(value) {
|
|
969
|
+
return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
921
970
|
}
|
|
922
971
|
var CACHE_PREFIX = "_aranova_cfg_";
|
|
923
972
|
function cacheKey(url) {
|
|
@@ -1370,6 +1419,10 @@ var TrackingConfigRuntime = class {
|
|
|
1370
1419
|
integrations() {
|
|
1371
1420
|
return this.current?.integrations ?? null;
|
|
1372
1421
|
}
|
|
1422
|
+
/** The lead-form contracts, from the cached object like `integrations()`. */
|
|
1423
|
+
leadForms() {
|
|
1424
|
+
return this.current?.lead_forms ?? null;
|
|
1425
|
+
}
|
|
1373
1426
|
async revalidateNow() {
|
|
1374
1427
|
try {
|
|
1375
1428
|
const headers = {};
|
|
@@ -1752,6 +1805,118 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
|
1752
1805
|
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
1753
1806
|
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
1754
1807
|
|
|
1808
|
+
// ../tracking-core/src/lead-forms/lead-forms.gen.ts
|
|
1809
|
+
var z2 = __toESM(require("zod/mini"));
|
|
1810
|
+
var LEAD_FORM_REGISTRY_VERSION = 2;
|
|
1811
|
+
var LEAD_FORM_KINDS = ["booking", "quote", "contact", "consult", "callback"];
|
|
1812
|
+
var LEAD_FORM_ROLES = [
|
|
1813
|
+
"given_name",
|
|
1814
|
+
"family_name",
|
|
1815
|
+
"phone",
|
|
1816
|
+
"email",
|
|
1817
|
+
"service",
|
|
1818
|
+
"preferred_date",
|
|
1819
|
+
"preferred_time",
|
|
1820
|
+
"note",
|
|
1821
|
+
"visit",
|
|
1822
|
+
"intent",
|
|
1823
|
+
"vehicle",
|
|
1824
|
+
"drop_off",
|
|
1825
|
+
"address",
|
|
1826
|
+
"patient_type",
|
|
1827
|
+
"matter",
|
|
1828
|
+
"language",
|
|
1829
|
+
"products",
|
|
1830
|
+
"goal",
|
|
1831
|
+
"business_type",
|
|
1832
|
+
"lead_volume",
|
|
1833
|
+
"attribution"
|
|
1834
|
+
];
|
|
1835
|
+
var LEAD_FORM_PRIMITIVES = [
|
|
1836
|
+
"string",
|
|
1837
|
+
"text",
|
|
1838
|
+
"enum",
|
|
1839
|
+
"multi_enum",
|
|
1840
|
+
"bool",
|
|
1841
|
+
"date",
|
|
1842
|
+
"time_window",
|
|
1843
|
+
"phone",
|
|
1844
|
+
"email",
|
|
1845
|
+
"address",
|
|
1846
|
+
"number"
|
|
1847
|
+
];
|
|
1848
|
+
var leadFormPrimitiveSchemas = /* @__PURE__ */ (() => ({
|
|
1849
|
+
string: z2.string().check(z2.maxLength(120)),
|
|
1850
|
+
text: z2.string().check(z2.maxLength(2e3)),
|
|
1851
|
+
enum: z2.string().check(z2.regex(/^[a-z0-9-]{1,48}$/)),
|
|
1852
|
+
multi_enum: z2.array(z2.string().check(z2.regex(/^[a-z0-9-]{1,48}$/))).check(z2.maxLength(10)),
|
|
1853
|
+
bool: z2.boolean(),
|
|
1854
|
+
date: z2.string().check(z2.regex(/^\d{4}-\d{2}-\d{2}$/)),
|
|
1855
|
+
time_window: z2.strictObject({
|
|
1856
|
+
start: z2.string().check(z2.regex(/^([01]\d|2[0-3]):[0-5]\d$/)),
|
|
1857
|
+
end: z2.nullable(z2.string().check(z2.regex(/^([01]\d|2[0-3]):[0-5]\d$/))),
|
|
1858
|
+
label: z2.optional(z2.string().check(z2.maxLength(60)))
|
|
1859
|
+
}),
|
|
1860
|
+
phone: z2.string().check(z2.regex(/^\+[1-9]\d{6,14}$/)),
|
|
1861
|
+
email: z2.string().check(z2.maxLength(320), z2.regex(/^[^\s@]+@[^\s@]+$/)),
|
|
1862
|
+
address: z2.strictObject({
|
|
1863
|
+
line1: z2.string().check(z2.maxLength(120)),
|
|
1864
|
+
line2: z2.optional(z2.string().check(z2.maxLength(120))),
|
|
1865
|
+
city: z2.optional(z2.string().check(z2.maxLength(120))),
|
|
1866
|
+
region: z2.optional(z2.string().check(z2.maxLength(120))),
|
|
1867
|
+
postal_code: z2.optional(z2.string().check(z2.maxLength(120))),
|
|
1868
|
+
country: z2.optional(z2.string().check(z2.maxLength(120)))
|
|
1869
|
+
}),
|
|
1870
|
+
number: z2.number()
|
|
1871
|
+
}))();
|
|
1872
|
+
var LEAD_FORM_ROLE_SPECS = {
|
|
1873
|
+
given_name: { primitive: "string", smsLabel: "", contactIdentity: true },
|
|
1874
|
+
family_name: { primitive: "string", smsLabel: "", contactIdentity: true },
|
|
1875
|
+
phone: { primitive: "phone", smsLabel: "", contactIdentity: true },
|
|
1876
|
+
email: { primitive: "email", smsLabel: "", contactIdentity: true },
|
|
1877
|
+
service: { primitive: "multi_enum", smsLabel: "Service" },
|
|
1878
|
+
preferred_date: { primitive: "date", smsLabel: "Date" },
|
|
1879
|
+
preferred_time: { primitive: "time_window", smsLabel: "Time" },
|
|
1880
|
+
note: { primitive: "text", smsLabel: "Note" },
|
|
1881
|
+
visit: {
|
|
1882
|
+
primitive: "enum",
|
|
1883
|
+
smsLabel: "Visit",
|
|
1884
|
+
options: [
|
|
1885
|
+
{ key: "in-shop", label: "In shop" },
|
|
1886
|
+
{ key: "in-home", label: "In home" },
|
|
1887
|
+
{ key: "remote", label: "Remote" },
|
|
1888
|
+
{ key: "on-site", label: "On site" }
|
|
1889
|
+
]
|
|
1890
|
+
},
|
|
1891
|
+
intent: {
|
|
1892
|
+
primitive: "enum",
|
|
1893
|
+
smsLabel: "Wants",
|
|
1894
|
+
options: [
|
|
1895
|
+
{ key: "book", label: "Book" },
|
|
1896
|
+
{ key: "quote", label: "Quote" }
|
|
1897
|
+
]
|
|
1898
|
+
},
|
|
1899
|
+
vehicle: { primitive: "string", smsLabel: "Vehicle" },
|
|
1900
|
+
drop_off: {
|
|
1901
|
+
primitive: "enum",
|
|
1902
|
+
smsLabel: "Drop-off",
|
|
1903
|
+
options: [
|
|
1904
|
+
{ key: "wait-for-it", label: "Waiting" },
|
|
1905
|
+
{ key: "drop-off", label: "Dropping off" }
|
|
1906
|
+
]
|
|
1907
|
+
},
|
|
1908
|
+
address: { primitive: "address", smsLabel: "Address" },
|
|
1909
|
+
patient_type: { primitive: "enum", smsLabel: "Patient" },
|
|
1910
|
+
matter: { primitive: "enum", smsLabel: "Matter" },
|
|
1911
|
+
language: { primitive: "enum", smsLabel: "Language" },
|
|
1912
|
+
products: { primitive: "multi_enum", smsLabel: "Products" },
|
|
1913
|
+
goal: { primitive: "enum", smsLabel: "Goal" },
|
|
1914
|
+
business_type: { primitive: "enum", smsLabel: "Business" },
|
|
1915
|
+
lead_volume: { primitive: "enum", smsLabel: "Lead volume" },
|
|
1916
|
+
add_on: { primitive: "bool", smsLabel: "" },
|
|
1917
|
+
attribution: { primitive: "enum", smsLabel: "", uninteresting: true }
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1755
1920
|
// ../tracking-core/src/resources/http/errors.ts
|
|
1756
1921
|
var AranovaApiError = class extends Error {
|
|
1757
1922
|
constructor(message, options) {
|
|
@@ -1845,39 +2010,54 @@ function outcomeOf(body) {
|
|
|
1845
2010
|
if (body.status === "pending") return { status: "pending", id: body.id, mode };
|
|
1846
2011
|
return { status: "failed", id: body.id, fallbackUrl: body.fallback_url, mode };
|
|
1847
2012
|
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
}
|
|
1856
|
-
const
|
|
1857
|
-
field("first_name", "text", "First name", input.firstName),
|
|
1858
|
-
field("last_name", "text", "Last name", input.lastName),
|
|
2013
|
+
var DROP_OFF_KEYS = {
|
|
2014
|
+
waitForIt: "wait-for-it",
|
|
2015
|
+
dropOff: "drop-off"
|
|
2016
|
+
};
|
|
2017
|
+
function formSubmitPayload(input, formSubmit, contractHash) {
|
|
2018
|
+
const field = (role, name, type, label, value) => ({ name, type, label, value, role });
|
|
2019
|
+
const text = (value) => value?.trim() || void 0;
|
|
2020
|
+
const { vehicle, dropOff } = input;
|
|
2021
|
+
const entries = [
|
|
2022
|
+
field("given_name", "first_name", "text", "First name", text(input.firstName)),
|
|
2023
|
+
field("family_name", "last_name", "text", "Last name", text(input.lastName)),
|
|
1859
2024
|
// E.164 on the wire: it keys the customer and enhanced-conversion matching.
|
|
1860
|
-
field("phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
|
|
1861
|
-
field("email", "email", "Email", input.email
|
|
2025
|
+
field("phone", "phone", "tel", "Phone", toE164(input.phone) ?? input.phone),
|
|
2026
|
+
field("email", "email", "email", "Email", text(input.email)),
|
|
2027
|
+
field("service", "service", "select", "Service", input.services),
|
|
1862
2028
|
field(
|
|
1863
|
-
"
|
|
1864
|
-
"
|
|
1865
|
-
"
|
|
1866
|
-
|
|
2029
|
+
"vehicle",
|
|
2030
|
+
"vehicle",
|
|
2031
|
+
"text",
|
|
2032
|
+
"Vehicle",
|
|
2033
|
+
vehicle ? `${vehicle.year} ${vehicle.make} ${vehicle.model}` : void 0
|
|
1867
2034
|
),
|
|
1868
|
-
field("vehicle", "text", "Vehicle", vehicle),
|
|
1869
2035
|
field(
|
|
1870
|
-
"
|
|
1871
|
-
"
|
|
1872
|
-
"
|
|
1873
|
-
|
|
2036
|
+
"drop_off",
|
|
2037
|
+
"drop_off",
|
|
2038
|
+
"select",
|
|
2039
|
+
"Drop-off",
|
|
2040
|
+
dropOff ? DROP_OFF_KEYS[dropOff] : void 0
|
|
1874
2041
|
),
|
|
1875
|
-
field("
|
|
2042
|
+
field("preferred_date", "preferred_date", "date", "Date", input.startDate),
|
|
2043
|
+
field("preferred_time", "preferred_time", "time", "Time", {
|
|
2044
|
+
start: `${String(input.startHour).padStart(2, "0")}:00`,
|
|
2045
|
+
end: null
|
|
2046
|
+
}),
|
|
2047
|
+
field("note", "note", "textarea", "Notes", text(input.notes))
|
|
1876
2048
|
];
|
|
1877
|
-
const reported = new Set(
|
|
2049
|
+
const reported = new Set(entries.map((item) => item.name));
|
|
2050
|
+
const fields = entries.filter((item) => item.value !== void 0);
|
|
1878
2051
|
const extra = (formSubmit.extraFields ?? []).filter((item) => !reported.has(item.name));
|
|
1879
2052
|
return {
|
|
1880
|
-
form: {
|
|
2053
|
+
form: {
|
|
2054
|
+
id: formSubmit.formId,
|
|
2055
|
+
action: "/tracking/bookings",
|
|
2056
|
+
fields: [...fields, ...extra],
|
|
2057
|
+
kind: "booking",
|
|
2058
|
+
contract_version: LEAD_FORM_REGISTRY_VERSION,
|
|
2059
|
+
...contractHash ? { contract_hash: contractHash } : {}
|
|
2060
|
+
},
|
|
1881
2061
|
page: { path: typeof window === "undefined" ? "/" : window.location.pathname }
|
|
1882
2062
|
};
|
|
1883
2063
|
}
|
|
@@ -1975,8 +2155,11 @@ function createSalesBookingsClient(config, firing) {
|
|
|
1975
2155
|
}
|
|
1976
2156
|
if (formSubmit && !submittedForms.has(attemptKey)) {
|
|
1977
2157
|
submittedForms.add(attemptKey);
|
|
1978
|
-
const
|
|
1979
|
-
formSubmit.tracking.trackEvent(
|
|
2158
|
+
const contract = runtime?.leadForms()?.contracts.find((c) => c.form_kind === "booking");
|
|
2159
|
+
formSubmit.tracking.trackEvent(
|
|
2160
|
+
"form_submit",
|
|
2161
|
+
formSubmitPayload(input, formSubmit, contract?.contract_hash ?? null)
|
|
2162
|
+
);
|
|
1980
2163
|
}
|
|
1981
2164
|
const body = {
|
|
1982
2165
|
idempotency_key: attemptKey,
|
|
@@ -2226,17 +2409,17 @@ function createSalesClient(config) {
|
|
|
2226
2409
|
}
|
|
2227
2410
|
|
|
2228
2411
|
// ../tracking-core/src/resources/sales/schema.ts
|
|
2229
|
-
var
|
|
2412
|
+
var z4 = __toESM(require("zod/mini"));
|
|
2230
2413
|
|
|
2231
2414
|
// ../tracking-core/src/resources/sales/generated/zod.gen.ts
|
|
2232
|
-
var
|
|
2233
|
-
var zAutoLeapSaleFacts =
|
|
2234
|
-
first_order:
|
|
2235
|
-
fleet_customer:
|
|
2236
|
-
invoice_code:
|
|
2237
|
-
invoice_id:
|
|
2415
|
+
var z3 = __toESM(require("zod/mini"));
|
|
2416
|
+
var zAutoLeapSaleFacts = z3.object({
|
|
2417
|
+
first_order: z3.boolean(),
|
|
2418
|
+
fleet_customer: z3.boolean(),
|
|
2419
|
+
invoice_code: z3.string(),
|
|
2420
|
+
invoice_id: z3.string()
|
|
2238
2421
|
});
|
|
2239
|
-
var zErrorCode =
|
|
2422
|
+
var zErrorCode = z3.enum([
|
|
2240
2423
|
"missing_credentials",
|
|
2241
2424
|
"invalid_api_key",
|
|
2242
2425
|
"not_authenticated",
|
|
@@ -2280,37 +2463,37 @@ var zErrorCode = z2.enum([
|
|
|
2280
2463
|
"rate_limited",
|
|
2281
2464
|
"internal_error"
|
|
2282
2465
|
]);
|
|
2283
|
-
var zSaleItemEntitySchema =
|
|
2284
|
-
category:
|
|
2285
|
-
external_item_id:
|
|
2286
|
-
id:
|
|
2287
|
-
name:
|
|
2288
|
-
quantity:
|
|
2289
|
-
unit_cost_cents:
|
|
2290
|
-
unit_price_cents:
|
|
2466
|
+
var zSaleItemEntitySchema = z3.object({
|
|
2467
|
+
category: z3.nullable(z3.string()),
|
|
2468
|
+
external_item_id: z3.nullable(z3.string()),
|
|
2469
|
+
id: z3.uuid(),
|
|
2470
|
+
name: z3.nullable(z3.string()),
|
|
2471
|
+
quantity: z3.string().check(z3.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
|
|
2472
|
+
unit_cost_cents: z3.nullable(z3.int()),
|
|
2473
|
+
unit_price_cents: z3.int()
|
|
2291
2474
|
});
|
|
2292
|
-
var zSaleItemInputSchema =
|
|
2293
|
-
category:
|
|
2294
|
-
external_item_id:
|
|
2295
|
-
name:
|
|
2296
|
-
quantity:
|
|
2297
|
-
unit_cost_cents:
|
|
2298
|
-
unit_price_cents:
|
|
2475
|
+
var zSaleItemInputSchema = z3.strictObject({
|
|
2476
|
+
category: z3.nullish(z3.string()),
|
|
2477
|
+
external_item_id: z3.nullish(z3.string()),
|
|
2478
|
+
name: z3.nullish(z3.string()),
|
|
2479
|
+
quantity: z3.string().check(z3.regex(/^\d+(\.\d{1,3})?$/)),
|
|
2480
|
+
unit_cost_cents: z3.nullish(z3.int().check(z3.gte(0))),
|
|
2481
|
+
unit_price_cents: z3.int().check(z3.gte(0))
|
|
2299
2482
|
});
|
|
2300
|
-
var zSaleServiceEntitySchema =
|
|
2301
|
-
amount_cents:
|
|
2302
|
-
id:
|
|
2303
|
-
mapped:
|
|
2304
|
-
service_id:
|
|
2305
|
-
service_key:
|
|
2306
|
-
service_label:
|
|
2483
|
+
var zSaleServiceEntitySchema = z3.object({
|
|
2484
|
+
amount_cents: z3.int(),
|
|
2485
|
+
id: z3.uuid(),
|
|
2486
|
+
mapped: z3.nullable(z3.boolean()),
|
|
2487
|
+
service_id: z3.uuid(),
|
|
2488
|
+
service_key: z3.string(),
|
|
2489
|
+
service_label: z3.string()
|
|
2307
2490
|
});
|
|
2308
|
-
var zSaleServiceInputSchema =
|
|
2309
|
-
amount_cents:
|
|
2310
|
-
service:
|
|
2491
|
+
var zSaleServiceInputSchema = z3.strictObject({
|
|
2492
|
+
amount_cents: z3.int().check(z3.gte(0)),
|
|
2493
|
+
service: z3.string()
|
|
2311
2494
|
});
|
|
2312
|
-
var zSaleSource =
|
|
2313
|
-
var zSmsAutomationState =
|
|
2495
|
+
var zSaleSource = z3.enum(["api", "admin", "autoleap"]);
|
|
2496
|
+
var zSmsAutomationState = z3.enum([
|
|
2314
2497
|
"needs_check",
|
|
2315
2498
|
"failed",
|
|
2316
2499
|
"undelivered",
|
|
@@ -2322,7 +2505,7 @@ var zSmsAutomationState = z2.enum([
|
|
|
2322
2505
|
"eligible",
|
|
2323
2506
|
"not_applicable"
|
|
2324
2507
|
]);
|
|
2325
|
-
var zSmsWithheldReason =
|
|
2508
|
+
var zSmsWithheldReason = z3.enum([
|
|
2326
2509
|
"automation_disabled",
|
|
2327
2510
|
"sms_disabled",
|
|
2328
2511
|
"no_phone",
|
|
@@ -2350,75 +2533,75 @@ var zSmsWithheldReason = z2.enum([
|
|
|
2350
2533
|
"invalid_phone",
|
|
2351
2534
|
"recently_texted"
|
|
2352
2535
|
]);
|
|
2353
|
-
var zSaleSmsStatusSchema =
|
|
2354
|
-
can_send_now:
|
|
2355
|
-
last_message_at:
|
|
2356
|
-
reason_detail:
|
|
2536
|
+
var zSaleSmsStatusSchema = z3.object({
|
|
2537
|
+
can_send_now: z3._default(z3.boolean(), false),
|
|
2538
|
+
last_message_at: z3.nullable(z3.iso.datetime({ offset: true })),
|
|
2539
|
+
reason_detail: z3.nullable(z3.string()),
|
|
2357
2540
|
state: zSmsAutomationState,
|
|
2358
|
-
suppressed_by_other_sale:
|
|
2359
|
-
withheld_reason:
|
|
2541
|
+
suppressed_by_other_sale: z3._default(z3.boolean(), false),
|
|
2542
|
+
withheld_reason: z3.nullable(zSmsWithheldReason)
|
|
2360
2543
|
});
|
|
2361
|
-
var zSupportedCurrency =
|
|
2362
|
-
var zTrackingEnvironment =
|
|
2363
|
-
var zSaleCreateSchema =
|
|
2364
|
-
amount_total_cents:
|
|
2544
|
+
var zSupportedCurrency = z3.enum(["USD", "CAD"]);
|
|
2545
|
+
var zTrackingEnvironment = z3.enum(["production", "development"]);
|
|
2546
|
+
var zSaleCreateSchema = z3.strictObject({
|
|
2547
|
+
amount_total_cents: z3.nullish(z3.int().check(z3.gte(0))),
|
|
2365
2548
|
currency: zSupportedCurrency,
|
|
2366
|
-
customer_email:
|
|
2367
|
-
customer_name:
|
|
2368
|
-
customer_phone:
|
|
2369
|
-
description:
|
|
2370
|
-
environment:
|
|
2371
|
-
external_id:
|
|
2372
|
-
items:
|
|
2373
|
-
metadata:
|
|
2374
|
-
occurred_at:
|
|
2375
|
-
service:
|
|
2376
|
-
services:
|
|
2377
|
-
sms_consent:
|
|
2549
|
+
customer_email: z3.nullish(z3.email().check(z3.maxLength(320))),
|
|
2550
|
+
customer_name: z3.nullish(z3.string().check(z3.maxLength(200))),
|
|
2551
|
+
customer_phone: z3.nullish(z3.string().check(z3.maxLength(64))),
|
|
2552
|
+
description: z3.nullish(z3.string()),
|
|
2553
|
+
environment: z3._default(z3.optional(zTrackingEnvironment), "production"),
|
|
2554
|
+
external_id: z3.nullish(z3.string()),
|
|
2555
|
+
items: z3.optional(z3.array(zSaleItemInputSchema)),
|
|
2556
|
+
metadata: z3.nullish(z3.record(z3.string(), z3.unknown())),
|
|
2557
|
+
occurred_at: z3.iso.datetime({ offset: true }),
|
|
2558
|
+
service: z3.nullish(z3.string()),
|
|
2559
|
+
services: z3.nullish(z3.array(zSaleServiceInputSchema)),
|
|
2560
|
+
sms_consent: z3.nullish(z3.boolean())
|
|
2378
2561
|
});
|
|
2379
|
-
var zValidationError =
|
|
2380
|
-
ctx:
|
|
2381
|
-
input:
|
|
2382
|
-
loc:
|
|
2383
|
-
msg:
|
|
2384
|
-
type:
|
|
2562
|
+
var zValidationError = z3.object({
|
|
2563
|
+
ctx: z3.optional(z3.record(z3.string(), z3.unknown())),
|
|
2564
|
+
input: z3.optional(z3.unknown()),
|
|
2565
|
+
loc: z3.array(z3.union([z3.string(), z3.int()])),
|
|
2566
|
+
msg: z3.string(),
|
|
2567
|
+
type: z3.string()
|
|
2385
2568
|
});
|
|
2386
|
-
var zHttpValidationError =
|
|
2387
|
-
detail:
|
|
2569
|
+
var zHttpValidationError = z3.object({
|
|
2570
|
+
detail: z3.optional(z3.array(zValidationError))
|
|
2388
2571
|
});
|
|
2389
|
-
var zValidationErrorItem =
|
|
2390
|
-
loc:
|
|
2391
|
-
msg:
|
|
2392
|
-
type:
|
|
2572
|
+
var zValidationErrorItem = z3.object({
|
|
2573
|
+
loc: z3.array(z3.union([z3.string(), z3.int()])),
|
|
2574
|
+
msg: z3.string(),
|
|
2575
|
+
type: z3.string()
|
|
2393
2576
|
});
|
|
2394
|
-
var zApiErrorSchema =
|
|
2577
|
+
var zApiErrorSchema = z3.object({
|
|
2395
2578
|
code: zErrorCode,
|
|
2396
|
-
context:
|
|
2397
|
-
detail:
|
|
2398
|
-
errors:
|
|
2399
|
-
request_id:
|
|
2579
|
+
context: z3._default(z3.nullish(z3.record(z3.string(), z3.unknown())), null),
|
|
2580
|
+
detail: z3.string(),
|
|
2581
|
+
errors: z3._default(z3.nullish(z3.array(zValidationErrorItem)), null),
|
|
2582
|
+
request_id: z3._default(z3.nullish(z3.string()), null)
|
|
2400
2583
|
});
|
|
2401
|
-
var zWritebackEmailSource =
|
|
2402
|
-
var zWritebackEnrichmentStatus =
|
|
2403
|
-
var zWritebackSaleUploadCounts =
|
|
2404
|
-
failed:
|
|
2405
|
-
pending:
|
|
2406
|
-
skipped:
|
|
2407
|
-
submitted:
|
|
2408
|
-
total:
|
|
2409
|
-
uploaded:
|
|
2584
|
+
var zWritebackEmailSource = z3.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
|
|
2585
|
+
var zWritebackEnrichmentStatus = z3.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
|
|
2586
|
+
var zWritebackSaleUploadCounts = z3.object({
|
|
2587
|
+
failed: z3._default(z3.int(), 0),
|
|
2588
|
+
pending: z3._default(z3.int(), 0),
|
|
2589
|
+
skipped: z3._default(z3.int(), 0),
|
|
2590
|
+
submitted: z3._default(z3.int(), 0),
|
|
2591
|
+
total: z3._default(z3.int(), 0),
|
|
2592
|
+
uploaded: z3._default(z3.int(), 0)
|
|
2410
2593
|
});
|
|
2411
|
-
var zSaleWritebackStatusSchema =
|
|
2412
|
-
blocked_reason:
|
|
2413
|
-
can_dispatch:
|
|
2414
|
-
email_source:
|
|
2415
|
-
enrichment_status:
|
|
2416
|
-
gclid_attached:
|
|
2417
|
-
identifiers_sent:
|
|
2418
|
-
mapped_service_ids:
|
|
2419
|
-
matched_submit_count:
|
|
2420
|
-
needs_force:
|
|
2421
|
-
rollup:
|
|
2594
|
+
var zSaleWritebackStatusSchema = z3.object({
|
|
2595
|
+
blocked_reason: z3.nullable(z3.string()),
|
|
2596
|
+
can_dispatch: z3._default(z3.boolean(), false),
|
|
2597
|
+
email_source: z3.nullable(zWritebackEmailSource),
|
|
2598
|
+
enrichment_status: z3.nullable(zWritebackEnrichmentStatus),
|
|
2599
|
+
gclid_attached: z3._default(z3.boolean(), false),
|
|
2600
|
+
identifiers_sent: z3.nullable(z3.string()),
|
|
2601
|
+
mapped_service_ids: z3.array(z3.uuid()),
|
|
2602
|
+
matched_submit_count: z3.nullable(z3.int()),
|
|
2603
|
+
needs_force: z3._default(z3.boolean(), false),
|
|
2604
|
+
rollup: z3.enum([
|
|
2422
2605
|
"failed",
|
|
2423
2606
|
"skipped",
|
|
2424
2607
|
"pending",
|
|
@@ -2428,39 +2611,39 @@ var zSaleWritebackStatusSchema = z2.object({
|
|
|
2428
2611
|
"out_of_window",
|
|
2429
2612
|
"blocked"
|
|
2430
2613
|
]),
|
|
2431
|
-
stale:
|
|
2432
|
-
uncovered_service_ids:
|
|
2614
|
+
stale: z3._default(z3.boolean(), false),
|
|
2615
|
+
uncovered_service_ids: z3.array(z3.uuid()),
|
|
2433
2616
|
uploads: zWritebackSaleUploadCounts
|
|
2434
2617
|
});
|
|
2435
|
-
var zSaleEntitySchema =
|
|
2436
|
-
amount_total_cents:
|
|
2437
|
-
business_id:
|
|
2438
|
-
business_name:
|
|
2439
|
-
created_at:
|
|
2440
|
-
currency:
|
|
2441
|
-
customer_email:
|
|
2442
|
-
customer_name:
|
|
2443
|
-
customer_name_placeholder_confirmed:
|
|
2444
|
-
customer_name_placeholder_confirmed_at:
|
|
2445
|
-
customer_phone:
|
|
2446
|
-
description:
|
|
2618
|
+
var zSaleEntitySchema = z3.object({
|
|
2619
|
+
amount_total_cents: z3.int(),
|
|
2620
|
+
business_id: z3.uuid(),
|
|
2621
|
+
business_name: z3.nullable(z3.string()),
|
|
2622
|
+
created_at: z3.iso.datetime({ offset: true }),
|
|
2623
|
+
currency: z3.string(),
|
|
2624
|
+
customer_email: z3.nullable(z3.string()),
|
|
2625
|
+
customer_name: z3.nullable(z3.string()),
|
|
2626
|
+
customer_name_placeholder_confirmed: z3._default(z3.boolean(), false),
|
|
2627
|
+
customer_name_placeholder_confirmed_at: z3.nullable(z3.iso.datetime({ offset: true })),
|
|
2628
|
+
customer_phone: z3.nullable(z3.string()),
|
|
2629
|
+
description: z3.nullable(z3.string()),
|
|
2447
2630
|
environment: zTrackingEnvironment,
|
|
2448
|
-
external_id:
|
|
2449
|
-
id:
|
|
2450
|
-
items:
|
|
2451
|
-
metadata:
|
|
2452
|
-
occurred_at:
|
|
2453
|
-
service_id:
|
|
2454
|
-
service_key:
|
|
2455
|
-
service_label:
|
|
2456
|
-
services:
|
|
2457
|
-
sms_automation:
|
|
2458
|
-
sms_consent:
|
|
2459
|
-
sms_consent_granted_at:
|
|
2631
|
+
external_id: z3.nullable(z3.string()),
|
|
2632
|
+
id: z3.uuid(),
|
|
2633
|
+
items: z3.array(zSaleItemEntitySchema),
|
|
2634
|
+
metadata: z3.nullable(z3.record(z3.string(), z3.unknown())),
|
|
2635
|
+
occurred_at: z3.iso.datetime({ offset: true }),
|
|
2636
|
+
service_id: z3.nullable(z3.uuid()),
|
|
2637
|
+
service_key: z3.nullable(z3.string()),
|
|
2638
|
+
service_label: z3.nullable(z3.string()),
|
|
2639
|
+
services: z3.array(zSaleServiceEntitySchema),
|
|
2640
|
+
sms_automation: z3.nullable(zSaleSmsStatusSchema),
|
|
2641
|
+
sms_consent: z3._default(z3.boolean(), false),
|
|
2642
|
+
sms_consent_granted_at: z3.nullable(z3.iso.datetime({ offset: true })),
|
|
2460
2643
|
source: zSaleSource,
|
|
2461
|
-
source_facts:
|
|
2462
|
-
updated_at:
|
|
2463
|
-
writeback:
|
|
2644
|
+
source_facts: z3.nullable(zAutoLeapSaleFacts),
|
|
2645
|
+
updated_at: z3.iso.datetime({ offset: true }),
|
|
2646
|
+
writeback: z3.nullable(zSaleWritebackStatusSchema)
|
|
2464
2647
|
});
|
|
2465
2648
|
|
|
2466
2649
|
// ../tracking-core/src/resources/sales/schema.ts
|
|
@@ -2469,11 +2652,11 @@ var saleServiceSchema = zSaleServiceInputSchema;
|
|
|
2469
2652
|
var currencySchema = zSupportedCurrency;
|
|
2470
2653
|
var SUPPORTED_CURRENCIES = currencySchema.options;
|
|
2471
2654
|
var SALE_SOURCES = zSaleSource.options;
|
|
2472
|
-
var centsSchema =
|
|
2473
|
-
var metadataSchema =
|
|
2474
|
-
var customerNameSchema =
|
|
2475
|
-
var customerPhoneSchema =
|
|
2476
|
-
var customerEmailSchema =
|
|
2655
|
+
var centsSchema = z4.int().check(z4.gte(0));
|
|
2656
|
+
var metadataSchema = z4.record(z4.string(), z4.unknown());
|
|
2657
|
+
var customerNameSchema = z4.string().check(z4.maxLength(200));
|
|
2658
|
+
var customerPhoneSchema = z4.string().check(z4.maxLength(64));
|
|
2659
|
+
var customerEmailSchema = z4.email().check(z4.maxLength(320));
|
|
2477
2660
|
function addIssue(ctx, path, message) {
|
|
2478
2661
|
ctx.issues.push({ code: "custom", input: ctx.value, path, message });
|
|
2479
2662
|
}
|
|
@@ -2507,24 +2690,24 @@ function refineServiceXor(val, ctx, { requireAmount }) {
|
|
|
2507
2690
|
);
|
|
2508
2691
|
}
|
|
2509
2692
|
}
|
|
2510
|
-
var saleCreateSchema =
|
|
2511
|
-
var saleUpdateSchema =
|
|
2512
|
-
description:
|
|
2513
|
-
service:
|
|
2514
|
-
services:
|
|
2515
|
-
currency:
|
|
2516
|
-
amount_total_cents:
|
|
2517
|
-
occurred_at:
|
|
2518
|
-
items:
|
|
2519
|
-
metadata:
|
|
2520
|
-
customer_name:
|
|
2693
|
+
var saleCreateSchema = z4.extend(zSaleCreateSchema, { items: z4._default(z4.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
|
|
2694
|
+
var saleUpdateSchema = z4.strictObject({
|
|
2695
|
+
description: z4.nullish(z4.string()),
|
|
2696
|
+
service: z4.nullish(z4.string()),
|
|
2697
|
+
services: z4.nullish(z4.array(saleServiceSchema)),
|
|
2698
|
+
currency: z4.optional(currencySchema),
|
|
2699
|
+
amount_total_cents: z4.optional(centsSchema),
|
|
2700
|
+
occurred_at: z4.optional(z4.iso.datetime()),
|
|
2701
|
+
items: z4.optional(z4.array(saleItemSchema)),
|
|
2702
|
+
metadata: z4.nullish(metadataSchema),
|
|
2703
|
+
customer_name: z4.nullish(customerNameSchema),
|
|
2521
2704
|
// Re-attest when changing a filler-looking name; the server clears the
|
|
2522
2705
|
// prior attestation whenever `customer_name` changes.
|
|
2523
|
-
customer_name_placeholder_confirmed:
|
|
2524
|
-
customer_phone:
|
|
2525
|
-
customer_email:
|
|
2706
|
+
customer_name_placeholder_confirmed: z4.optional(z4.boolean()),
|
|
2707
|
+
customer_phone: z4.nullish(customerPhoneSchema),
|
|
2708
|
+
customer_email: z4.nullish(customerEmailSchema),
|
|
2526
2709
|
// NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
|
|
2527
|
-
sms_consent:
|
|
2710
|
+
sms_consent: z4.optional(z4.boolean())
|
|
2528
2711
|
}).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
|
|
2529
2712
|
var TRACKING_RANGES = ["24h", "7d", "30d"];
|
|
2530
2713
|
var NAMED_RANGES = [
|
|
@@ -2551,118 +2734,6 @@ function phoneField(name, raw, country) {
|
|
|
2551
2734
|
return { name, type: "phone", value: toE164(raw, country) };
|
|
2552
2735
|
}
|
|
2553
2736
|
|
|
2554
|
-
// ../tracking-core/src/lead-forms/lead-forms.gen.ts
|
|
2555
|
-
var z4 = __toESM(require("zod/mini"));
|
|
2556
|
-
var LEAD_FORM_REGISTRY_VERSION = 1;
|
|
2557
|
-
var LEAD_FORM_KINDS = ["booking", "quote", "contact", "consult", "callback"];
|
|
2558
|
-
var LEAD_FORM_ROLES = [
|
|
2559
|
-
"given_name",
|
|
2560
|
-
"family_name",
|
|
2561
|
-
"phone",
|
|
2562
|
-
"email",
|
|
2563
|
-
"service",
|
|
2564
|
-
"preferred_date",
|
|
2565
|
-
"preferred_time",
|
|
2566
|
-
"note",
|
|
2567
|
-
"visit",
|
|
2568
|
-
"intent",
|
|
2569
|
-
"vehicle",
|
|
2570
|
-
"drop_off",
|
|
2571
|
-
"address",
|
|
2572
|
-
"patient_type",
|
|
2573
|
-
"matter",
|
|
2574
|
-
"language",
|
|
2575
|
-
"products",
|
|
2576
|
-
"goal",
|
|
2577
|
-
"business_type",
|
|
2578
|
-
"lead_volume",
|
|
2579
|
-
"attribution"
|
|
2580
|
-
];
|
|
2581
|
-
var LEAD_FORM_PRIMITIVES = [
|
|
2582
|
-
"string",
|
|
2583
|
-
"text",
|
|
2584
|
-
"enum",
|
|
2585
|
-
"multi_enum",
|
|
2586
|
-
"bool",
|
|
2587
|
-
"date",
|
|
2588
|
-
"time_window",
|
|
2589
|
-
"phone",
|
|
2590
|
-
"email",
|
|
2591
|
-
"address",
|
|
2592
|
-
"number"
|
|
2593
|
-
];
|
|
2594
|
-
var leadFormPrimitiveSchemas = {
|
|
2595
|
-
string: z4.string().check(z4.maxLength(120)),
|
|
2596
|
-
text: z4.string().check(z4.maxLength(2e3)),
|
|
2597
|
-
enum: z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/)),
|
|
2598
|
-
multi_enum: z4.array(z4.string().check(z4.regex(/^[a-z0-9-]{1,48}$/))).check(z4.maxLength(10)),
|
|
2599
|
-
bool: z4.boolean(),
|
|
2600
|
-
date: z4.string().check(z4.regex(/^\d{4}-\d{2}-\d{2}$/)),
|
|
2601
|
-
time_window: z4.strictObject({
|
|
2602
|
-
start: z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/)),
|
|
2603
|
-
end: z4.nullable(z4.string().check(z4.regex(/^([01]\d|2[0-3]):[0-5]\d$/))),
|
|
2604
|
-
label: z4.optional(z4.string().check(z4.maxLength(60)))
|
|
2605
|
-
}),
|
|
2606
|
-
phone: z4.string().check(z4.regex(/^\+[1-9]\d{6,14}$/)),
|
|
2607
|
-
email: z4.string().check(z4.maxLength(320), z4.regex(/^[^\s@]+@[^\s@]+$/)),
|
|
2608
|
-
address: z4.strictObject({
|
|
2609
|
-
line1: z4.string().check(z4.maxLength(120)),
|
|
2610
|
-
line2: z4.optional(z4.string().check(z4.maxLength(120))),
|
|
2611
|
-
city: z4.optional(z4.string().check(z4.maxLength(120))),
|
|
2612
|
-
region: z4.optional(z4.string().check(z4.maxLength(120))),
|
|
2613
|
-
postal_code: z4.optional(z4.string().check(z4.maxLength(120))),
|
|
2614
|
-
country: z4.optional(z4.string().check(z4.maxLength(120)))
|
|
2615
|
-
}),
|
|
2616
|
-
number: z4.number()
|
|
2617
|
-
};
|
|
2618
|
-
var LEAD_FORM_ROLE_SPECS = {
|
|
2619
|
-
given_name: { primitive: "string", smsLabel: "", contactIdentity: true },
|
|
2620
|
-
family_name: { primitive: "string", smsLabel: "", contactIdentity: true },
|
|
2621
|
-
phone: { primitive: "phone", smsLabel: "", contactIdentity: true },
|
|
2622
|
-
email: { primitive: "email", smsLabel: "", contactIdentity: true },
|
|
2623
|
-
service: { primitive: "enum", smsLabel: "Service" },
|
|
2624
|
-
preferred_date: { primitive: "date", smsLabel: "Date" },
|
|
2625
|
-
preferred_time: { primitive: "time_window", smsLabel: "Time" },
|
|
2626
|
-
note: { primitive: "text", smsLabel: "Note" },
|
|
2627
|
-
visit: {
|
|
2628
|
-
primitive: "enum",
|
|
2629
|
-
smsLabel: "Visit",
|
|
2630
|
-
options: [
|
|
2631
|
-
{ key: "in-shop", label: "In shop" },
|
|
2632
|
-
{ key: "in-home", label: "In home" },
|
|
2633
|
-
{ key: "remote", label: "Remote" },
|
|
2634
|
-
{ key: "on-site", label: "On site" }
|
|
2635
|
-
]
|
|
2636
|
-
},
|
|
2637
|
-
intent: {
|
|
2638
|
-
primitive: "enum",
|
|
2639
|
-
smsLabel: "Wants",
|
|
2640
|
-
options: [
|
|
2641
|
-
{ key: "book", label: "Book" },
|
|
2642
|
-
{ key: "quote", label: "Quote" }
|
|
2643
|
-
]
|
|
2644
|
-
},
|
|
2645
|
-
vehicle: { primitive: "string", smsLabel: "Vehicle" },
|
|
2646
|
-
drop_off: {
|
|
2647
|
-
primitive: "enum",
|
|
2648
|
-
smsLabel: "Drop-off",
|
|
2649
|
-
options: [
|
|
2650
|
-
{ key: "wait-for-it", label: "Waiting" },
|
|
2651
|
-
{ key: "drop-off", label: "Dropping off" }
|
|
2652
|
-
]
|
|
2653
|
-
},
|
|
2654
|
-
address: { primitive: "address", smsLabel: "Address" },
|
|
2655
|
-
patient_type: { primitive: "enum", smsLabel: "Patient" },
|
|
2656
|
-
matter: { primitive: "enum", smsLabel: "Matter" },
|
|
2657
|
-
language: { primitive: "enum", smsLabel: "Language" },
|
|
2658
|
-
products: { primitive: "multi_enum", smsLabel: "Products" },
|
|
2659
|
-
goal: { primitive: "enum", smsLabel: "Goal" },
|
|
2660
|
-
business_type: { primitive: "enum", smsLabel: "Business" },
|
|
2661
|
-
lead_volume: { primitive: "enum", smsLabel: "Lead volume" },
|
|
2662
|
-
add_on: { primitive: "bool", smsLabel: "" },
|
|
2663
|
-
attribution: { primitive: "enum", smsLabel: "", uninteresting: true }
|
|
2664
|
-
};
|
|
2665
|
-
|
|
2666
2737
|
// src/index.ts
|
|
2667
2738
|
var import_client2 = require("@aranova/tracking-react/client");
|
|
2668
2739
|
var import_client3 = require("@aranova/tracking-react/client");
|