@aranova/tracking-next 1.0.0 → 1.2.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 +48 -1
- package/dist/blog-server.js.map +1 -1
- package/dist/blog-server.mjs.map +1 -1
- package/dist/blog.js.map +1 -1
- package/dist/blog.mjs.map +1 -1
- package/dist/calendar-server.d.mts +1 -1
- package/dist/calendar-server.d.ts +1 -1
- package/dist/calendar-server.js.map +1 -1
- package/dist/calendar-server.mjs.map +1 -1
- package/dist/calendar.d.mts +14 -3
- package/dist/calendar.d.ts +14 -3
- package/dist/calendar.js +212 -18
- package/dist/calendar.js.map +1 -1
- package/dist/calendar.mjs +211 -18
- package/dist/calendar.mjs.map +1 -1
- package/dist/client.d.mts +9 -3
- package/dist/client.d.ts +9 -3
- package/dist/client.js +550 -194
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +550 -194
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +491 -284
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +490 -284
- package/dist/index.mjs.map +1 -1
- package/dist/{ingest-typed-BdKmlouW.d.ts → ingest-typed-MBuMe9Pn.d.ts} +94 -2
- package/dist/{ingest-typed-Bo7WPmpU.d.mts → ingest-typed-UA13xTfI.d.mts} +94 -2
- package/dist/{phone-utils-CubQif9Z.d.mts → phone-utils-C0ds6cqZ.d.mts} +6 -0
- package/dist/{phone-utils-CubQif9Z.d.ts → phone-utils-C0ds6cqZ.d.ts} +6 -0
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/{sales-DG150g3o.d.ts → sales-DQC815f3.d.ts} +1 -1
- package/dist/{sales-D7KstKA-.d.mts → sales-w1reW_Y3.d.mts} +1 -1
- package/dist/sales.d.mts +2 -2
- package/dist/sales.d.ts +2 -2
- package/dist/sales.js +17 -1
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +17 -1
- package/dist/sales.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/{tracking-config-runtime-D7prdTE1.d.mts → tracking-config-runtime-C6H7ofmo.d.mts} +6 -0
- package/dist/{tracking-config-runtime-D7prdTE1.d.ts → tracking-config-runtime-C6H7ofmo.d.ts} +6 -0
- package/dist/{transport-I_cMSFQ6.d.mts → transport-BlXQZs9Z.d.mts} +120 -50
- package/dist/{transport-CDmGOiCq.d.ts → transport-CAZYrZbB.d.ts} +120 -50
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -213,6 +213,7 @@ var TRACKING_CAPABILITIES = [
|
|
|
213
213
|
"consent_controls",
|
|
214
214
|
"conversion_goals_auto",
|
|
215
215
|
"conversion_goals_manual",
|
|
216
|
+
"cross_site_linker",
|
|
216
217
|
"cta_click_capture",
|
|
217
218
|
"form_capture",
|
|
218
219
|
"phone_click_capture",
|
|
@@ -239,6 +240,9 @@ function readDomMarkers() {
|
|
|
239
240
|
return found;
|
|
240
241
|
}
|
|
241
242
|
|
|
243
|
+
// ../tracking-core/src/cross-site-link.ts
|
|
244
|
+
import * as z from "zod/mini";
|
|
245
|
+
|
|
242
246
|
// ../tracking-core/src/tracking.ts
|
|
243
247
|
var TRACKING_COOKIE_MAX_AGE_SECONDS = 7776e3;
|
|
244
248
|
var TRACKING_PARAM_KEYS = [
|
|
@@ -483,6 +487,72 @@ function buildLandingPayloadFields(sessionId, override) {
|
|
|
483
487
|
};
|
|
484
488
|
}
|
|
485
489
|
|
|
490
|
+
// ../tracking-core/src/session.ts
|
|
491
|
+
var VISITOR_STORAGE_KEY = "aranova_tracking_visitor";
|
|
492
|
+
var SESSION_STORAGE_KEY = "aranova_tracking_session";
|
|
493
|
+
var SESSION_IDLE_MS = 30 * 60 * 1e3;
|
|
494
|
+
function readLocalStorage(key) {
|
|
495
|
+
try {
|
|
496
|
+
return window.localStorage.getItem(key);
|
|
497
|
+
} catch {
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function peekVisitorId() {
|
|
502
|
+
if (typeof window === "undefined") return null;
|
|
503
|
+
const existing = readLocalStorage(VISITOR_STORAGE_KEY);
|
|
504
|
+
return existing && existing.length > 0 ? existing : null;
|
|
505
|
+
}
|
|
506
|
+
function peekSessionId(now = Date.now()) {
|
|
507
|
+
if (typeof window === "undefined") return null;
|
|
508
|
+
const raw = readLocalStorage(SESSION_STORAGE_KEY);
|
|
509
|
+
if (!raw) return null;
|
|
510
|
+
try {
|
|
511
|
+
const parsed = JSON.parse(raw);
|
|
512
|
+
if (typeof parsed.id !== "string" || typeof parsed.last_event_at !== "number") return null;
|
|
513
|
+
return now - parsed.last_event_at <= SESSION_IDLE_MS ? parsed.id : null;
|
|
514
|
+
} catch {
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// ../tracking-core/src/cross-site-link.ts
|
|
520
|
+
var LINK_PARAM = "_arv";
|
|
521
|
+
var LINK_TOKEN_TTL_MS = 5 * 60 * 1e3;
|
|
522
|
+
var FUTURE_SKEW_MS = 60 * 1e3;
|
|
523
|
+
var CARRIED_KEYS = {
|
|
524
|
+
g: "gclid",
|
|
525
|
+
w: "wbraid",
|
|
526
|
+
gb: "gbraid",
|
|
527
|
+
f: "fbclid",
|
|
528
|
+
y: "ylpcid"
|
|
529
|
+
};
|
|
530
|
+
var CARRIED_ENTRIES = Object.entries(CARRIED_KEYS);
|
|
531
|
+
var identifier = z.string().check(z.minLength(1), z.maxLength(128));
|
|
532
|
+
var optionalIdentifier = z.optional(identifier);
|
|
533
|
+
var linkTokenSchema = z.object({
|
|
534
|
+
v: identifier,
|
|
535
|
+
s: identifier,
|
|
536
|
+
// Epoch ms in base36.
|
|
537
|
+
t: z.string().check(z.regex(/^[0-9a-z]{1,12}$/)),
|
|
538
|
+
g: optionalIdentifier,
|
|
539
|
+
w: optionalIdentifier,
|
|
540
|
+
gb: optionalIdentifier,
|
|
541
|
+
f: optionalIdentifier,
|
|
542
|
+
fc: optionalIdentifier,
|
|
543
|
+
y: optionalIdentifier
|
|
544
|
+
});
|
|
545
|
+
function stripLinkParam(url) {
|
|
546
|
+
try {
|
|
547
|
+
const parsed = new URL(url, typeof window === "undefined" ? void 0 : window.location.href);
|
|
548
|
+
if (!parsed.searchParams.has(LINK_PARAM)) return url;
|
|
549
|
+
parsed.searchParams.delete(LINK_PARAM);
|
|
550
|
+
return parsed.href;
|
|
551
|
+
} catch {
|
|
552
|
+
return url;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
486
556
|
// ../tracking-core/src/payloads.ts
|
|
487
557
|
function createTrackingClientContext(surface, input = {}) {
|
|
488
558
|
return {
|
|
@@ -522,6 +592,7 @@ function createTrackingSessionUpsertPayload(trackingParams, input, context) {
|
|
|
522
592
|
};
|
|
523
593
|
}
|
|
524
594
|
function createTrackingEventCreatePayload(trackingParams, input, context) {
|
|
595
|
+
const pageUrl = input.pageUrl ?? (typeof window === "undefined" ? null : window.location.href);
|
|
525
596
|
return {
|
|
526
597
|
session_id: input.sessionId,
|
|
527
598
|
event_type: input.eventType,
|
|
@@ -532,7 +603,7 @@ function createTrackingEventCreatePayload(trackingParams, input, context) {
|
|
|
532
603
|
fbclid: trackingParams.fbclid,
|
|
533
604
|
fbc: getFbcCookie(),
|
|
534
605
|
fbp: getFbpCookie(),
|
|
535
|
-
page_url:
|
|
606
|
+
page_url: pageUrl === null ? null : stripLinkParam(pageUrl),
|
|
536
607
|
metadata: input.metadata ?? null,
|
|
537
608
|
context
|
|
538
609
|
};
|
|
@@ -644,7 +715,8 @@ function parseConversionConfig(raw) {
|
|
|
644
715
|
gtag_ids: isStringMap(obj.gtag_ids) ? obj.gtag_ids : {},
|
|
645
716
|
meta_pixel_ids: isStringMap(obj.meta_pixel_ids) ? obj.meta_pixel_ids : {},
|
|
646
717
|
services,
|
|
647
|
-
goals
|
|
718
|
+
goals,
|
|
719
|
+
linked_hostnames: Array.isArray(obj.linked_hostnames) ? obj.linked_hostnames.filter((h) => typeof h === "string" && h.length > 0) : []
|
|
648
720
|
};
|
|
649
721
|
}
|
|
650
722
|
var CACHE_PREFIX = "_aranova_cfg_";
|
|
@@ -728,6 +800,7 @@ function resolveConversionConfig(options) {
|
|
|
728
800
|
getFiring: (key) => goalsByKey.get(key)?.firing ?? null,
|
|
729
801
|
getGoal: (key) => goalsByKey.get(key) ?? null,
|
|
730
802
|
listGoals: () => [...goalsByKey.values()],
|
|
803
|
+
linkedHostnames: () => current?.linked_hostnames ?? [],
|
|
731
804
|
current: () => current,
|
|
732
805
|
isReady: () => current !== null,
|
|
733
806
|
onResolve: (listener) => {
|
|
@@ -935,7 +1008,7 @@ function validateConfig(config, ref) {
|
|
|
935
1008
|
function pageViewSnapshot() {
|
|
936
1009
|
if (typeof window === "undefined" || typeof document === "undefined") return null;
|
|
937
1010
|
return {
|
|
938
|
-
href: window.location.href,
|
|
1011
|
+
href: stripLinkParam(window.location.href),
|
|
939
1012
|
title: document.title || null,
|
|
940
1013
|
referrer: document.referrer || null
|
|
941
1014
|
};
|
|
@@ -1086,6 +1159,10 @@ var TrackingConfigRuntime = class {
|
|
|
1086
1159
|
listGoals() {
|
|
1087
1160
|
return this.current?.goals ?? [];
|
|
1088
1161
|
}
|
|
1162
|
+
/** Sibling hostnames for the linker — read from the cached object even while unconfirmed. */
|
|
1163
|
+
linkedHostnames() {
|
|
1164
|
+
return this.current?.linked_hostnames ?? [];
|
|
1165
|
+
}
|
|
1089
1166
|
async revalidateNow() {
|
|
1090
1167
|
try {
|
|
1091
1168
|
const headers = {};
|
|
@@ -1329,6 +1406,18 @@ var EVENT_SEMANTICS = {
|
|
|
1329
1406
|
category: "engagement",
|
|
1330
1407
|
outcomeRole: "engagement",
|
|
1331
1408
|
clientVisibility: "simple"
|
|
1409
|
+
},
|
|
1410
|
+
site_link_click: {
|
|
1411
|
+
label: "Left for sibling site",
|
|
1412
|
+
category: "page",
|
|
1413
|
+
outcomeRole: "navigation",
|
|
1414
|
+
clientVisibility: "detailed"
|
|
1415
|
+
},
|
|
1416
|
+
site_link_arrival: {
|
|
1417
|
+
label: "Arrived from sibling site",
|
|
1418
|
+
category: "page",
|
|
1419
|
+
outcomeRole: "navigation",
|
|
1420
|
+
clientVisibility: "simple"
|
|
1332
1421
|
}
|
|
1333
1422
|
};
|
|
1334
1423
|
function getEventSemantics(eventName) {
|
|
@@ -1570,11 +1659,11 @@ function createSalesClient(config) {
|
|
|
1570
1659
|
}
|
|
1571
1660
|
|
|
1572
1661
|
// ../tracking-core/src/resources/sales/schema.ts
|
|
1573
|
-
import * as
|
|
1662
|
+
import * as z3 from "zod/mini";
|
|
1574
1663
|
|
|
1575
1664
|
// ../tracking-core/src/resources/sales/generated/zod.gen.ts
|
|
1576
|
-
import * as
|
|
1577
|
-
var zErrorCode =
|
|
1665
|
+
import * as z2 from "zod/mini";
|
|
1666
|
+
var zErrorCode = z2.enum([
|
|
1578
1667
|
"missing_credentials",
|
|
1579
1668
|
"invalid_api_key",
|
|
1580
1669
|
"not_authenticated",
|
|
@@ -1589,9 +1678,19 @@ var zErrorCode = z.enum([
|
|
|
1589
1678
|
"bad_request",
|
|
1590
1679
|
"not_found",
|
|
1591
1680
|
"conflict",
|
|
1681
|
+
"gone",
|
|
1592
1682
|
"incompatible_payload",
|
|
1593
1683
|
"repeat_confirmation_required",
|
|
1594
1684
|
"idempotency_conflict",
|
|
1685
|
+
"slot_unavailable",
|
|
1686
|
+
"calendar_not_connected",
|
|
1687
|
+
"calendar_disconnected",
|
|
1688
|
+
"booking_not_found",
|
|
1689
|
+
"booking_not_cancellable",
|
|
1690
|
+
"booking_not_reschedulable",
|
|
1691
|
+
"manage_token_invalid",
|
|
1692
|
+
"google_error",
|
|
1693
|
+
"calendar_not_owned",
|
|
1595
1694
|
"validation_error",
|
|
1596
1695
|
"unknown_service",
|
|
1597
1696
|
"invalid_sale_properties",
|
|
@@ -1599,36 +1698,36 @@ var zErrorCode = z.enum([
|
|
|
1599
1698
|
"rate_limited",
|
|
1600
1699
|
"internal_error"
|
|
1601
1700
|
]);
|
|
1602
|
-
var zSaleItemEntitySchema =
|
|
1603
|
-
category:
|
|
1604
|
-
external_item_id:
|
|
1605
|
-
id:
|
|
1606
|
-
name:
|
|
1607
|
-
quantity:
|
|
1608
|
-
unit_cost_cents:
|
|
1609
|
-
unit_price_cents:
|
|
1701
|
+
var zSaleItemEntitySchema = z2.object({
|
|
1702
|
+
category: z2.nullable(z2.string()),
|
|
1703
|
+
external_item_id: z2.nullable(z2.string()),
|
|
1704
|
+
id: z2.uuid(),
|
|
1705
|
+
name: z2.nullable(z2.string()),
|
|
1706
|
+
quantity: z2.string().check(z2.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
|
|
1707
|
+
unit_cost_cents: z2.nullable(z2.int()),
|
|
1708
|
+
unit_price_cents: z2.int()
|
|
1610
1709
|
});
|
|
1611
|
-
var zSaleItemInputSchema =
|
|
1612
|
-
category:
|
|
1613
|
-
external_item_id:
|
|
1614
|
-
name:
|
|
1615
|
-
quantity:
|
|
1616
|
-
unit_cost_cents:
|
|
1617
|
-
unit_price_cents:
|
|
1710
|
+
var zSaleItemInputSchema = z2.strictObject({
|
|
1711
|
+
category: z2.nullish(z2.string()),
|
|
1712
|
+
external_item_id: z2.nullish(z2.string()),
|
|
1713
|
+
name: z2.nullish(z2.string()),
|
|
1714
|
+
quantity: z2.string().check(z2.regex(/^\d+(\.\d{1,3})?$/)),
|
|
1715
|
+
unit_cost_cents: z2.nullish(z2.int().check(z2.gte(0))),
|
|
1716
|
+
unit_price_cents: z2.int().check(z2.gte(0))
|
|
1618
1717
|
});
|
|
1619
|
-
var zSaleServiceEntitySchema =
|
|
1620
|
-
amount_cents:
|
|
1621
|
-
id:
|
|
1622
|
-
mapped:
|
|
1623
|
-
service_id:
|
|
1624
|
-
service_key:
|
|
1625
|
-
service_label:
|
|
1718
|
+
var zSaleServiceEntitySchema = z2.object({
|
|
1719
|
+
amount_cents: z2.int(),
|
|
1720
|
+
id: z2.uuid(),
|
|
1721
|
+
mapped: z2.nullable(z2.boolean()),
|
|
1722
|
+
service_id: z2.uuid(),
|
|
1723
|
+
service_key: z2.string(),
|
|
1724
|
+
service_label: z2.string()
|
|
1626
1725
|
});
|
|
1627
|
-
var zSaleServiceInputSchema =
|
|
1628
|
-
amount_cents:
|
|
1629
|
-
service:
|
|
1726
|
+
var zSaleServiceInputSchema = z2.strictObject({
|
|
1727
|
+
amount_cents: z2.int().check(z2.gte(0)),
|
|
1728
|
+
service: z2.string()
|
|
1630
1729
|
});
|
|
1631
|
-
var zSmsAutomationState =
|
|
1730
|
+
var zSmsAutomationState = z2.enum([
|
|
1632
1731
|
"needs_check",
|
|
1633
1732
|
"failed",
|
|
1634
1733
|
"undelivered",
|
|
@@ -1640,7 +1739,7 @@ var zSmsAutomationState = z.enum([
|
|
|
1640
1739
|
"eligible",
|
|
1641
1740
|
"not_applicable"
|
|
1642
1741
|
]);
|
|
1643
|
-
var zSmsWithheldReason =
|
|
1742
|
+
var zSmsWithheldReason = z2.enum([
|
|
1644
1743
|
"automation_disabled",
|
|
1645
1744
|
"sms_disabled",
|
|
1646
1745
|
"no_phone",
|
|
@@ -1653,77 +1752,83 @@ var zSmsWithheldReason = z.enum([
|
|
|
1653
1752
|
"sender_not_ready",
|
|
1654
1753
|
"missing_review_url",
|
|
1655
1754
|
"no_handler",
|
|
1656
|
-
"dispatch_already_recorded"
|
|
1755
|
+
"dispatch_already_recorded",
|
|
1756
|
+
"text_back_disabled",
|
|
1757
|
+
"number_text_back_disabled",
|
|
1758
|
+
"number_not_active",
|
|
1759
|
+
"a2p_registration_required",
|
|
1760
|
+
"alert_recipient_cannot_receive_sms",
|
|
1761
|
+
"line_type_unresolved"
|
|
1657
1762
|
]);
|
|
1658
|
-
var zSaleSmsStatusSchema =
|
|
1659
|
-
can_send_now:
|
|
1660
|
-
last_message_at:
|
|
1661
|
-
reason_detail:
|
|
1763
|
+
var zSaleSmsStatusSchema = z2.object({
|
|
1764
|
+
can_send_now: z2._default(z2.boolean(), false),
|
|
1765
|
+
last_message_at: z2.nullable(z2.iso.datetime({ offset: true })),
|
|
1766
|
+
reason_detail: z2.nullable(z2.string()),
|
|
1662
1767
|
state: zSmsAutomationState,
|
|
1663
|
-
suppressed_by_other_sale:
|
|
1664
|
-
withheld_reason:
|
|
1768
|
+
suppressed_by_other_sale: z2._default(z2.boolean(), false),
|
|
1769
|
+
withheld_reason: z2.nullable(zSmsWithheldReason)
|
|
1665
1770
|
});
|
|
1666
|
-
var zSupportedCurrency =
|
|
1667
|
-
var zTrackingEnvironment =
|
|
1668
|
-
var zSaleCreateSchema =
|
|
1669
|
-
amount_total_cents:
|
|
1771
|
+
var zSupportedCurrency = z2.enum(["USD", "CAD"]);
|
|
1772
|
+
var zTrackingEnvironment = z2.enum(["production", "development"]);
|
|
1773
|
+
var zSaleCreateSchema = z2.strictObject({
|
|
1774
|
+
amount_total_cents: z2.nullish(z2.int().check(z2.gte(0))),
|
|
1670
1775
|
currency: zSupportedCurrency,
|
|
1671
|
-
customer_email:
|
|
1672
|
-
customer_name:
|
|
1673
|
-
customer_phone:
|
|
1674
|
-
description:
|
|
1675
|
-
environment:
|
|
1676
|
-
external_id:
|
|
1677
|
-
items:
|
|
1678
|
-
metadata:
|
|
1679
|
-
occurred_at:
|
|
1680
|
-
service:
|
|
1681
|
-
services:
|
|
1682
|
-
sms_consent:
|
|
1776
|
+
customer_email: z2.nullish(z2.email().check(z2.maxLength(320))),
|
|
1777
|
+
customer_name: z2.nullish(z2.string().check(z2.maxLength(200))),
|
|
1778
|
+
customer_phone: z2.nullish(z2.string().check(z2.maxLength(64))),
|
|
1779
|
+
description: z2.nullish(z2.string()),
|
|
1780
|
+
environment: z2._default(z2.optional(zTrackingEnvironment), "production"),
|
|
1781
|
+
external_id: z2.nullish(z2.string()),
|
|
1782
|
+
items: z2.optional(z2.array(zSaleItemInputSchema)),
|
|
1783
|
+
metadata: z2.nullish(z2.record(z2.string(), z2.unknown())),
|
|
1784
|
+
occurred_at: z2.iso.datetime({ offset: true }),
|
|
1785
|
+
service: z2.nullish(z2.string()),
|
|
1786
|
+
services: z2.nullish(z2.array(zSaleServiceInputSchema)),
|
|
1787
|
+
sms_consent: z2.nullish(z2.boolean())
|
|
1683
1788
|
});
|
|
1684
|
-
var zValidationError =
|
|
1685
|
-
ctx:
|
|
1686
|
-
input:
|
|
1687
|
-
loc:
|
|
1688
|
-
msg:
|
|
1689
|
-
type:
|
|
1789
|
+
var zValidationError = z2.object({
|
|
1790
|
+
ctx: z2.optional(z2.record(z2.string(), z2.unknown())),
|
|
1791
|
+
input: z2.optional(z2.unknown()),
|
|
1792
|
+
loc: z2.array(z2.union([z2.string(), z2.int()])),
|
|
1793
|
+
msg: z2.string(),
|
|
1794
|
+
type: z2.string()
|
|
1690
1795
|
});
|
|
1691
|
-
var zHttpValidationError =
|
|
1692
|
-
detail:
|
|
1796
|
+
var zHttpValidationError = z2.object({
|
|
1797
|
+
detail: z2.optional(z2.array(zValidationError))
|
|
1693
1798
|
});
|
|
1694
|
-
var zValidationErrorItem =
|
|
1695
|
-
loc:
|
|
1696
|
-
msg:
|
|
1697
|
-
type:
|
|
1799
|
+
var zValidationErrorItem = z2.object({
|
|
1800
|
+
loc: z2.array(z2.union([z2.string(), z2.int()])),
|
|
1801
|
+
msg: z2.string(),
|
|
1802
|
+
type: z2.string()
|
|
1698
1803
|
});
|
|
1699
|
-
var zApiErrorSchema =
|
|
1804
|
+
var zApiErrorSchema = z2.object({
|
|
1700
1805
|
code: zErrorCode,
|
|
1701
|
-
context:
|
|
1702
|
-
detail:
|
|
1703
|
-
errors:
|
|
1704
|
-
request_id:
|
|
1806
|
+
context: z2._default(z2.nullish(z2.record(z2.string(), z2.unknown())), null),
|
|
1807
|
+
detail: z2.string(),
|
|
1808
|
+
errors: z2._default(z2.nullish(z2.array(zValidationErrorItem)), null),
|
|
1809
|
+
request_id: z2._default(z2.nullish(z2.string()), null)
|
|
1705
1810
|
});
|
|
1706
|
-
var zWritebackEmailSource =
|
|
1707
|
-
var zWritebackEnrichmentStatus =
|
|
1708
|
-
var zWritebackSaleUploadCounts =
|
|
1709
|
-
failed:
|
|
1710
|
-
pending:
|
|
1711
|
-
skipped:
|
|
1712
|
-
submitted:
|
|
1713
|
-
total:
|
|
1714
|
-
uploaded:
|
|
1811
|
+
var zWritebackEmailSource = z2.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
|
|
1812
|
+
var zWritebackEnrichmentStatus = z2.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
|
|
1813
|
+
var zWritebackSaleUploadCounts = z2.object({
|
|
1814
|
+
failed: z2._default(z2.int(), 0),
|
|
1815
|
+
pending: z2._default(z2.int(), 0),
|
|
1816
|
+
skipped: z2._default(z2.int(), 0),
|
|
1817
|
+
submitted: z2._default(z2.int(), 0),
|
|
1818
|
+
total: z2._default(z2.int(), 0),
|
|
1819
|
+
uploaded: z2._default(z2.int(), 0)
|
|
1715
1820
|
});
|
|
1716
|
-
var zSaleWritebackStatusSchema =
|
|
1717
|
-
blocked_reason:
|
|
1718
|
-
can_dispatch:
|
|
1719
|
-
email_source:
|
|
1720
|
-
enrichment_status:
|
|
1721
|
-
gclid_attached:
|
|
1722
|
-
identifiers_sent:
|
|
1723
|
-
mapped_service_ids:
|
|
1724
|
-
matched_submit_count:
|
|
1725
|
-
needs_force:
|
|
1726
|
-
rollup:
|
|
1821
|
+
var zSaleWritebackStatusSchema = z2.object({
|
|
1822
|
+
blocked_reason: z2.nullable(z2.string()),
|
|
1823
|
+
can_dispatch: z2._default(z2.boolean(), false),
|
|
1824
|
+
email_source: z2.nullable(zWritebackEmailSource),
|
|
1825
|
+
enrichment_status: z2.nullable(zWritebackEnrichmentStatus),
|
|
1826
|
+
gclid_attached: z2._default(z2.boolean(), false),
|
|
1827
|
+
identifiers_sent: z2.nullable(z2.string()),
|
|
1828
|
+
mapped_service_ids: z2.array(z2.uuid()),
|
|
1829
|
+
matched_submit_count: z2.nullable(z2.int()),
|
|
1830
|
+
needs_force: z2._default(z2.boolean(), false),
|
|
1831
|
+
rollup: z2.enum([
|
|
1727
1832
|
"failed",
|
|
1728
1833
|
"skipped",
|
|
1729
1834
|
"pending",
|
|
@@ -1733,37 +1838,37 @@ var zSaleWritebackStatusSchema = z.object({
|
|
|
1733
1838
|
"out_of_window",
|
|
1734
1839
|
"blocked"
|
|
1735
1840
|
]),
|
|
1736
|
-
stale:
|
|
1737
|
-
uncovered_service_ids:
|
|
1841
|
+
stale: z2._default(z2.boolean(), false),
|
|
1842
|
+
uncovered_service_ids: z2.array(z2.uuid()),
|
|
1738
1843
|
uploads: zWritebackSaleUploadCounts
|
|
1739
1844
|
});
|
|
1740
|
-
var zSaleEntitySchema =
|
|
1741
|
-
amount_total_cents:
|
|
1742
|
-
business_id:
|
|
1743
|
-
business_name:
|
|
1744
|
-
created_at:
|
|
1745
|
-
currency:
|
|
1746
|
-
customer_email:
|
|
1747
|
-
customer_name:
|
|
1748
|
-
customer_name_placeholder_confirmed:
|
|
1749
|
-
customer_name_placeholder_confirmed_at:
|
|
1750
|
-
customer_phone:
|
|
1751
|
-
description:
|
|
1845
|
+
var zSaleEntitySchema = z2.object({
|
|
1846
|
+
amount_total_cents: z2.int(),
|
|
1847
|
+
business_id: z2.uuid(),
|
|
1848
|
+
business_name: z2.nullable(z2.string()),
|
|
1849
|
+
created_at: z2.iso.datetime({ offset: true }),
|
|
1850
|
+
currency: z2.string(),
|
|
1851
|
+
customer_email: z2.nullable(z2.string()),
|
|
1852
|
+
customer_name: z2.nullable(z2.string()),
|
|
1853
|
+
customer_name_placeholder_confirmed: z2._default(z2.boolean(), false),
|
|
1854
|
+
customer_name_placeholder_confirmed_at: z2.nullable(z2.iso.datetime({ offset: true })),
|
|
1855
|
+
customer_phone: z2.nullable(z2.string()),
|
|
1856
|
+
description: z2.nullable(z2.string()),
|
|
1752
1857
|
environment: zTrackingEnvironment,
|
|
1753
|
-
external_id:
|
|
1754
|
-
id:
|
|
1755
|
-
items:
|
|
1756
|
-
metadata:
|
|
1757
|
-
occurred_at:
|
|
1758
|
-
service_id:
|
|
1759
|
-
service_key:
|
|
1760
|
-
service_label:
|
|
1761
|
-
services:
|
|
1762
|
-
sms_automation:
|
|
1763
|
-
sms_consent:
|
|
1764
|
-
sms_consent_granted_at:
|
|
1765
|
-
updated_at:
|
|
1766
|
-
writeback:
|
|
1858
|
+
external_id: z2.nullable(z2.string()),
|
|
1859
|
+
id: z2.uuid(),
|
|
1860
|
+
items: z2.array(zSaleItemEntitySchema),
|
|
1861
|
+
metadata: z2.nullable(z2.record(z2.string(), z2.unknown())),
|
|
1862
|
+
occurred_at: z2.iso.datetime({ offset: true }),
|
|
1863
|
+
service_id: z2.nullable(z2.uuid()),
|
|
1864
|
+
service_key: z2.nullable(z2.string()),
|
|
1865
|
+
service_label: z2.nullable(z2.string()),
|
|
1866
|
+
services: z2.array(zSaleServiceEntitySchema),
|
|
1867
|
+
sms_automation: z2.nullable(zSaleSmsStatusSchema),
|
|
1868
|
+
sms_consent: z2._default(z2.boolean(), false),
|
|
1869
|
+
sms_consent_granted_at: z2.nullable(z2.iso.datetime({ offset: true })),
|
|
1870
|
+
updated_at: z2.iso.datetime({ offset: true }),
|
|
1871
|
+
writeback: z2.nullable(zSaleWritebackStatusSchema)
|
|
1767
1872
|
});
|
|
1768
1873
|
|
|
1769
1874
|
// ../tracking-core/src/resources/sales/schema.ts
|
|
@@ -1771,11 +1876,11 @@ var saleItemSchema = zSaleItemInputSchema;
|
|
|
1771
1876
|
var saleServiceSchema = zSaleServiceInputSchema;
|
|
1772
1877
|
var currencySchema = zSupportedCurrency;
|
|
1773
1878
|
var SUPPORTED_CURRENCIES = currencySchema.options;
|
|
1774
|
-
var centsSchema =
|
|
1775
|
-
var metadataSchema =
|
|
1776
|
-
var customerNameSchema =
|
|
1777
|
-
var customerPhoneSchema =
|
|
1778
|
-
var customerEmailSchema =
|
|
1879
|
+
var centsSchema = z3.int().check(z3.gte(0));
|
|
1880
|
+
var metadataSchema = z3.record(z3.string(), z3.unknown());
|
|
1881
|
+
var customerNameSchema = z3.string().check(z3.maxLength(200));
|
|
1882
|
+
var customerPhoneSchema = z3.string().check(z3.maxLength(64));
|
|
1883
|
+
var customerEmailSchema = z3.email().check(z3.maxLength(320));
|
|
1779
1884
|
function addIssue(ctx, path, message) {
|
|
1780
1885
|
ctx.issues.push({ code: "custom", input: ctx.value, path, message });
|
|
1781
1886
|
}
|
|
@@ -1809,24 +1914,24 @@ function refineServiceXor(val, ctx, { requireAmount }) {
|
|
|
1809
1914
|
);
|
|
1810
1915
|
}
|
|
1811
1916
|
}
|
|
1812
|
-
var saleCreateSchema =
|
|
1813
|
-
var saleUpdateSchema =
|
|
1814
|
-
description:
|
|
1815
|
-
service:
|
|
1816
|
-
services:
|
|
1817
|
-
currency:
|
|
1818
|
-
amount_total_cents:
|
|
1819
|
-
occurred_at:
|
|
1820
|
-
items:
|
|
1821
|
-
metadata:
|
|
1822
|
-
customer_name:
|
|
1917
|
+
var saleCreateSchema = z3.extend(zSaleCreateSchema, { items: z3._default(z3.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
|
|
1918
|
+
var saleUpdateSchema = z3.strictObject({
|
|
1919
|
+
description: z3.nullish(z3.string()),
|
|
1920
|
+
service: z3.nullish(z3.string()),
|
|
1921
|
+
services: z3.nullish(z3.array(saleServiceSchema)),
|
|
1922
|
+
currency: z3.optional(currencySchema),
|
|
1923
|
+
amount_total_cents: z3.optional(centsSchema),
|
|
1924
|
+
occurred_at: z3.optional(z3.iso.datetime()),
|
|
1925
|
+
items: z3.optional(z3.array(saleItemSchema)),
|
|
1926
|
+
metadata: z3.nullish(metadataSchema),
|
|
1927
|
+
customer_name: z3.nullish(customerNameSchema),
|
|
1823
1928
|
// Re-attest when changing a filler-looking name; the server clears the
|
|
1824
1929
|
// prior attestation whenever `customer_name` changes.
|
|
1825
|
-
customer_name_placeholder_confirmed:
|
|
1826
|
-
customer_phone:
|
|
1827
|
-
customer_email:
|
|
1930
|
+
customer_name_placeholder_confirmed: z3.optional(z3.boolean()),
|
|
1931
|
+
customer_phone: z3.nullish(customerPhoneSchema),
|
|
1932
|
+
customer_email: z3.nullish(customerEmailSchema),
|
|
1828
1933
|
// NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
|
|
1829
|
-
sms_consent:
|
|
1934
|
+
sms_consent: z3.optional(z3.boolean())
|
|
1830
1935
|
}).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
|
|
1831
1936
|
var TRACKING_RANGES = ["24h", "7d", "30d"];
|
|
1832
1937
|
var NAMED_RANGES = [
|
|
@@ -1866,6 +1971,40 @@ import {
|
|
|
1866
1971
|
useTrackingParams
|
|
1867
1972
|
} from "@aranova/tracking-next/client";
|
|
1868
1973
|
|
|
1974
|
+
// ../tracking-core/src/resources/calendar/attribution.ts
|
|
1975
|
+
var LIMITS = {
|
|
1976
|
+
session_id: 64,
|
|
1977
|
+
visitor_id: 64,
|
|
1978
|
+
gclid: 256,
|
|
1979
|
+
fbclid: 256,
|
|
1980
|
+
utm_source: 128,
|
|
1981
|
+
utm_medium: 128,
|
|
1982
|
+
utm_campaign: 128,
|
|
1983
|
+
utm_term: 128,
|
|
1984
|
+
utm_content: 128
|
|
1985
|
+
};
|
|
1986
|
+
function getBookingAttribution() {
|
|
1987
|
+
if (typeof window === "undefined") return {};
|
|
1988
|
+
const params = getTrackingParamsFromCookieReader(getCookieValueFromDocument);
|
|
1989
|
+
const values = {
|
|
1990
|
+
session_id: peekSessionId(),
|
|
1991
|
+
visitor_id: peekVisitorId(),
|
|
1992
|
+
gclid: params.gclid,
|
|
1993
|
+
fbclid: params.fbclid,
|
|
1994
|
+
utm_source: params.utm_source,
|
|
1995
|
+
utm_medium: params.utm_medium,
|
|
1996
|
+
utm_campaign: params.utm_campaign,
|
|
1997
|
+
utm_term: params.utm_term,
|
|
1998
|
+
utm_content: params.utm_content
|
|
1999
|
+
};
|
|
2000
|
+
const attribution = {};
|
|
2001
|
+
for (const key of Object.keys(LIMITS)) {
|
|
2002
|
+
const value = values[key];
|
|
2003
|
+
if (value) attribution[key] = value.slice(0, LIMITS[key]);
|
|
2004
|
+
}
|
|
2005
|
+
return attribution;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
1869
2008
|
// ../tracking-core/src/resources/calendar/transport.ts
|
|
1870
2009
|
async function calendarRequest(config, method, path, body) {
|
|
1871
2010
|
return apiRequest(config, method, `/calendar${path}`, body);
|
|
@@ -1964,80 +2103,119 @@ function isCalendarError(error, code) {
|
|
|
1964
2103
|
}
|
|
1965
2104
|
|
|
1966
2105
|
// ../tracking-core/src/resources/calendar/schema.ts
|
|
1967
|
-
import * as
|
|
2106
|
+
import * as z5 from "zod/mini";
|
|
1968
2107
|
|
|
1969
2108
|
// ../tracking-core/src/resources/calendar/generated/zod.gen.ts
|
|
1970
|
-
import * as
|
|
1971
|
-
var zBookingAttendee =
|
|
1972
|
-
display_name:
|
|
1973
|
-
email:
|
|
1974
|
-
optional:
|
|
2109
|
+
import * as z4 from "zod/mini";
|
|
2110
|
+
var zBookingAttendee = z4.strictObject({
|
|
2111
|
+
display_name: z4.nullish(z4.string().check(z4.maxLength(200))),
|
|
2112
|
+
email: z4.email().check(z4.maxLength(320)),
|
|
2113
|
+
optional: z4._default(z4.optional(z4.boolean()), false)
|
|
1975
2114
|
});
|
|
1976
|
-
var zBookingCancelSchema =
|
|
1977
|
-
notify_attendees:
|
|
1978
|
-
reason:
|
|
2115
|
+
var zBookingCancelSchema = z4.strictObject({
|
|
2116
|
+
notify_attendees: z4._default(z4.optional(z4.boolean()), true),
|
|
2117
|
+
reason: z4.nullish(z4.string().check(z4.maxLength(500)))
|
|
1979
2118
|
});
|
|
1980
|
-
var zBookingCustomerInput =
|
|
1981
|
-
email:
|
|
1982
|
-
name:
|
|
1983
|
-
phone:
|
|
1984
|
-
sms_consent:
|
|
2119
|
+
var zBookingCustomerInput = z4.strictObject({
|
|
2120
|
+
email: z4.email().check(z4.maxLength(320)),
|
|
2121
|
+
name: z4.nullish(z4.string().check(z4.maxLength(200))),
|
|
2122
|
+
phone: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2123
|
+
sms_consent: z4._default(z4.optional(z4.boolean()), false)
|
|
1985
2124
|
});
|
|
1986
|
-
var zBookingCustomerOutput =
|
|
1987
|
-
email:
|
|
1988
|
-
name:
|
|
1989
|
-
phone:
|
|
1990
|
-
sms_consent:
|
|
2125
|
+
var zBookingCustomerOutput = z4.strictObject({
|
|
2126
|
+
email: z4.email().check(z4.maxLength(320)),
|
|
2127
|
+
name: z4.nullable(z4.string().check(z4.maxLength(200))),
|
|
2128
|
+
phone: z4.nullable(z4.string().check(z4.maxLength(64))),
|
|
2129
|
+
sms_consent: z4._default(z4.boolean(), false)
|
|
1991
2130
|
});
|
|
1992
|
-
var zBookingRescheduleSchema =
|
|
1993
|
-
duration_minutes:
|
|
1994
|
-
end_at:
|
|
1995
|
-
notify_attendees:
|
|
1996
|
-
reason:
|
|
1997
|
-
start_at:
|
|
1998
|
-
time_zone:
|
|
2131
|
+
var zBookingRescheduleSchema = z4.strictObject({
|
|
2132
|
+
duration_minutes: z4.nullish(z4.int().check(z4.gt(0), z4.lte(1440))),
|
|
2133
|
+
end_at: z4.nullish(z4.iso.datetime({ offset: true })),
|
|
2134
|
+
notify_attendees: z4._default(z4.optional(z4.boolean()), true),
|
|
2135
|
+
reason: z4.nullish(z4.string().check(z4.maxLength(500))),
|
|
2136
|
+
start_at: z4.iso.datetime({ offset: true }),
|
|
2137
|
+
time_zone: z4.string().check(z4.minLength(1), z4.maxLength(64), z4.regex(/^[A-Za-z0-9_+\-\/]+$/))
|
|
1999
2138
|
});
|
|
2000
|
-
var zBookingResponse =
|
|
2001
|
-
|
|
2002
|
-
|
|
2139
|
+
var zBookingResponse = z4.strictObject({
|
|
2140
|
+
all_day: z4.boolean(),
|
|
2141
|
+
appointment_type: z4.nullable(z4.string()),
|
|
2142
|
+
calendar_key: z4.string(),
|
|
2143
|
+
created_at: z4.iso.datetime({ offset: true }),
|
|
2003
2144
|
customer: zBookingCustomerOutput,
|
|
2004
|
-
end_at:
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2145
|
+
end_at: z4.iso.datetime({ offset: true }),
|
|
2146
|
+
google_event_id: z4.nullable(z4.string()),
|
|
2147
|
+
google_html_link: z4.nullable(z4.string()),
|
|
2148
|
+
google_sync_state: z4.enum(["queued", "synced", "uncertain", "failed", "drifted"]),
|
|
2149
|
+
ical_uid: z4.nullable(z4.string()),
|
|
2150
|
+
id: z4.string(),
|
|
2151
|
+
manage_token: z4.nullable(z4.string()),
|
|
2152
|
+
meet_url: z4.nullable(z4.string()),
|
|
2153
|
+
organizer_email: z4.nullable(z4.string()),
|
|
2154
|
+
start_at: z4.iso.datetime({ offset: true }),
|
|
2155
|
+
status: z4.enum(["pending", "confirmed", "cancelled", "no_show"]),
|
|
2156
|
+
time_zone: z4.string(),
|
|
2157
|
+
title: z4.string()
|
|
2014
2158
|
});
|
|
2015
|
-
var zBookingSource =
|
|
2016
|
-
var
|
|
2017
|
-
custom:
|
|
2018
|
-
|
|
2159
|
+
var zBookingSource = z4.enum(["website", "phone", "walk_in", "import", "operator"]);
|
|
2160
|
+
var zBookingMetadataInput = z4.strictObject({
|
|
2161
|
+
custom: z4.nullish(
|
|
2162
|
+
z4.record(z4.string(), z4.nullable(z4.union([z4.string(), z4.int(), z4.number(), z4.boolean()])))
|
|
2019
2163
|
),
|
|
2020
|
-
fbclid:
|
|
2021
|
-
gclid:
|
|
2022
|
-
landing_page:
|
|
2023
|
-
notes:
|
|
2024
|
-
referrer:
|
|
2025
|
-
schema_version:
|
|
2026
|
-
service:
|
|
2027
|
-
session_id:
|
|
2028
|
-
source:
|
|
2029
|
-
utm_campaign:
|
|
2030
|
-
utm_content:
|
|
2031
|
-
utm_medium:
|
|
2032
|
-
utm_source:
|
|
2033
|
-
utm_term:
|
|
2034
|
-
visitor_id:
|
|
2164
|
+
fbclid: z4.nullish(z4.string().check(z4.maxLength(256))),
|
|
2165
|
+
gclid: z4.nullish(z4.string().check(z4.maxLength(256))),
|
|
2166
|
+
landing_page: z4.nullish(z4.string().check(z4.maxLength(2048))),
|
|
2167
|
+
notes: z4.nullish(z4.string().check(z4.maxLength(2e3))),
|
|
2168
|
+
referrer: z4.nullish(z4.string().check(z4.maxLength(2048))),
|
|
2169
|
+
schema_version: z4._default(z4.optional(z4.int()), 1),
|
|
2170
|
+
service: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2171
|
+
session_id: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2172
|
+
source: z4.nullish(zBookingSource),
|
|
2173
|
+
utm_campaign: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2174
|
+
utm_content: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2175
|
+
utm_medium: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2176
|
+
utm_source: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2177
|
+
utm_term: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2178
|
+
visitor_id: z4.nullish(z4.string().check(z4.maxLength(64)))
|
|
2035
2179
|
});
|
|
2036
|
-
var
|
|
2037
|
-
|
|
2038
|
-
|
|
2180
|
+
var zBusySource = z4.enum(["google", "booking"]);
|
|
2181
|
+
var zBusyInterval = z4.strictObject({
|
|
2182
|
+
end_at: z4.iso.datetime({ offset: true }),
|
|
2183
|
+
source: zBusySource,
|
|
2184
|
+
start_at: z4.iso.datetime({ offset: true })
|
|
2039
2185
|
});
|
|
2040
|
-
var
|
|
2186
|
+
var zBusyWindow = z4.strictObject({
|
|
2187
|
+
since: z4.iso.datetime({ offset: true }),
|
|
2188
|
+
until: z4.iso.datetime({ offset: true })
|
|
2189
|
+
});
|
|
2190
|
+
var zBusyResponse = z4.strictObject({
|
|
2191
|
+
busy: z4.array(zBusyInterval),
|
|
2192
|
+
calendar_key: z4.string(),
|
|
2193
|
+
generated_at: z4.iso.datetime({ offset: true }),
|
|
2194
|
+
time_zone: z4.string(),
|
|
2195
|
+
window: zBusyWindow
|
|
2196
|
+
});
|
|
2197
|
+
var zCalendarSummary = z4.strictObject({
|
|
2198
|
+
allow_overlaps: z4.boolean(),
|
|
2199
|
+
calendar_key: z4.string(),
|
|
2200
|
+
connected_at: z4.nullable(z4.iso.datetime({ offset: true })),
|
|
2201
|
+
google_account_email: z4.nullable(z4.string()),
|
|
2202
|
+
granted_scopes: z4.nullable(z4.array(z4.string())),
|
|
2203
|
+
label: z4.string(),
|
|
2204
|
+
status: z4.enum([
|
|
2205
|
+
"pending_invite",
|
|
2206
|
+
"awaiting_calendar_selection",
|
|
2207
|
+
"connected",
|
|
2208
|
+
"needs_reconnect",
|
|
2209
|
+
"revoked",
|
|
2210
|
+
"disabled"
|
|
2211
|
+
]),
|
|
2212
|
+
time_zone: z4.string()
|
|
2213
|
+
});
|
|
2214
|
+
var zCustomLocation = z4.strictObject({
|
|
2215
|
+
kind: z4.literal("custom"),
|
|
2216
|
+
text: z4.string().check(z4.maxLength(1024))
|
|
2217
|
+
});
|
|
2218
|
+
var zErrorCode2 = z4.enum([
|
|
2041
2219
|
"missing_credentials",
|
|
2042
2220
|
"invalid_api_key",
|
|
2043
2221
|
"not_authenticated",
|
|
@@ -2052,9 +2230,19 @@ var zErrorCode2 = z3.enum([
|
|
|
2052
2230
|
"bad_request",
|
|
2053
2231
|
"not_found",
|
|
2054
2232
|
"conflict",
|
|
2233
|
+
"gone",
|
|
2055
2234
|
"incompatible_payload",
|
|
2056
2235
|
"repeat_confirmation_required",
|
|
2057
2236
|
"idempotency_conflict",
|
|
2237
|
+
"slot_unavailable",
|
|
2238
|
+
"calendar_not_connected",
|
|
2239
|
+
"calendar_disconnected",
|
|
2240
|
+
"booking_not_found",
|
|
2241
|
+
"booking_not_cancellable",
|
|
2242
|
+
"booking_not_reschedulable",
|
|
2243
|
+
"manage_token_invalid",
|
|
2244
|
+
"google_error",
|
|
2245
|
+
"calendar_not_owned",
|
|
2058
2246
|
"validation_error",
|
|
2059
2247
|
"unknown_service",
|
|
2060
2248
|
"invalid_sale_properties",
|
|
@@ -2062,66 +2250,67 @@ var zErrorCode2 = z3.enum([
|
|
|
2062
2250
|
"rate_limited",
|
|
2063
2251
|
"internal_error"
|
|
2064
2252
|
]);
|
|
2065
|
-
var zMeetLocation =
|
|
2066
|
-
kind:
|
|
2253
|
+
var zMeetLocation = z4.strictObject({
|
|
2254
|
+
kind: z4.literal("google_meet")
|
|
2067
2255
|
});
|
|
2068
|
-
var zPhoneLocation =
|
|
2069
|
-
kind:
|
|
2070
|
-
phone:
|
|
2256
|
+
var zPhoneLocation = z4.strictObject({
|
|
2257
|
+
kind: z4.literal("phone"),
|
|
2258
|
+
phone: z4.string().check(z4.maxLength(64))
|
|
2071
2259
|
});
|
|
2072
|
-
var zPhysicalLocation =
|
|
2073
|
-
address:
|
|
2074
|
-
kind:
|
|
2260
|
+
var zPhysicalLocation = z4.strictObject({
|
|
2261
|
+
address: z4.string().check(z4.maxLength(1024)),
|
|
2262
|
+
kind: z4.literal("physical")
|
|
2075
2263
|
});
|
|
2076
|
-
var zReminderMethod =
|
|
2077
|
-
var zBookingReminder =
|
|
2264
|
+
var zReminderMethod = z4.enum(["email", "popup"]);
|
|
2265
|
+
var zBookingReminder = z4.strictObject({
|
|
2078
2266
|
method: zReminderMethod,
|
|
2079
|
-
minutes_before:
|
|
2267
|
+
minutes_before: z4.int().check(z4.gte(0), z4.lte(40320))
|
|
2080
2268
|
});
|
|
2081
|
-
var zBookingReminders =
|
|
2082
|
-
overrides:
|
|
2083
|
-
use_calendar_defaults:
|
|
2269
|
+
var zBookingReminders = z4.strictObject({
|
|
2270
|
+
overrides: z4.optional(z4.array(zBookingReminder).check(z4.maxLength(5))),
|
|
2271
|
+
use_calendar_defaults: z4._default(z4.optional(z4.boolean()), true)
|
|
2084
2272
|
});
|
|
2085
|
-
var zBookingCreateSchema =
|
|
2086
|
-
appointment_type:
|
|
2087
|
-
attendees:
|
|
2088
|
-
buffer_after_minutes:
|
|
2089
|
-
buffer_before_minutes:
|
|
2090
|
-
calendar_key:
|
|
2273
|
+
var zBookingCreateSchema = z4.strictObject({
|
|
2274
|
+
appointment_type: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2275
|
+
attendees: z4.optional(z4.array(zBookingAttendee).check(z4.maxLength(20))),
|
|
2276
|
+
buffer_after_minutes: z4._default(z4.optional(z4.int().check(z4.gte(0), z4.lte(1440))), 0),
|
|
2277
|
+
buffer_before_minutes: z4._default(z4.optional(z4.int().check(z4.gte(0), z4.lte(1440))), 0),
|
|
2278
|
+
calendar_key: z4.string().check(z4.minLength(1), z4.maxLength(64)),
|
|
2091
2279
|
customer: zBookingCustomerInput,
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2280
|
+
date: z4.nullish(z4.iso.date()),
|
|
2281
|
+
description: z4.nullish(z4.string().check(z4.maxLength(8e3))),
|
|
2282
|
+
duration_minutes: z4.nullish(z4.int().check(z4.gt(0), z4.lte(1440))),
|
|
2283
|
+
end_at: z4.nullish(z4.iso.datetime({ offset: true })),
|
|
2284
|
+
idempotency_key: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2285
|
+
location: z4.nullish(z4.union([zMeetLocation, zPhysicalLocation, zPhoneLocation, zCustomLocation])),
|
|
2286
|
+
metadata: z4.nullish(zBookingMetadataInput),
|
|
2287
|
+
reminders: z4.nullish(zBookingReminders),
|
|
2288
|
+
send_invites: z4._default(z4.optional(z4.boolean()), true),
|
|
2289
|
+
start_at: z4.nullish(z4.iso.datetime({ offset: true })),
|
|
2290
|
+
time_zone: z4.string().check(z4.minLength(1), z4.maxLength(64), z4.regex(/^[A-Za-z0-9_+\-\/]+$/)),
|
|
2291
|
+
title: z4.nullish(z4.string().check(z4.maxLength(300)))
|
|
2103
2292
|
});
|
|
2104
|
-
var zValidationError2 =
|
|
2105
|
-
ctx:
|
|
2106
|
-
input:
|
|
2107
|
-
loc:
|
|
2108
|
-
msg:
|
|
2109
|
-
type:
|
|
2293
|
+
var zValidationError2 = z4.object({
|
|
2294
|
+
ctx: z4.optional(z4.record(z4.string(), z4.unknown())),
|
|
2295
|
+
input: z4.optional(z4.unknown()),
|
|
2296
|
+
loc: z4.array(z4.union([z4.string(), z4.int()])),
|
|
2297
|
+
msg: z4.string(),
|
|
2298
|
+
type: z4.string()
|
|
2110
2299
|
});
|
|
2111
|
-
var zHttpValidationError2 =
|
|
2112
|
-
detail:
|
|
2300
|
+
var zHttpValidationError2 = z4.object({
|
|
2301
|
+
detail: z4.optional(z4.array(zValidationError2))
|
|
2113
2302
|
});
|
|
2114
|
-
var zValidationErrorItem2 =
|
|
2115
|
-
loc:
|
|
2116
|
-
msg:
|
|
2117
|
-
type:
|
|
2303
|
+
var zValidationErrorItem2 = z4.object({
|
|
2304
|
+
loc: z4.array(z4.union([z4.string(), z4.int()])),
|
|
2305
|
+
msg: z4.string(),
|
|
2306
|
+
type: z4.string()
|
|
2118
2307
|
});
|
|
2119
|
-
var zApiErrorSchema2 =
|
|
2308
|
+
var zApiErrorSchema2 = z4.object({
|
|
2120
2309
|
code: zErrorCode2,
|
|
2121
|
-
context:
|
|
2122
|
-
detail:
|
|
2123
|
-
errors:
|
|
2124
|
-
request_id:
|
|
2310
|
+
context: z4._default(z4.nullish(z4.record(z4.string(), z4.unknown())), null),
|
|
2311
|
+
detail: z4.string(),
|
|
2312
|
+
errors: z4._default(z4.nullish(z4.array(zValidationErrorItem2)), null),
|
|
2313
|
+
request_id: z4._default(z4.nullish(z4.string()), null)
|
|
2125
2314
|
});
|
|
2126
2315
|
|
|
2127
2316
|
// ../tracking-core/src/resources/calendar/schema.ts
|
|
@@ -2131,22 +2320,17 @@ var MAX_REMINDER_OVERRIDES = 5;
|
|
|
2131
2320
|
var MAX_REMINDER_MINUTES = 40320;
|
|
2132
2321
|
var MAX_BOOKING_MINUTES = 1440;
|
|
2133
2322
|
var BOOKING_SOURCES = ["website", "phone", "walk_in", "import", "operator"];
|
|
2134
|
-
var BOOKING_STATUSES =
|
|
2135
|
-
var GOOGLE_SYNC_STATES =
|
|
2136
|
-
var CALENDAR_SYNC_STATUSES =
|
|
2137
|
-
"pending_invite",
|
|
2138
|
-
"awaiting_calendar_selection",
|
|
2139
|
-
"connected",
|
|
2140
|
-
"needs_reconnect",
|
|
2141
|
-
"revoked",
|
|
2142
|
-
"disabled"
|
|
2143
|
-
];
|
|
2323
|
+
var BOOKING_STATUSES = zBookingResponse.shape.status.options;
|
|
2324
|
+
var GOOGLE_SYNC_STATES = zBookingResponse.shape.google_sync_state.options;
|
|
2325
|
+
var CALENDAR_SYNC_STATUSES = zCalendarSummary.shape.status.options;
|
|
2144
2326
|
var CALENDAR_ERROR_CODES = [
|
|
2145
2327
|
"slot_unavailable",
|
|
2146
2328
|
"calendar_not_connected",
|
|
2147
2329
|
"calendar_disconnected",
|
|
2148
2330
|
"booking_not_found",
|
|
2149
|
-
"
|
|
2331
|
+
"booking_not_cancellable",
|
|
2332
|
+
"booking_not_reschedulable",
|
|
2333
|
+
"manage_token_invalid",
|
|
2150
2334
|
"rate_limited",
|
|
2151
2335
|
"google_error"
|
|
2152
2336
|
];
|
|
@@ -2158,29 +2342,29 @@ function isKnownTimeZone(timeZone) {
|
|
|
2158
2342
|
return false;
|
|
2159
2343
|
}
|
|
2160
2344
|
}
|
|
2161
|
-
var ianaTz =
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2345
|
+
var ianaTz = z5.string().check(
|
|
2346
|
+
z5.minLength(1),
|
|
2347
|
+
z5.maxLength(64),
|
|
2348
|
+
z5.regex(/^[A-Za-z0-9_+\-/]+$/),
|
|
2349
|
+
z5.refine(isKnownTimeZone, { error: "unknown IANA time zone" })
|
|
2166
2350
|
);
|
|
2167
2351
|
var bookingAttendeeSchema = zBookingAttendee;
|
|
2168
2352
|
var bookingReminderSchema = zBookingReminder;
|
|
2169
2353
|
var bookingCustomerSchema = zBookingCustomerInput;
|
|
2170
|
-
var bookingMetadataSchema =
|
|
2171
|
-
custom:
|
|
2172
|
-
|
|
2354
|
+
var bookingMetadataSchema = z5.extend(zBookingMetadataInput, {
|
|
2355
|
+
custom: z5.nullish(
|
|
2356
|
+
z5.record(z5.string(), z5.union([z5.string(), z5.int(), z5.number(), z5.boolean(), z5.null()]))
|
|
2173
2357
|
)
|
|
2174
2358
|
});
|
|
2175
|
-
var bookingLocationSchema =
|
|
2359
|
+
var bookingLocationSchema = z5.union([
|
|
2176
2360
|
zMeetLocation,
|
|
2177
2361
|
zPhysicalLocation,
|
|
2178
2362
|
zPhoneLocation,
|
|
2179
2363
|
zCustomLocation
|
|
2180
2364
|
]);
|
|
2181
|
-
var bookingLocationNullableSchema =
|
|
2365
|
+
var bookingLocationNullableSchema = z5.union([
|
|
2182
2366
|
...bookingLocationSchema.def.options,
|
|
2183
|
-
|
|
2367
|
+
z5.null()
|
|
2184
2368
|
]);
|
|
2185
2369
|
function addIssue2(ctx, path, message) {
|
|
2186
2370
|
ctx.issues.push({ code: "custom", input: ctx.value, path, message });
|
|
@@ -2196,26 +2380,44 @@ function refineEndXor(value, ctx) {
|
|
|
2196
2380
|
addIssue2(ctx, ["end_at"], "end_at must be after start_at");
|
|
2197
2381
|
}
|
|
2198
2382
|
}
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2383
|
+
function refineStartXor(value, ctx) {
|
|
2384
|
+
const hasStart = value.start_at !== void 0 && value.start_at !== null;
|
|
2385
|
+
const hasDate = value.date !== void 0 && value.date !== null;
|
|
2386
|
+
if (hasStart === hasDate) {
|
|
2387
|
+
addIssue2(ctx, ["start_at"], "provide exactly one of start_at or date");
|
|
2388
|
+
return;
|
|
2389
|
+
}
|
|
2390
|
+
if (hasStart) {
|
|
2391
|
+
refineEndXor(value, ctx);
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
if (value.end_at != null || value.duration_minutes != null) {
|
|
2395
|
+
addIssue2(ctx, ["date"], "an all-day booking (date) takes no end_at or duration_minutes");
|
|
2396
|
+
}
|
|
2397
|
+
if (value.buffer_before_minutes || value.buffer_after_minutes) {
|
|
2398
|
+
addIssue2(ctx, ["date"], "an all-day booking (date) takes no buffers");
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
var bookingRemindersSchema = z5.extend(zBookingReminders, {
|
|
2402
|
+
overrides: z5._default(
|
|
2403
|
+
z5.array(bookingReminderSchema).check(z5.maxLength(MAX_REMINDER_OVERRIDES)),
|
|
2202
2404
|
[]
|
|
2203
2405
|
)
|
|
2204
2406
|
});
|
|
2205
|
-
var bookingCreateSchema =
|
|
2407
|
+
var bookingCreateSchema = z5.extend(zBookingCreateSchema, {
|
|
2206
2408
|
time_zone: ianaTz,
|
|
2207
2409
|
// The generated field is `z.union([...variants]).nullish()`, which nests one
|
|
2208
2410
|
// `anyOf` inside another; Pydantic's `BookingLocation | None` flattens to a
|
|
2209
2411
|
// single list and the drift snapshot compares structure. Override with the
|
|
2210
2412
|
// flattened union.
|
|
2211
|
-
location:
|
|
2212
|
-
attendees:
|
|
2413
|
+
location: z5.optional(bookingLocationNullableSchema),
|
|
2414
|
+
attendees: z5._default(z5.array(bookingAttendeeSchema).check(z5.maxLength(MAX_ATTENDEES)), []),
|
|
2213
2415
|
// These reference the un-composed generated schemas; generation can't nest
|
|
2214
2416
|
// our compositions into its own output.
|
|
2215
|
-
reminders:
|
|
2216
|
-
metadata:
|
|
2217
|
-
}).check((ctx) =>
|
|
2218
|
-
var bookingRescheduleSchema =
|
|
2417
|
+
reminders: z5.nullish(bookingRemindersSchema),
|
|
2418
|
+
metadata: z5.nullish(bookingMetadataSchema)
|
|
2419
|
+
}).check((ctx) => refineStartXor(ctx.value, ctx));
|
|
2420
|
+
var bookingRescheduleSchema = z5.extend(zBookingRescheduleSchema, { time_zone: ianaTz }).check((ctx) => refineEndXor(ctx.value, ctx));
|
|
2219
2421
|
var bookingCancelSchema = zBookingCancelSchema;
|
|
2220
2422
|
|
|
2221
2423
|
// ../tracking-core/src/resources/calendar/slots.ts
|
|
@@ -2373,7 +2575,10 @@ function useBookingForm(options = {}) {
|
|
|
2373
2575
|
const response = await fetch(endpoint, {
|
|
2374
2576
|
method: "POST",
|
|
2375
2577
|
headers: { "Content-Type": "application/json" },
|
|
2376
|
-
body: JSON.stringify(
|
|
2578
|
+
body: JSON.stringify({
|
|
2579
|
+
...input,
|
|
2580
|
+
metadata: { ...getBookingAttribution(), ...input.metadata }
|
|
2581
|
+
})
|
|
2377
2582
|
});
|
|
2378
2583
|
const body = await response.json().catch(() => null);
|
|
2379
2584
|
if (!response.ok) {
|
|
@@ -2457,6 +2662,7 @@ export {
|
|
|
2457
2662
|
formatPhoneAsTyped,
|
|
2458
2663
|
formatSlotRange,
|
|
2459
2664
|
fromMinor,
|
|
2665
|
+
getBookingAttribution,
|
|
2460
2666
|
getConsentChoice,
|
|
2461
2667
|
getConsentState,
|
|
2462
2668
|
getEventSemantics,
|