@aranova/tracking-next 0.27.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blog-server.d.mts +2 -1
- package/dist/blog-server.d.ts +2 -1
- package/dist/blog-server.js +121 -98
- package/dist/blog-server.js.map +1 -1
- package/dist/blog-server.mjs +86 -63
- package/dist/blog-server.mjs.map +1 -1
- package/dist/blog.d.mts +651 -1755
- package/dist/blog.d.ts +651 -1755
- package/dist/blog.js +121 -98
- package/dist/blog.js.map +1 -1
- package/dist/blog.mjs +86 -63
- package/dist/blog.mjs.map +1 -1
- package/dist/calendar-server.d.mts +2 -2
- package/dist/calendar-server.d.ts +2 -2
- package/dist/calendar-server.js +0 -26
- package/dist/calendar-server.js.map +1 -1
- package/dist/calendar-server.mjs +0 -26
- package/dist/calendar-server.mjs.map +1 -1
- package/dist/calendar.d.mts +3 -3
- package/dist/calendar.d.ts +3 -3
- package/dist/calendar.js +227 -126
- package/dist/calendar.js.map +1 -1
- package/dist/calendar.mjs +216 -125
- package/dist/calendar.mjs.map +1 -1
- package/dist/client.d.mts +11 -4
- package/dist/client.d.ts +11 -4
- package/dist/client.js +611 -347
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +611 -347
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +550 -487
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +539 -487
- package/dist/index.mjs.map +1 -1
- package/dist/ingest-typed-MBuMe9Pn.d.ts +883 -0
- package/dist/ingest-typed-UA13xTfI.d.mts +883 -0
- package/dist/middleware.js +0 -467
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +0 -467
- package/dist/middleware.mjs.map +1 -1
- package/dist/{phone-utils-BVzSNBf1.d.mts → phone-utils-C0ds6cqZ.d.mts} +24 -78
- package/dist/{phone-utils-BVzSNBf1.d.ts → phone-utils-C0ds6cqZ.d.ts} +24 -78
- package/dist/phone.d.mts +2 -2
- package/dist/phone.d.ts +2 -2
- package/dist/phone.js +0 -464
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs +0 -464
- package/dist/phone.mjs.map +1 -1
- package/dist/{sales-IGC2tq4J.d.ts → sales-DQC815f3.d.ts} +90 -329
- package/dist/{sales-DQGzXSgL.d.mts → sales-w1reW_Y3.d.mts} +90 -329
- package/dist/sales.d.mts +3 -3
- package/dist/sales.d.ts +3 -3
- package/dist/sales.js +270 -127
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +259 -127
- package/dist/sales.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +0 -467
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +0 -467
- package/dist/server.mjs.map +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-CDmGOiCq.d.ts +253 -0
- package/dist/transport-I_cMSFQ6.d.mts +253 -0
- package/package.json +2 -2
- package/dist/ingest-typed-BxLFlZ7N.d.mts +0 -1371
- package/dist/ingest-typed-ByQVRMvP.d.ts +0 -1371
- package/dist/transport-C-_rFSR4.d.ts +0 -721
- package/dist/transport-yUF5Wize.d.mts +0 -721
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -62,6 +72,7 @@ __export(src_exports, {
|
|
|
62
72
|
createTrackingClientContext: () => createTrackingClientContext,
|
|
63
73
|
createTrackingEventCreatePayload: () => createTrackingEventCreatePayload,
|
|
64
74
|
createTrackingSessionUpsertPayload: () => createTrackingSessionUpsertPayload,
|
|
75
|
+
currencySchema: () => currencySchema,
|
|
65
76
|
durationMinutes: () => durationMinutes,
|
|
66
77
|
endOfDayInTz: () => endOfDayInTz,
|
|
67
78
|
fetchServices: () => fetchServices,
|
|
@@ -162,7 +173,7 @@ function normalizeEmail(raw) {
|
|
|
162
173
|
return EMAIL_SHAPE.test(cleaned) ? cleaned : null;
|
|
163
174
|
}
|
|
164
175
|
function stashUserData(data, country) {
|
|
165
|
-
const
|
|
176
|
+
const email4 = normalizeEmail(data.email);
|
|
166
177
|
let phoneNumber = null;
|
|
167
178
|
if (typeof data.phone === "string" && data.phone.length > 0) {
|
|
168
179
|
try {
|
|
@@ -172,7 +183,7 @@ function stashUserData(data, country) {
|
|
|
172
183
|
}
|
|
173
184
|
}
|
|
174
185
|
stash = {
|
|
175
|
-
email:
|
|
186
|
+
email: email4 ?? stash.email,
|
|
176
187
|
phoneNumber: phoneNumber ?? stash.phoneNumber
|
|
177
188
|
};
|
|
178
189
|
}
|
|
@@ -181,11 +192,11 @@ function clearStashedUserData() {
|
|
|
181
192
|
}
|
|
182
193
|
function applyUserDataForConversion(explicit, country) {
|
|
183
194
|
if (typeof window === "undefined" || typeof window.gtag !== "function") return false;
|
|
184
|
-
let
|
|
195
|
+
let email4 = stash.email;
|
|
185
196
|
let phoneNumber = stash.phoneNumber;
|
|
186
197
|
if (explicit) {
|
|
187
198
|
const normalizedEmail = normalizeEmail(explicit.email);
|
|
188
|
-
if (normalizedEmail)
|
|
199
|
+
if (normalizedEmail) email4 = normalizedEmail;
|
|
189
200
|
if (typeof explicit.phone === "string" && explicit.phone.length > 0) {
|
|
190
201
|
try {
|
|
191
202
|
phoneNumber = toE164(explicit.phone, country) ?? phoneNumber;
|
|
@@ -193,10 +204,10 @@ function applyUserDataForConversion(explicit, country) {
|
|
|
193
204
|
}
|
|
194
205
|
}
|
|
195
206
|
}
|
|
196
|
-
if (
|
|
207
|
+
if (email4 === null && phoneNumber === null) return false;
|
|
197
208
|
try {
|
|
198
209
|
window.gtag("set", "user_data", {
|
|
199
|
-
...
|
|
210
|
+
...email4 !== null ? { email: email4 } : {},
|
|
200
211
|
...phoneNumber !== null ? { phone_number: phoneNumber } : {}
|
|
201
212
|
});
|
|
202
213
|
return true;
|
|
@@ -328,6 +339,7 @@ var TRACKING_CAPABILITIES = [
|
|
|
328
339
|
"consent_controls",
|
|
329
340
|
"conversion_goals_auto",
|
|
330
341
|
"conversion_goals_manual",
|
|
342
|
+
"cross_site_linker",
|
|
331
343
|
"cta_click_capture",
|
|
332
344
|
"form_capture",
|
|
333
345
|
"phone_click_capture",
|
|
@@ -354,6 +366,9 @@ function readDomMarkers() {
|
|
|
354
366
|
return found;
|
|
355
367
|
}
|
|
356
368
|
|
|
369
|
+
// ../tracking-core/src/cross-site-link.ts
|
|
370
|
+
var z = __toESM(require("zod/mini"));
|
|
371
|
+
|
|
357
372
|
// ../tracking-core/src/tracking.ts
|
|
358
373
|
var TRACKING_COOKIE_MAX_AGE_SECONDS = 7776e3;
|
|
359
374
|
var TRACKING_PARAM_KEYS = [
|
|
@@ -552,10 +567,10 @@ function readStoredRecord() {
|
|
|
552
567
|
return null;
|
|
553
568
|
}
|
|
554
569
|
}
|
|
555
|
-
function writeRecord(
|
|
556
|
-
memoryRecord =
|
|
570
|
+
function writeRecord(record5) {
|
|
571
|
+
memoryRecord = record5;
|
|
557
572
|
try {
|
|
558
|
-
window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(
|
|
573
|
+
window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record5));
|
|
559
574
|
} catch {
|
|
560
575
|
}
|
|
561
576
|
}
|
|
@@ -577,9 +592,9 @@ function getOrCaptureLandingParams(sessionId, url) {
|
|
|
577
592
|
if (memoryRecord && memoryRecord.session_id === sessionId) {
|
|
578
593
|
return memoryRecord.params;
|
|
579
594
|
}
|
|
580
|
-
const
|
|
581
|
-
writeRecord(
|
|
582
|
-
return
|
|
595
|
+
const record5 = { session_id: sessionId, params: captureFromUrl(url) };
|
|
596
|
+
writeRecord(record5);
|
|
597
|
+
return record5.params;
|
|
583
598
|
}
|
|
584
599
|
function buildLandingPayloadFields(sessionId, override) {
|
|
585
600
|
const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
|
|
@@ -598,6 +613,43 @@ function buildLandingPayloadFields(sessionId, override) {
|
|
|
598
613
|
};
|
|
599
614
|
}
|
|
600
615
|
|
|
616
|
+
// ../tracking-core/src/cross-site-link.ts
|
|
617
|
+
var LINK_PARAM = "_arv";
|
|
618
|
+
var LINK_TOKEN_TTL_MS = 5 * 60 * 1e3;
|
|
619
|
+
var FUTURE_SKEW_MS = 60 * 1e3;
|
|
620
|
+
var CARRIED_KEYS = {
|
|
621
|
+
g: "gclid",
|
|
622
|
+
w: "wbraid",
|
|
623
|
+
gb: "gbraid",
|
|
624
|
+
f: "fbclid",
|
|
625
|
+
y: "ylpcid"
|
|
626
|
+
};
|
|
627
|
+
var CARRIED_ENTRIES = Object.entries(CARRIED_KEYS);
|
|
628
|
+
var identifier = z.string().check(z.minLength(1), z.maxLength(128));
|
|
629
|
+
var optionalIdentifier = z.optional(identifier);
|
|
630
|
+
var linkTokenSchema = z.object({
|
|
631
|
+
v: identifier,
|
|
632
|
+
s: identifier,
|
|
633
|
+
// Epoch ms in base36.
|
|
634
|
+
t: z.string().check(z.regex(/^[0-9a-z]{1,12}$/)),
|
|
635
|
+
g: optionalIdentifier,
|
|
636
|
+
w: optionalIdentifier,
|
|
637
|
+
gb: optionalIdentifier,
|
|
638
|
+
f: optionalIdentifier,
|
|
639
|
+
fc: optionalIdentifier,
|
|
640
|
+
y: optionalIdentifier
|
|
641
|
+
});
|
|
642
|
+
function stripLinkParam(url) {
|
|
643
|
+
try {
|
|
644
|
+
const parsed = new URL(url, typeof window === "undefined" ? void 0 : window.location.href);
|
|
645
|
+
if (!parsed.searchParams.has(LINK_PARAM)) return url;
|
|
646
|
+
parsed.searchParams.delete(LINK_PARAM);
|
|
647
|
+
return parsed.href;
|
|
648
|
+
} catch {
|
|
649
|
+
return url;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
601
653
|
// ../tracking-core/src/payloads.ts
|
|
602
654
|
function createTrackingClientContext(surface, input = {}) {
|
|
603
655
|
return {
|
|
@@ -637,6 +689,7 @@ function createTrackingSessionUpsertPayload(trackingParams, input, context) {
|
|
|
637
689
|
};
|
|
638
690
|
}
|
|
639
691
|
function createTrackingEventCreatePayload(trackingParams, input, context) {
|
|
692
|
+
const pageUrl = input.pageUrl ?? (typeof window === "undefined" ? null : window.location.href);
|
|
640
693
|
return {
|
|
641
694
|
session_id: input.sessionId,
|
|
642
695
|
event_type: input.eventType,
|
|
@@ -647,7 +700,7 @@ function createTrackingEventCreatePayload(trackingParams, input, context) {
|
|
|
647
700
|
fbclid: trackingParams.fbclid,
|
|
648
701
|
fbc: getFbcCookie(),
|
|
649
702
|
fbp: getFbpCookie(),
|
|
650
|
-
page_url:
|
|
703
|
+
page_url: pageUrl === null ? null : stripLinkParam(pageUrl),
|
|
651
704
|
metadata: input.metadata ?? null,
|
|
652
705
|
context
|
|
653
706
|
};
|
|
@@ -759,7 +812,8 @@ function parseConversionConfig(raw) {
|
|
|
759
812
|
gtag_ids: isStringMap(obj.gtag_ids) ? obj.gtag_ids : {},
|
|
760
813
|
meta_pixel_ids: isStringMap(obj.meta_pixel_ids) ? obj.meta_pixel_ids : {},
|
|
761
814
|
services,
|
|
762
|
-
goals
|
|
815
|
+
goals,
|
|
816
|
+
linked_hostnames: Array.isArray(obj.linked_hostnames) ? obj.linked_hostnames.filter((h) => typeof h === "string" && h.length > 0) : []
|
|
763
817
|
};
|
|
764
818
|
}
|
|
765
819
|
var CACHE_PREFIX = "_aranova_cfg_";
|
|
@@ -843,6 +897,7 @@ function resolveConversionConfig(options) {
|
|
|
843
897
|
getFiring: (key) => goalsByKey.get(key)?.firing ?? null,
|
|
844
898
|
getGoal: (key) => goalsByKey.get(key) ?? null,
|
|
845
899
|
listGoals: () => [...goalsByKey.values()],
|
|
900
|
+
linkedHostnames: () => current?.linked_hostnames ?? [],
|
|
846
901
|
current: () => current,
|
|
847
902
|
isReady: () => current !== null,
|
|
848
903
|
onResolve: (listener) => {
|
|
@@ -956,9 +1011,9 @@ function automaticThresholdMet(goal, eventType, metadata) {
|
|
|
956
1011
|
}
|
|
957
1012
|
|
|
958
1013
|
// ../tracking-core/src/resources/intl/date.ts
|
|
959
|
-
function formatDateInTz(
|
|
960
|
-
const date = new Date(
|
|
961
|
-
if (Number.isNaN(date.getTime())) return
|
|
1014
|
+
function formatDateInTz(iso4, timeZone, opts, locale) {
|
|
1015
|
+
const date = new Date(iso4);
|
|
1016
|
+
if (Number.isNaN(date.getTime())) return iso4;
|
|
962
1017
|
return new Intl.DateTimeFormat(locale, {
|
|
963
1018
|
year: "numeric",
|
|
964
1019
|
month: "short",
|
|
@@ -1050,7 +1105,7 @@ function validateConfig(config, ref) {
|
|
|
1050
1105
|
function pageViewSnapshot() {
|
|
1051
1106
|
if (typeof window === "undefined" || typeof document === "undefined") return null;
|
|
1052
1107
|
return {
|
|
1053
|
-
href: window.location.href,
|
|
1108
|
+
href: stripLinkParam(window.location.href),
|
|
1054
1109
|
title: document.title || null,
|
|
1055
1110
|
referrer: document.referrer || null
|
|
1056
1111
|
};
|
|
@@ -1201,6 +1256,10 @@ var TrackingConfigRuntime = class {
|
|
|
1201
1256
|
listGoals() {
|
|
1202
1257
|
return this.current?.goals ?? [];
|
|
1203
1258
|
}
|
|
1259
|
+
/** Sibling hostnames for the linker — read from the cached object even while unconfirmed. */
|
|
1260
|
+
linkedHostnames() {
|
|
1261
|
+
return this.current?.linked_hostnames ?? [];
|
|
1262
|
+
}
|
|
1204
1263
|
async revalidateNow() {
|
|
1205
1264
|
try {
|
|
1206
1265
|
const headers = {};
|
|
@@ -1370,29 +1429,6 @@ function getTrackingConfigRuntime(ref, fetchImpl) {
|
|
|
1370
1429
|
return runtime;
|
|
1371
1430
|
}
|
|
1372
1431
|
|
|
1373
|
-
// ../tracking-core/src/session.ts
|
|
1374
|
-
var SESSION_IDLE_MS = 30 * 60 * 1e3;
|
|
1375
|
-
|
|
1376
|
-
// ../tracking-core/src/events/page-view.ts
|
|
1377
|
-
var import_zod = require("zod");
|
|
1378
|
-
var pageViewMetadataSchema = import_zod.z.object({
|
|
1379
|
-
page: import_zod.z.object({
|
|
1380
|
-
title: import_zod.z.string().nullable(),
|
|
1381
|
-
path: import_zod.z.string(),
|
|
1382
|
-
search: import_zod.z.string(),
|
|
1383
|
-
hash: import_zod.z.string()
|
|
1384
|
-
}).strict(),
|
|
1385
|
-
referrer: import_zod.z.string().nullable(),
|
|
1386
|
-
// `.nullable().optional()` — absent (undefined) OR explicit null OR a
|
|
1387
|
-
// real viewport object. Mirrors Pydantic's `_Viewport | None = None`
|
|
1388
|
-
// on the backend side so the drift test stays clean.
|
|
1389
|
-
viewport: import_zod.z.object({
|
|
1390
|
-
w: import_zod.z.number(),
|
|
1391
|
-
h: import_zod.z.number()
|
|
1392
|
-
}).strict().nullable().optional()
|
|
1393
|
-
}).strict();
|
|
1394
|
-
var pageViewConfigSchema = import_zod.z.object({}).strict();
|
|
1395
|
-
|
|
1396
1432
|
// ../tracking-core/src/ingest.ts
|
|
1397
1433
|
var API_KEY_HEADER = "X-Aranova-Api-Key";
|
|
1398
1434
|
var SDK_VERSION_HEADER = "X-Aranova-Sdk-Version";
|
|
@@ -1400,187 +1436,6 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
|
1400
1436
|
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
1401
1437
|
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
1402
1438
|
|
|
1403
|
-
// ../tracking-core/src/events/cta-click.ts
|
|
1404
|
-
var import_zod2 = require("zod");
|
|
1405
|
-
var ctaClickMetadataSchema = import_zod2.z.object({
|
|
1406
|
-
cta_name: import_zod2.z.string(),
|
|
1407
|
-
page: import_zod2.z.object({
|
|
1408
|
-
path: import_zod2.z.string()
|
|
1409
|
-
}).strict(),
|
|
1410
|
-
section: import_zod2.z.string().nullable().optional(),
|
|
1411
|
-
destination_url: import_zod2.z.string().nullable().optional(),
|
|
1412
|
-
// Set by auto-capture (and available to manual callers): the link target
|
|
1413
|
-
// and a short element descriptor (tag#id) for tying clicks to specific UI.
|
|
1414
|
-
href: import_zod2.z.string().nullable().optional(),
|
|
1415
|
-
element: import_zod2.z.string().nullable().optional()
|
|
1416
|
-
}).strict();
|
|
1417
|
-
var ctaClickConfigSchema = import_zod2.z.object({
|
|
1418
|
-
autoCapture: import_zod2.z.object({
|
|
1419
|
-
selector: import_zod2.z.string().optional()
|
|
1420
|
-
}).strict().optional()
|
|
1421
|
-
}).strict();
|
|
1422
|
-
|
|
1423
|
-
// ../tracking-core/src/events/sdk-heartbeat.ts
|
|
1424
|
-
var import_zod3 = require("zod");
|
|
1425
|
-
var sdkHeartbeatTriggersSchema = import_zod3.z.object({
|
|
1426
|
-
automatic: import_zod3.z.array(import_zod3.z.string()),
|
|
1427
|
-
manual: import_zod3.z.array(import_zod3.z.string())
|
|
1428
|
-
}).strict();
|
|
1429
|
-
var sdkHeartbeatMetadataSchema = import_zod3.z.object({
|
|
1430
|
-
sdk_version: import_zod3.z.string(),
|
|
1431
|
-
package_name: import_zod3.z.string().nullable(),
|
|
1432
|
-
surface: import_zod3.z.enum(["next", "react", "script"]),
|
|
1433
|
-
triggers: sdkHeartbeatTriggersSchema,
|
|
1434
|
-
trigger_config: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown())).nullable().optional(),
|
|
1435
|
-
configured_gtag_ids: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).nullable().optional(),
|
|
1436
|
-
// Site whose config object the SDK resolves; null on a legacy business ref.
|
|
1437
|
-
config_site_id: import_zod3.z.string().uuid().nullable().optional()
|
|
1438
|
-
}).strict();
|
|
1439
|
-
var sdkHeartbeatConfigSchema = import_zod3.z.object({}).strict();
|
|
1440
|
-
|
|
1441
|
-
// ../tracking-core/src/events/form-start.ts
|
|
1442
|
-
var import_zod4 = require("zod");
|
|
1443
|
-
var formStartMetadataSchema = import_zod4.z.object({
|
|
1444
|
-
form: import_zod4.z.object({
|
|
1445
|
-
id: import_zod4.z.string(),
|
|
1446
|
-
action: import_zod4.z.string().nullable()
|
|
1447
|
-
}).strict(),
|
|
1448
|
-
page: import_zod4.z.object({
|
|
1449
|
-
path: import_zod4.z.string()
|
|
1450
|
-
}).strict()
|
|
1451
|
-
}).strict();
|
|
1452
|
-
var formStartConfigSchema = import_zod4.z.object({
|
|
1453
|
-
selector: import_zod4.z.string().optional()
|
|
1454
|
-
}).strict();
|
|
1455
|
-
|
|
1456
|
-
// ../tracking-core/src/events/form-submit.ts
|
|
1457
|
-
var import_zod5 = require("zod");
|
|
1458
|
-
var jsonValueSchema = import_zod5.z.lazy(
|
|
1459
|
-
() => import_zod5.z.union([
|
|
1460
|
-
import_zod5.z.string(),
|
|
1461
|
-
import_zod5.z.number().finite(),
|
|
1462
|
-
import_zod5.z.boolean(),
|
|
1463
|
-
import_zod5.z.null(),
|
|
1464
|
-
import_zod5.z.array(jsonValueSchema),
|
|
1465
|
-
import_zod5.z.record(jsonValueSchema)
|
|
1466
|
-
])
|
|
1467
|
-
);
|
|
1468
|
-
var formSubmitMetadataSchema = import_zod5.z.object({
|
|
1469
|
-
form: import_zod5.z.object({
|
|
1470
|
-
id: import_zod5.z.string(),
|
|
1471
|
-
action: import_zod5.z.string().nullable(),
|
|
1472
|
-
fields: import_zod5.z.array(
|
|
1473
|
-
import_zod5.z.object({
|
|
1474
|
-
name: import_zod5.z.string(),
|
|
1475
|
-
type: import_zod5.z.string(),
|
|
1476
|
-
label: import_zod5.z.string().nullable(),
|
|
1477
|
-
value: jsonValueSchema
|
|
1478
|
-
}).strict()
|
|
1479
|
-
).optional()
|
|
1480
|
-
}).strict(),
|
|
1481
|
-
page: import_zod5.z.object({
|
|
1482
|
-
path: import_zod5.z.string()
|
|
1483
|
-
}).strict()
|
|
1484
|
-
}).strict();
|
|
1485
|
-
var formSubmitConfigSchema = import_zod5.z.object({}).strict();
|
|
1486
|
-
|
|
1487
|
-
// ../tracking-core/src/events/multi-page-session.ts
|
|
1488
|
-
var import_zod6 = require("zod");
|
|
1489
|
-
var multiPageSessionMetadataSchema = import_zod6.z.object({
|
|
1490
|
-
page_count: import_zod6.z.number().int().min(2),
|
|
1491
|
-
page: import_zod6.z.object({
|
|
1492
|
-
path: import_zod6.z.string()
|
|
1493
|
-
}).strict()
|
|
1494
|
-
}).strict();
|
|
1495
|
-
var multiPageSessionConfigSchema = import_zod6.z.object({
|
|
1496
|
-
pageThreshold: import_zod6.z.number().int().min(2)
|
|
1497
|
-
}).strict();
|
|
1498
|
-
|
|
1499
|
-
// ../tracking-core/src/events/page-exit.ts
|
|
1500
|
-
var import_zod7 = require("zod");
|
|
1501
|
-
var pageExitMetadataSchema = import_zod7.z.object({
|
|
1502
|
-
dwell_ms: import_zod7.z.number().int().min(0),
|
|
1503
|
-
// null = left without any scroll signal; floor is 0 so a valid 0% is never
|
|
1504
|
-
// rejected (a single bad field 422s the whole keepalive beacon batch).
|
|
1505
|
-
max_scroll_percent: import_zod7.z.number().int().min(0).max(100).nullable(),
|
|
1506
|
-
// The gating baseline: the fraction of the page visible at load with
|
|
1507
|
-
// zero scrolling — or, for pages that grew after the post-paint snapshot
|
|
1508
|
-
// (skeleton/streaming renders), the first-scroll position that
|
|
1509
|
-
// established it. null = page had no scrollable range, or the segment
|
|
1510
|
-
// ended before the snapshot. `.optional()` is load-bearing: SDK builds
|
|
1511
|
-
// predating this field keep POSTing page_exit without the key —
|
|
1512
|
-
// requiring it would 422 whole keepalive beacon batches.
|
|
1513
|
-
scroll_baseline_percent: import_zod7.z.number().int().min(0).max(100).nullable().optional(),
|
|
1514
|
-
page: import_zod7.z.object({
|
|
1515
|
-
path: import_zod7.z.string()
|
|
1516
|
-
}).strict()
|
|
1517
|
-
}).strict();
|
|
1518
|
-
var pageExitConfigSchema = import_zod7.z.object({}).strict();
|
|
1519
|
-
|
|
1520
|
-
// ../tracking-core/src/events/phone-click.ts
|
|
1521
|
-
var import_zod8 = require("zod");
|
|
1522
|
-
var phoneClickMetadataSchema = import_zod8.z.object({
|
|
1523
|
-
phone_number: import_zod8.z.string(),
|
|
1524
|
-
page: import_zod8.z.object({
|
|
1525
|
-
path: import_zod8.z.string()
|
|
1526
|
-
}).strict(),
|
|
1527
|
-
section: import_zod8.z.string().nullable().optional()
|
|
1528
|
-
}).strict();
|
|
1529
|
-
var phoneClickConfigSchema = import_zod8.z.object({
|
|
1530
|
-
autoCapture: import_zod8.z.object({
|
|
1531
|
-
selector: import_zod8.z.string().optional()
|
|
1532
|
-
}).strict().optional()
|
|
1533
|
-
}).strict();
|
|
1534
|
-
|
|
1535
|
-
// ../tracking-core/src/events/scroll-depth.ts
|
|
1536
|
-
var import_zod9 = require("zod");
|
|
1537
|
-
var scrollDepthMetadataSchema = import_zod9.z.object({
|
|
1538
|
-
depth_percent: import_zod9.z.number().int().min(1).max(100),
|
|
1539
|
-
page: import_zod9.z.object({
|
|
1540
|
-
path: import_zod9.z.string()
|
|
1541
|
-
}).strict()
|
|
1542
|
-
}).strict();
|
|
1543
|
-
var scrollDepthConfigSchema = import_zod9.z.object({
|
|
1544
|
-
thresholds: import_zod9.z.array(import_zod9.z.number().int().min(1).max(100)).min(1)
|
|
1545
|
-
}).strict();
|
|
1546
|
-
|
|
1547
|
-
// ../tracking-core/src/events/specific-page-visit.ts
|
|
1548
|
-
var import_zod10 = require("zod");
|
|
1549
|
-
var PAGE_IDENTITY_MAX_LENGTH = 64;
|
|
1550
|
-
var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
|
|
1551
|
-
var pageIdentitySchema = import_zod10.z.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
|
|
1552
|
-
message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
|
|
1553
|
-
});
|
|
1554
|
-
var specificPageNameSchema = pageIdentitySchema;
|
|
1555
|
-
var specificPageVisitMetadataSchema = import_zod10.z.object({
|
|
1556
|
-
page_name: specificPageNameSchema,
|
|
1557
|
-
page: import_zod10.z.object({
|
|
1558
|
-
path: import_zod10.z.string()
|
|
1559
|
-
}).strict()
|
|
1560
|
-
}).strict();
|
|
1561
|
-
var specificPageVisitConfigSchema = import_zod10.z.object({
|
|
1562
|
-
pages: import_zod10.z.array(
|
|
1563
|
-
import_zod10.z.object({
|
|
1564
|
-
name: specificPageNameSchema,
|
|
1565
|
-
pathPattern: import_zod10.z.custom((value) => value instanceof RegExp, {
|
|
1566
|
-
message: "pathPattern must be a RegExp"
|
|
1567
|
-
})
|
|
1568
|
-
}).strict()
|
|
1569
|
-
).min(1)
|
|
1570
|
-
}).strict();
|
|
1571
|
-
|
|
1572
|
-
// ../tracking-core/src/events/time-on-site.ts
|
|
1573
|
-
var import_zod11 = require("zod");
|
|
1574
|
-
var timeOnSiteMetadataSchema = import_zod11.z.object({
|
|
1575
|
-
duration_ms: import_zod11.z.number().int().nonnegative(),
|
|
1576
|
-
page: import_zod11.z.object({
|
|
1577
|
-
path: import_zod11.z.string()
|
|
1578
|
-
}).strict()
|
|
1579
|
-
}).strict();
|
|
1580
|
-
var timeOnSiteConfigSchema = import_zod11.z.object({
|
|
1581
|
-
thresholdSeconds: import_zod11.z.number().int().positive()
|
|
1582
|
-
}).strict();
|
|
1583
|
-
|
|
1584
1439
|
// ../tracking-core/src/events/semantics.ts
|
|
1585
1440
|
var EVENT_SEMANTICS = {
|
|
1586
1441
|
page_view: {
|
|
@@ -1648,88 +1503,24 @@ var EVENT_SEMANTICS = {
|
|
|
1648
1503
|
category: "engagement",
|
|
1649
1504
|
outcomeRole: "engagement",
|
|
1650
1505
|
clientVisibility: "simple"
|
|
1506
|
+
},
|
|
1507
|
+
site_link_click: {
|
|
1508
|
+
label: "Left for sibling site",
|
|
1509
|
+
category: "page",
|
|
1510
|
+
outcomeRole: "navigation",
|
|
1511
|
+
clientVisibility: "detailed"
|
|
1512
|
+
},
|
|
1513
|
+
site_link_arrival: {
|
|
1514
|
+
label: "Arrived from sibling site",
|
|
1515
|
+
category: "page",
|
|
1516
|
+
outcomeRole: "navigation",
|
|
1517
|
+
clientVisibility: "simple"
|
|
1651
1518
|
}
|
|
1652
1519
|
};
|
|
1653
1520
|
function getEventSemantics(eventName) {
|
|
1654
1521
|
return eventName in EVENT_SEMANTICS ? EVENT_SEMANTICS[eventName] : null;
|
|
1655
1522
|
}
|
|
1656
1523
|
|
|
1657
|
-
// ../tracking-core/src/events/registry.ts
|
|
1658
|
-
var EVENT_REGISTRY = {
|
|
1659
|
-
// --- automatic triggers ---
|
|
1660
|
-
page_view: {
|
|
1661
|
-
kind: "automatic",
|
|
1662
|
-
semantics: EVENT_SEMANTICS.page_view,
|
|
1663
|
-
metadataSchema: pageViewMetadataSchema,
|
|
1664
|
-
configSchema: pageViewConfigSchema
|
|
1665
|
-
},
|
|
1666
|
-
time_on_site: {
|
|
1667
|
-
kind: "automatic",
|
|
1668
|
-
semantics: EVENT_SEMANTICS.time_on_site,
|
|
1669
|
-
metadataSchema: timeOnSiteMetadataSchema,
|
|
1670
|
-
configSchema: timeOnSiteConfigSchema
|
|
1671
|
-
},
|
|
1672
|
-
specific_page_visit: {
|
|
1673
|
-
kind: "automatic",
|
|
1674
|
-
semantics: EVENT_SEMANTICS.specific_page_visit,
|
|
1675
|
-
metadataSchema: specificPageVisitMetadataSchema,
|
|
1676
|
-
configSchema: specificPageVisitConfigSchema
|
|
1677
|
-
},
|
|
1678
|
-
scroll_depth: {
|
|
1679
|
-
kind: "automatic",
|
|
1680
|
-
semantics: EVENT_SEMANTICS.scroll_depth,
|
|
1681
|
-
metadataSchema: scrollDepthMetadataSchema,
|
|
1682
|
-
configSchema: scrollDepthConfigSchema
|
|
1683
|
-
},
|
|
1684
|
-
multi_page_session: {
|
|
1685
|
-
kind: "automatic",
|
|
1686
|
-
semantics: EVENT_SEMANTICS.multi_page_session,
|
|
1687
|
-
metadataSchema: multiPageSessionMetadataSchema,
|
|
1688
|
-
configSchema: multiPageSessionConfigSchema
|
|
1689
|
-
},
|
|
1690
|
-
form_start: {
|
|
1691
|
-
kind: "automatic",
|
|
1692
|
-
semantics: EVENT_SEMANTICS.form_start,
|
|
1693
|
-
metadataSchema: formStartMetadataSchema,
|
|
1694
|
-
configSchema: formStartConfigSchema
|
|
1695
|
-
},
|
|
1696
|
-
// --- SDK-internal automatic (not consumer-configurable) ---
|
|
1697
|
-
sdk_heartbeat: {
|
|
1698
|
-
kind: "automatic",
|
|
1699
|
-
semantics: EVENT_SEMANTICS.sdk_heartbeat,
|
|
1700
|
-
metadataSchema: sdkHeartbeatMetadataSchema,
|
|
1701
|
-
configSchema: sdkHeartbeatConfigSchema
|
|
1702
|
-
},
|
|
1703
|
-
page_exit: {
|
|
1704
|
-
kind: "automatic",
|
|
1705
|
-
semantics: EVENT_SEMANTICS.page_exit,
|
|
1706
|
-
metadataSchema: pageExitMetadataSchema,
|
|
1707
|
-
configSchema: pageExitConfigSchema
|
|
1708
|
-
},
|
|
1709
|
-
// --- manual triggers ---
|
|
1710
|
-
form_submit: {
|
|
1711
|
-
kind: "manual",
|
|
1712
|
-
semantics: EVENT_SEMANTICS.form_submit,
|
|
1713
|
-
metadataSchema: formSubmitMetadataSchema,
|
|
1714
|
-
configSchema: formSubmitConfigSchema
|
|
1715
|
-
},
|
|
1716
|
-
phone_click: {
|
|
1717
|
-
kind: "manual",
|
|
1718
|
-
semantics: EVENT_SEMANTICS.phone_click,
|
|
1719
|
-
metadataSchema: phoneClickMetadataSchema,
|
|
1720
|
-
configSchema: phoneClickConfigSchema
|
|
1721
|
-
},
|
|
1722
|
-
cta_click: {
|
|
1723
|
-
kind: "manual",
|
|
1724
|
-
semantics: EVENT_SEMANTICS.cta_click,
|
|
1725
|
-
metadataSchema: ctaClickMetadataSchema,
|
|
1726
|
-
configSchema: ctaClickConfigSchema
|
|
1727
|
-
}
|
|
1728
|
-
};
|
|
1729
|
-
var ALL_AUTOMATIC_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "automatic").map(([name]) => name);
|
|
1730
|
-
var ALL_MANUAL_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "manual").map(([name]) => name);
|
|
1731
|
-
var ALL_LEAD_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.semantics.outcomeRole === "lead").map(([name]) => name);
|
|
1732
|
-
|
|
1733
1524
|
// ../tracking-core/src/resources/http/errors.ts
|
|
1734
1525
|
var AranovaApiError = class extends Error {
|
|
1735
1526
|
constructor(message, options) {
|
|
@@ -1767,9 +1558,9 @@ async function apiRequest(config, method, path, body, extraHeaders) {
|
|
|
1767
1558
|
try {
|
|
1768
1559
|
const parsed = await response.json();
|
|
1769
1560
|
if (parsed && typeof parsed === "object") {
|
|
1770
|
-
const
|
|
1771
|
-
if (typeof
|
|
1772
|
-
if (typeof
|
|
1561
|
+
const record5 = parsed;
|
|
1562
|
+
if (typeof record5.detail === "string") detail = record5.detail;
|
|
1563
|
+
if (typeof record5.code === "string") code = record5.code;
|
|
1773
1564
|
}
|
|
1774
1565
|
} catch {
|
|
1775
1566
|
}
|
|
@@ -1818,7 +1609,7 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
|
|
|
1818
1609
|
}
|
|
1819
1610
|
function createSalesClient(config) {
|
|
1820
1611
|
if (config.firing) registerCapability("conversion_goals_manual");
|
|
1821
|
-
async function
|
|
1612
|
+
async function record5(input) {
|
|
1822
1613
|
const currency = input.currency ?? config.defaultCurrency;
|
|
1823
1614
|
if (!currency) {
|
|
1824
1615
|
throw new Error(
|
|
@@ -1844,9 +1635,9 @@ function createSalesClient(config) {
|
|
|
1844
1635
|
return sale;
|
|
1845
1636
|
}
|
|
1846
1637
|
return {
|
|
1847
|
-
record,
|
|
1638
|
+
record: record5,
|
|
1848
1639
|
// recordSale is the intent-revealing alias — same behavior, clearer call site.
|
|
1849
|
-
recordSale:
|
|
1640
|
+
recordSale: record5,
|
|
1850
1641
|
trackConversion(key, options) {
|
|
1851
1642
|
if (config.firing && "fireConversion" in config.firing) {
|
|
1852
1643
|
if (options?.userData && getConsentState() !== "denied") stashUserData(options.userData);
|
|
@@ -1965,115 +1756,269 @@ function createSalesClient(config) {
|
|
|
1965
1756
|
}
|
|
1966
1757
|
|
|
1967
1758
|
// ../tracking-core/src/resources/sales/schema.ts
|
|
1968
|
-
var
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
var
|
|
1972
|
-
var
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1759
|
+
var z3 = __toESM(require("zod/mini"));
|
|
1760
|
+
|
|
1761
|
+
// ../tracking-core/src/resources/sales/generated/zod.gen.ts
|
|
1762
|
+
var z2 = __toESM(require("zod/mini"));
|
|
1763
|
+
var zErrorCode = z2.enum([
|
|
1764
|
+
"missing_credentials",
|
|
1765
|
+
"invalid_api_key",
|
|
1766
|
+
"not_authenticated",
|
|
1767
|
+
"wrong_key_type",
|
|
1768
|
+
"origin_missing",
|
|
1769
|
+
"origin_not_allowed",
|
|
1770
|
+
"capability_denied",
|
|
1771
|
+
"session_required",
|
|
1772
|
+
"operator_only",
|
|
1773
|
+
"cross_tenant",
|
|
1774
|
+
"business_id_required",
|
|
1775
|
+
"bad_request",
|
|
1776
|
+
"not_found",
|
|
1777
|
+
"conflict",
|
|
1778
|
+
"incompatible_payload",
|
|
1779
|
+
"repeat_confirmation_required",
|
|
1780
|
+
"idempotency_conflict",
|
|
1781
|
+
"validation_error",
|
|
1782
|
+
"unknown_service",
|
|
1783
|
+
"invalid_sale_properties",
|
|
1784
|
+
"invalid_cursor",
|
|
1785
|
+
"rate_limited",
|
|
1786
|
+
"internal_error"
|
|
1787
|
+
]);
|
|
1788
|
+
var zSaleItemEntitySchema = z2.object({
|
|
1789
|
+
category: z2.nullable(z2.string()),
|
|
1790
|
+
external_item_id: z2.nullable(z2.string()),
|
|
1791
|
+
id: z2.uuid(),
|
|
1792
|
+
name: z2.nullable(z2.string()),
|
|
1793
|
+
quantity: z2.string().check(z2.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
|
|
1794
|
+
unit_cost_cents: z2.nullable(z2.int()),
|
|
1795
|
+
unit_price_cents: z2.int()
|
|
1796
|
+
});
|
|
1797
|
+
var zSaleItemInputSchema = z2.strictObject({
|
|
1798
|
+
category: z2.nullish(z2.string()),
|
|
1799
|
+
external_item_id: z2.nullish(z2.string()),
|
|
1800
|
+
name: z2.nullish(z2.string()),
|
|
1801
|
+
quantity: z2.string().check(z2.regex(/^\d+(\.\d{1,3})?$/)),
|
|
1802
|
+
unit_cost_cents: z2.nullish(z2.int().check(z2.gte(0))),
|
|
1803
|
+
unit_price_cents: z2.int().check(z2.gte(0))
|
|
1804
|
+
});
|
|
1805
|
+
var zSaleServiceEntitySchema = z2.object({
|
|
1806
|
+
amount_cents: z2.int(),
|
|
1807
|
+
id: z2.uuid(),
|
|
1808
|
+
mapped: z2.nullable(z2.boolean()),
|
|
1809
|
+
service_id: z2.uuid(),
|
|
1810
|
+
service_key: z2.string(),
|
|
1811
|
+
service_label: z2.string()
|
|
1812
|
+
});
|
|
1813
|
+
var zSaleServiceInputSchema = z2.strictObject({
|
|
1814
|
+
amount_cents: z2.int().check(z2.gte(0)),
|
|
1815
|
+
service: z2.string()
|
|
1816
|
+
});
|
|
1817
|
+
var zSmsAutomationState = z2.enum([
|
|
1818
|
+
"needs_check",
|
|
1819
|
+
"failed",
|
|
1820
|
+
"undelivered",
|
|
1821
|
+
"blocked_opted_out",
|
|
1822
|
+
"withheld",
|
|
1823
|
+
"queued",
|
|
1824
|
+
"sent",
|
|
1825
|
+
"delivered",
|
|
1826
|
+
"eligible",
|
|
1827
|
+
"not_applicable"
|
|
1828
|
+
]);
|
|
1829
|
+
var zSmsWithheldReason = z2.enum([
|
|
1830
|
+
"automation_disabled",
|
|
1831
|
+
"sms_disabled",
|
|
1832
|
+
"no_phone",
|
|
1833
|
+
"no_consent",
|
|
1834
|
+
"no_customer_identity",
|
|
1835
|
+
"missing_customer_name",
|
|
1836
|
+
"placeholder_customer_name",
|
|
1837
|
+
"opted_out",
|
|
1838
|
+
"already_messaged",
|
|
1839
|
+
"sender_not_ready",
|
|
1840
|
+
"missing_review_url",
|
|
1841
|
+
"no_handler",
|
|
1842
|
+
"dispatch_already_recorded",
|
|
1843
|
+
"text_back_disabled",
|
|
1844
|
+
"number_not_active",
|
|
1845
|
+
"a2p_registration_required",
|
|
1846
|
+
"alert_recipient_cannot_receive_sms",
|
|
1847
|
+
"line_type_unresolved"
|
|
1848
|
+
]);
|
|
1849
|
+
var zSaleSmsStatusSchema = z2.object({
|
|
1850
|
+
can_send_now: z2._default(z2.boolean(), false),
|
|
1851
|
+
last_message_at: z2.nullable(z2.iso.datetime({ offset: true })),
|
|
1852
|
+
reason_detail: z2.nullable(z2.string()),
|
|
1853
|
+
state: zSmsAutomationState,
|
|
1854
|
+
suppressed_by_other_sale: z2._default(z2.boolean(), false),
|
|
1855
|
+
withheld_reason: z2.nullable(zSmsWithheldReason)
|
|
1856
|
+
});
|
|
1857
|
+
var zSupportedCurrency = z2.enum(["USD", "CAD"]);
|
|
1858
|
+
var zTrackingEnvironment = z2.enum(["production", "development"]);
|
|
1859
|
+
var zSaleCreateSchema = z2.strictObject({
|
|
1860
|
+
amount_total_cents: z2.nullish(z2.int().check(z2.gte(0))),
|
|
1861
|
+
currency: zSupportedCurrency,
|
|
1862
|
+
customer_email: z2.nullish(z2.email().check(z2.maxLength(320))),
|
|
1863
|
+
customer_name: z2.nullish(z2.string().check(z2.maxLength(200))),
|
|
1864
|
+
customer_phone: z2.nullish(z2.string().check(z2.maxLength(64))),
|
|
1865
|
+
description: z2.nullish(z2.string()),
|
|
1866
|
+
environment: z2._default(z2.optional(zTrackingEnvironment), "production"),
|
|
1867
|
+
external_id: z2.nullish(z2.string()),
|
|
1868
|
+
items: z2.optional(z2.array(zSaleItemInputSchema)),
|
|
1869
|
+
metadata: z2.nullish(z2.record(z2.string(), z2.unknown())),
|
|
1870
|
+
occurred_at: z2.iso.datetime({ offset: true }),
|
|
1871
|
+
service: z2.nullish(z2.string()),
|
|
1872
|
+
services: z2.nullish(z2.array(zSaleServiceInputSchema)),
|
|
1873
|
+
sms_consent: z2.nullish(z2.boolean())
|
|
1874
|
+
});
|
|
1875
|
+
var zValidationError = z2.object({
|
|
1876
|
+
ctx: z2.optional(z2.record(z2.string(), z2.unknown())),
|
|
1877
|
+
input: z2.optional(z2.unknown()),
|
|
1878
|
+
loc: z2.array(z2.union([z2.string(), z2.int()])),
|
|
1879
|
+
msg: z2.string(),
|
|
1880
|
+
type: z2.string()
|
|
1881
|
+
});
|
|
1882
|
+
var zHttpValidationError = z2.object({
|
|
1883
|
+
detail: z2.optional(z2.array(zValidationError))
|
|
1884
|
+
});
|
|
1885
|
+
var zValidationErrorItem = z2.object({
|
|
1886
|
+
loc: z2.array(z2.union([z2.string(), z2.int()])),
|
|
1887
|
+
msg: z2.string(),
|
|
1888
|
+
type: z2.string()
|
|
1889
|
+
});
|
|
1890
|
+
var zApiErrorSchema = z2.object({
|
|
1891
|
+
code: zErrorCode,
|
|
1892
|
+
context: z2._default(z2.nullish(z2.record(z2.string(), z2.unknown())), null),
|
|
1893
|
+
detail: z2.string(),
|
|
1894
|
+
errors: z2._default(z2.nullish(z2.array(zValidationErrorItem)), null),
|
|
1895
|
+
request_id: z2._default(z2.nullish(z2.string()), null)
|
|
1896
|
+
});
|
|
1897
|
+
var zWritebackEmailSource = z2.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
|
|
1898
|
+
var zWritebackEnrichmentStatus = z2.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
|
|
1899
|
+
var zWritebackSaleUploadCounts = z2.object({
|
|
1900
|
+
failed: z2._default(z2.int(), 0),
|
|
1901
|
+
pending: z2._default(z2.int(), 0),
|
|
1902
|
+
skipped: z2._default(z2.int(), 0),
|
|
1903
|
+
submitted: z2._default(z2.int(), 0),
|
|
1904
|
+
total: z2._default(z2.int(), 0),
|
|
1905
|
+
uploaded: z2._default(z2.int(), 0)
|
|
1906
|
+
});
|
|
1907
|
+
var zSaleWritebackStatusSchema = z2.object({
|
|
1908
|
+
blocked_reason: z2.nullable(z2.string()),
|
|
1909
|
+
can_dispatch: z2._default(z2.boolean(), false),
|
|
1910
|
+
email_source: z2.nullable(zWritebackEmailSource),
|
|
1911
|
+
enrichment_status: z2.nullable(zWritebackEnrichmentStatus),
|
|
1912
|
+
gclid_attached: z2._default(z2.boolean(), false),
|
|
1913
|
+
identifiers_sent: z2.nullable(z2.string()),
|
|
1914
|
+
mapped_service_ids: z2.array(z2.uuid()),
|
|
1915
|
+
matched_submit_count: z2.nullable(z2.int()),
|
|
1916
|
+
needs_force: z2._default(z2.boolean(), false),
|
|
1917
|
+
rollup: z2.enum([
|
|
1918
|
+
"failed",
|
|
1919
|
+
"skipped",
|
|
1920
|
+
"pending",
|
|
1921
|
+
"submitted",
|
|
1922
|
+
"uploaded",
|
|
1923
|
+
"not_uploaded",
|
|
1924
|
+
"out_of_window",
|
|
1925
|
+
"blocked"
|
|
1926
|
+
]),
|
|
1927
|
+
stale: z2._default(z2.boolean(), false),
|
|
1928
|
+
uncovered_service_ids: z2.array(z2.uuid()),
|
|
1929
|
+
uploads: zWritebackSaleUploadCounts
|
|
1930
|
+
});
|
|
1931
|
+
var zSaleEntitySchema = z2.object({
|
|
1932
|
+
amount_total_cents: z2.int(),
|
|
1933
|
+
business_id: z2.uuid(),
|
|
1934
|
+
business_name: z2.nullable(z2.string()),
|
|
1935
|
+
created_at: z2.iso.datetime({ offset: true }),
|
|
1936
|
+
currency: z2.string(),
|
|
1937
|
+
customer_email: z2.nullable(z2.string()),
|
|
1938
|
+
customer_name: z2.nullable(z2.string()),
|
|
1939
|
+
customer_name_placeholder_confirmed: z2._default(z2.boolean(), false),
|
|
1940
|
+
customer_name_placeholder_confirmed_at: z2.nullable(z2.iso.datetime({ offset: true })),
|
|
1941
|
+
customer_phone: z2.nullable(z2.string()),
|
|
1942
|
+
description: z2.nullable(z2.string()),
|
|
1943
|
+
environment: zTrackingEnvironment,
|
|
1944
|
+
external_id: z2.nullable(z2.string()),
|
|
1945
|
+
id: z2.uuid(),
|
|
1946
|
+
items: z2.array(zSaleItemEntitySchema),
|
|
1947
|
+
metadata: z2.nullable(z2.record(z2.string(), z2.unknown())),
|
|
1948
|
+
occurred_at: z2.iso.datetime({ offset: true }),
|
|
1949
|
+
service_id: z2.nullable(z2.uuid()),
|
|
1950
|
+
service_key: z2.nullable(z2.string()),
|
|
1951
|
+
service_label: z2.nullable(z2.string()),
|
|
1952
|
+
services: z2.array(zSaleServiceEntitySchema),
|
|
1953
|
+
sms_automation: z2.nullable(zSaleSmsStatusSchema),
|
|
1954
|
+
sms_consent: z2._default(z2.boolean(), false),
|
|
1955
|
+
sms_consent_granted_at: z2.nullable(z2.iso.datetime({ offset: true })),
|
|
1956
|
+
updated_at: z2.iso.datetime({ offset: true }),
|
|
1957
|
+
writeback: z2.nullable(zSaleWritebackStatusSchema)
|
|
1958
|
+
});
|
|
1959
|
+
|
|
1960
|
+
// ../tracking-core/src/resources/sales/schema.ts
|
|
1961
|
+
var saleItemSchema = zSaleItemInputSchema;
|
|
1962
|
+
var saleServiceSchema = zSaleServiceInputSchema;
|
|
1963
|
+
var currencySchema = zSupportedCurrency;
|
|
1964
|
+
var SUPPORTED_CURRENCIES = currencySchema.options;
|
|
1965
|
+
var centsSchema = z3.int().check(z3.gte(0));
|
|
1966
|
+
var metadataSchema = z3.record(z3.string(), z3.unknown());
|
|
1967
|
+
var customerNameSchema = z3.string().check(z3.maxLength(200));
|
|
1968
|
+
var customerPhoneSchema = z3.string().check(z3.maxLength(64));
|
|
1969
|
+
var customerEmailSchema = z3.email().check(z3.maxLength(320));
|
|
1970
|
+
function addIssue(ctx, path, message) {
|
|
1971
|
+
ctx.issues.push({ code: "custom", input: ctx.value, path, message });
|
|
1972
|
+
}
|
|
1992
1973
|
function refineServiceXor(val, ctx, { requireAmount }) {
|
|
1993
1974
|
if (val.services != null) {
|
|
1994
1975
|
if (val.service != null) {
|
|
1995
|
-
|
|
1996
|
-
code: import_zod12.z.ZodIssueCode.custom,
|
|
1997
|
-
message: "pass either `service` or `services`, not both",
|
|
1998
|
-
path: ["services"]
|
|
1999
|
-
});
|
|
1976
|
+
addIssue(ctx, ["services"], "pass either `service` or `services`, not both");
|
|
2000
1977
|
}
|
|
2001
1978
|
if (val.services.length === 0) {
|
|
2002
|
-
|
|
2003
|
-
code: import_zod12.z.ZodIssueCode.custom,
|
|
2004
|
-
message: "`services` must not be empty",
|
|
2005
|
-
path: ["services"]
|
|
2006
|
-
});
|
|
1979
|
+
addIssue(ctx, ["services"], "`services` must not be empty");
|
|
2007
1980
|
}
|
|
2008
1981
|
const keys = val.services.map((s) => s.service);
|
|
2009
1982
|
if (new Set(keys).size !== keys.length) {
|
|
2010
|
-
|
|
2011
|
-
code: import_zod12.z.ZodIssueCode.custom,
|
|
2012
|
-
message: "`services` must not list the same service more than once",
|
|
2013
|
-
path: ["services"]
|
|
2014
|
-
});
|
|
1983
|
+
addIssue(ctx, ["services"], "`services` must not list the same service more than once");
|
|
2015
1984
|
}
|
|
2016
1985
|
if (val.amount_total_cents != null) {
|
|
2017
1986
|
const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
|
|
2018
1987
|
if (val.amount_total_cents !== sum) {
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
1988
|
+
addIssue(
|
|
1989
|
+
ctx,
|
|
1990
|
+
["amount_total_cents"],
|
|
1991
|
+
"amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)"
|
|
1992
|
+
);
|
|
2024
1993
|
}
|
|
2025
1994
|
}
|
|
2026
1995
|
} else if (requireAmount && val.amount_total_cents == null) {
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
1996
|
+
addIssue(
|
|
1997
|
+
ctx,
|
|
1998
|
+
["amount_total_cents"],
|
|
1999
|
+
"amount_total_cents is required unless `services` is provided"
|
|
2000
|
+
);
|
|
2032
2001
|
}
|
|
2033
2002
|
}
|
|
2034
|
-
var saleCreateSchema =
|
|
2035
|
-
|
|
2036
|
-
description:
|
|
2037
|
-
service:
|
|
2038
|
-
services:
|
|
2039
|
-
currency: currencySchema,
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
items: import_zod12.z.array(saleItemSchema).default([]),
|
|
2046
|
-
metadata: metadataSchema.nullable().optional(),
|
|
2047
|
-
customer_name: customerNameSchema.nullable().optional(),
|
|
2048
|
-
customer_phone: customerPhoneSchema.nullable().optional(),
|
|
2049
|
-
customer_email: customerEmailSchema.nullable().optional(),
|
|
2050
|
-
// CASL consent attestation: the customer agreed to receive SMS. Recorded
|
|
2051
|
-
// with a timestamp server-side; every SMS send path gates on it.
|
|
2052
|
-
//
|
|
2053
|
-
// Tri-state: omit it (or send null) to let the server apply the business's
|
|
2054
|
-
// configured default-opt-in policy, honouring a returning customer's
|
|
2055
|
-
// remembered preference. Send an explicit boolean to assert consent state
|
|
2056
|
-
// yourself — `false` records a deliberate opt-out.
|
|
2057
|
-
sms_consent: import_zod12.z.boolean().nullable().optional()
|
|
2058
|
-
}).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
|
|
2059
|
-
var saleUpdateSchema = import_zod12.z.object({
|
|
2060
|
-
description: import_zod12.z.string().nullable().optional(),
|
|
2061
|
-
service: import_zod12.z.string().nullable().optional(),
|
|
2062
|
-
services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
|
|
2063
|
-
currency: currencySchema.optional(),
|
|
2064
|
-
amount_total_cents: centsSchema.optional(),
|
|
2065
|
-
occurred_at: import_zod12.z.string().datetime().optional(),
|
|
2066
|
-
items: import_zod12.z.array(saleItemSchema).optional(),
|
|
2067
|
-
metadata: metadataSchema.nullable().optional(),
|
|
2068
|
-
customer_name: customerNameSchema.nullable().optional(),
|
|
2003
|
+
var saleCreateSchema = z3.extend(zSaleCreateSchema, { items: z3._default(z3.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
|
|
2004
|
+
var saleUpdateSchema = z3.strictObject({
|
|
2005
|
+
description: z3.nullish(z3.string()),
|
|
2006
|
+
service: z3.nullish(z3.string()),
|
|
2007
|
+
services: z3.nullish(z3.array(saleServiceSchema)),
|
|
2008
|
+
currency: z3.optional(currencySchema),
|
|
2009
|
+
amount_total_cents: z3.optional(centsSchema),
|
|
2010
|
+
occurred_at: z3.optional(z3.iso.datetime()),
|
|
2011
|
+
items: z3.optional(z3.array(saleItemSchema)),
|
|
2012
|
+
metadata: z3.nullish(metadataSchema),
|
|
2013
|
+
customer_name: z3.nullish(customerNameSchema),
|
|
2069
2014
|
// Re-attest when changing a filler-looking name; the server clears the
|
|
2070
2015
|
// prior attestation whenever `customer_name` changes.
|
|
2071
|
-
customer_name_placeholder_confirmed:
|
|
2072
|
-
customer_phone:
|
|
2073
|
-
customer_email:
|
|
2016
|
+
customer_name_placeholder_confirmed: z3.optional(z3.boolean()),
|
|
2017
|
+
customer_phone: z3.nullish(customerPhoneSchema),
|
|
2018
|
+
customer_email: z3.nullish(customerEmailSchema),
|
|
2074
2019
|
// NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
|
|
2075
|
-
sms_consent:
|
|
2076
|
-
}).
|
|
2020
|
+
sms_consent: z3.optional(z3.boolean())
|
|
2021
|
+
}).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
|
|
2077
2022
|
var TRACKING_RANGES = ["24h", "7d", "30d"];
|
|
2078
2023
|
var NAMED_RANGES = [
|
|
2079
2024
|
"today",
|
|
@@ -2144,8 +2089,8 @@ function instantFromWallClock(timeZone, year, month, day, hour = 0, minute = 0)
|
|
|
2144
2089
|
const corrected = naive - offsetMinutesAt(firstGuess, timeZone) * 6e4;
|
|
2145
2090
|
return new Date(corrected);
|
|
2146
2091
|
}
|
|
2147
|
-
function localDateKey(
|
|
2148
|
-
const p = partsInTz(new Date(
|
|
2092
|
+
function localDateKey(iso4, timeZone) {
|
|
2093
|
+
const p = partsInTz(new Date(iso4), timeZone);
|
|
2149
2094
|
const pad = (n) => String(n).padStart(2, "0");
|
|
2150
2095
|
return `${p.year}-${pad(p.month)}-${pad(p.day)}`;
|
|
2151
2096
|
}
|
|
@@ -2200,7 +2145,167 @@ function isCalendarError(error, code) {
|
|
|
2200
2145
|
}
|
|
2201
2146
|
|
|
2202
2147
|
// ../tracking-core/src/resources/calendar/schema.ts
|
|
2203
|
-
var
|
|
2148
|
+
var z5 = __toESM(require("zod/mini"));
|
|
2149
|
+
|
|
2150
|
+
// ../tracking-core/src/resources/calendar/generated/zod.gen.ts
|
|
2151
|
+
var z4 = __toESM(require("zod/mini"));
|
|
2152
|
+
var zBookingAttendee = z4.strictObject({
|
|
2153
|
+
display_name: z4.nullish(z4.string().check(z4.maxLength(200))),
|
|
2154
|
+
email: z4.email().check(z4.maxLength(320)),
|
|
2155
|
+
optional: z4._default(z4.optional(z4.boolean()), false)
|
|
2156
|
+
});
|
|
2157
|
+
var zBookingCancelSchema = z4.strictObject({
|
|
2158
|
+
notify_attendees: z4._default(z4.optional(z4.boolean()), true),
|
|
2159
|
+
reason: z4.nullish(z4.string().check(z4.maxLength(500)))
|
|
2160
|
+
});
|
|
2161
|
+
var zBookingCustomerInput = z4.strictObject({
|
|
2162
|
+
email: z4.email().check(z4.maxLength(320)),
|
|
2163
|
+
name: z4.nullish(z4.string().check(z4.maxLength(200))),
|
|
2164
|
+
phone: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2165
|
+
sms_consent: z4._default(z4.optional(z4.boolean()), false)
|
|
2166
|
+
});
|
|
2167
|
+
var zBookingCustomerOutput = z4.strictObject({
|
|
2168
|
+
email: z4.email().check(z4.maxLength(320)),
|
|
2169
|
+
name: z4.nullable(z4.string().check(z4.maxLength(200))),
|
|
2170
|
+
phone: z4.nullable(z4.string().check(z4.maxLength(64))),
|
|
2171
|
+
sms_consent: z4._default(z4.boolean(), false)
|
|
2172
|
+
});
|
|
2173
|
+
var zBookingRescheduleSchema = z4.strictObject({
|
|
2174
|
+
duration_minutes: z4.nullish(z4.int().check(z4.gt(0), z4.lte(1440))),
|
|
2175
|
+
end_at: z4.nullish(z4.iso.datetime({ offset: true })),
|
|
2176
|
+
notify_attendees: z4._default(z4.optional(z4.boolean()), true),
|
|
2177
|
+
reason: z4.nullish(z4.string().check(z4.maxLength(500))),
|
|
2178
|
+
start_at: z4.iso.datetime({ offset: true }),
|
|
2179
|
+
time_zone: z4.string().check(z4.minLength(1), z4.maxLength(64), z4.regex(/^[A-Za-z0-9_+\-\/]+$/))
|
|
2180
|
+
});
|
|
2181
|
+
var zBookingResponse = z4.strictObject({
|
|
2182
|
+
appointment_type: z4.nullable(z4.string()),
|
|
2183
|
+
calendar_key: z4.string(),
|
|
2184
|
+
customer: zBookingCustomerOutput,
|
|
2185
|
+
end_at: z4.iso.datetime({ offset: true }),
|
|
2186
|
+
google_html_link: z4.nullable(z4.string()),
|
|
2187
|
+
google_sync_state: z4.string(),
|
|
2188
|
+
id: z4.string(),
|
|
2189
|
+
manage_token: z4.nullable(z4.string()),
|
|
2190
|
+
meet_url: z4.nullable(z4.string()),
|
|
2191
|
+
start_at: z4.iso.datetime({ offset: true }),
|
|
2192
|
+
status: z4.string(),
|
|
2193
|
+
time_zone: z4.string(),
|
|
2194
|
+
title: z4.string()
|
|
2195
|
+
});
|
|
2196
|
+
var zBookingSource = z4.enum(["website", "phone", "walk_in", "import", "operator"]);
|
|
2197
|
+
var zBookingMetadata = z4.strictObject({
|
|
2198
|
+
custom: z4.nullish(
|
|
2199
|
+
z4.record(z4.string(), z4.nullable(z4.union([z4.string(), z4.int(), z4.number(), z4.boolean()])))
|
|
2200
|
+
),
|
|
2201
|
+
fbclid: z4.nullish(z4.string().check(z4.maxLength(256))),
|
|
2202
|
+
gclid: z4.nullish(z4.string().check(z4.maxLength(256))),
|
|
2203
|
+
landing_page: z4.nullish(z4.string().check(z4.maxLength(2048))),
|
|
2204
|
+
notes: z4.nullish(z4.string().check(z4.maxLength(2e3))),
|
|
2205
|
+
referrer: z4.nullish(z4.string().check(z4.maxLength(2048))),
|
|
2206
|
+
schema_version: z4._default(z4.optional(z4.int()), 1),
|
|
2207
|
+
service: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2208
|
+
session_id: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2209
|
+
source: z4.nullish(zBookingSource),
|
|
2210
|
+
utm_campaign: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2211
|
+
utm_content: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2212
|
+
utm_medium: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2213
|
+
utm_source: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2214
|
+
utm_term: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2215
|
+
visitor_id: z4.nullish(z4.string().check(z4.maxLength(64)))
|
|
2216
|
+
});
|
|
2217
|
+
var zCustomLocation = z4.strictObject({
|
|
2218
|
+
kind: z4.literal("custom"),
|
|
2219
|
+
text: z4.string().check(z4.maxLength(1024))
|
|
2220
|
+
});
|
|
2221
|
+
var zErrorCode2 = z4.enum([
|
|
2222
|
+
"missing_credentials",
|
|
2223
|
+
"invalid_api_key",
|
|
2224
|
+
"not_authenticated",
|
|
2225
|
+
"wrong_key_type",
|
|
2226
|
+
"origin_missing",
|
|
2227
|
+
"origin_not_allowed",
|
|
2228
|
+
"capability_denied",
|
|
2229
|
+
"session_required",
|
|
2230
|
+
"operator_only",
|
|
2231
|
+
"cross_tenant",
|
|
2232
|
+
"business_id_required",
|
|
2233
|
+
"bad_request",
|
|
2234
|
+
"not_found",
|
|
2235
|
+
"conflict",
|
|
2236
|
+
"incompatible_payload",
|
|
2237
|
+
"repeat_confirmation_required",
|
|
2238
|
+
"idempotency_conflict",
|
|
2239
|
+
"validation_error",
|
|
2240
|
+
"unknown_service",
|
|
2241
|
+
"invalid_sale_properties",
|
|
2242
|
+
"invalid_cursor",
|
|
2243
|
+
"rate_limited",
|
|
2244
|
+
"internal_error"
|
|
2245
|
+
]);
|
|
2246
|
+
var zMeetLocation = z4.strictObject({
|
|
2247
|
+
kind: z4.literal("google_meet")
|
|
2248
|
+
});
|
|
2249
|
+
var zPhoneLocation = z4.strictObject({
|
|
2250
|
+
kind: z4.literal("phone"),
|
|
2251
|
+
phone: z4.string().check(z4.maxLength(64))
|
|
2252
|
+
});
|
|
2253
|
+
var zPhysicalLocation = z4.strictObject({
|
|
2254
|
+
address: z4.string().check(z4.maxLength(1024)),
|
|
2255
|
+
kind: z4.literal("physical")
|
|
2256
|
+
});
|
|
2257
|
+
var zReminderMethod = z4.enum(["email", "popup"]);
|
|
2258
|
+
var zBookingReminder = z4.strictObject({
|
|
2259
|
+
method: zReminderMethod,
|
|
2260
|
+
minutes_before: z4.int().check(z4.gte(0), z4.lte(40320))
|
|
2261
|
+
});
|
|
2262
|
+
var zBookingReminders = z4.strictObject({
|
|
2263
|
+
overrides: z4.optional(z4.array(zBookingReminder).check(z4.maxLength(5))),
|
|
2264
|
+
use_calendar_defaults: z4._default(z4.optional(z4.boolean()), true)
|
|
2265
|
+
});
|
|
2266
|
+
var zBookingCreateSchema = z4.strictObject({
|
|
2267
|
+
appointment_type: z4.nullish(z4.string().check(z4.maxLength(64))),
|
|
2268
|
+
attendees: z4.optional(z4.array(zBookingAttendee).check(z4.maxLength(20))),
|
|
2269
|
+
buffer_after_minutes: z4._default(z4.optional(z4.int().check(z4.gte(0), z4.lte(1440))), 0),
|
|
2270
|
+
buffer_before_minutes: z4._default(z4.optional(z4.int().check(z4.gte(0), z4.lte(1440))), 0),
|
|
2271
|
+
calendar_key: z4.string().check(z4.minLength(1), z4.maxLength(64)),
|
|
2272
|
+
customer: zBookingCustomerInput,
|
|
2273
|
+
description: z4.nullish(z4.string().check(z4.maxLength(8e3))),
|
|
2274
|
+
duration_minutes: z4.nullish(z4.int().check(z4.gt(0), z4.lte(1440))),
|
|
2275
|
+
end_at: z4.nullish(z4.iso.datetime({ offset: true })),
|
|
2276
|
+
idempotency_key: z4.nullish(z4.string().check(z4.maxLength(128))),
|
|
2277
|
+
location: z4.nullish(z4.union([zMeetLocation, zPhysicalLocation, zPhoneLocation, zCustomLocation])),
|
|
2278
|
+
metadata: z4.nullish(zBookingMetadata),
|
|
2279
|
+
reminders: z4.nullish(zBookingReminders),
|
|
2280
|
+
send_invites: z4._default(z4.optional(z4.boolean()), true),
|
|
2281
|
+
start_at: z4.iso.datetime({ offset: true }),
|
|
2282
|
+
time_zone: z4.string().check(z4.minLength(1), z4.maxLength(64), z4.regex(/^[A-Za-z0-9_+\-\/]+$/)),
|
|
2283
|
+
title: z4.nullish(z4.string().check(z4.maxLength(300)))
|
|
2284
|
+
});
|
|
2285
|
+
var zValidationError2 = z4.object({
|
|
2286
|
+
ctx: z4.optional(z4.record(z4.string(), z4.unknown())),
|
|
2287
|
+
input: z4.optional(z4.unknown()),
|
|
2288
|
+
loc: z4.array(z4.union([z4.string(), z4.int()])),
|
|
2289
|
+
msg: z4.string(),
|
|
2290
|
+
type: z4.string()
|
|
2291
|
+
});
|
|
2292
|
+
var zHttpValidationError2 = z4.object({
|
|
2293
|
+
detail: z4.optional(z4.array(zValidationError2))
|
|
2294
|
+
});
|
|
2295
|
+
var zValidationErrorItem2 = z4.object({
|
|
2296
|
+
loc: z4.array(z4.union([z4.string(), z4.int()])),
|
|
2297
|
+
msg: z4.string(),
|
|
2298
|
+
type: z4.string()
|
|
2299
|
+
});
|
|
2300
|
+
var zApiErrorSchema2 = z4.object({
|
|
2301
|
+
code: zErrorCode2,
|
|
2302
|
+
context: z4._default(z4.nullish(z4.record(z4.string(), z4.unknown())), null),
|
|
2303
|
+
detail: z4.string(),
|
|
2304
|
+
errors: z4._default(z4.nullish(z4.array(zValidationErrorItem2)), null),
|
|
2305
|
+
request_id: z4._default(z4.nullish(z4.string()), null)
|
|
2306
|
+
});
|
|
2307
|
+
|
|
2308
|
+
// ../tracking-core/src/resources/calendar/schema.ts
|
|
2204
2309
|
var CALENDAR_METADATA_SCHEMA_VERSION = 1;
|
|
2205
2310
|
var MAX_ATTENDEES = 20;
|
|
2206
2311
|
var MAX_REMINDER_OVERRIDES = 5;
|
|
@@ -2226,7 +2331,6 @@ var CALENDAR_ERROR_CODES = [
|
|
|
2226
2331
|
"rate_limited",
|
|
2227
2332
|
"google_error"
|
|
2228
2333
|
];
|
|
2229
|
-
var isoInstant = import_zod13.z.string().datetime({ offset: true });
|
|
2230
2334
|
function isKnownTimeZone(timeZone) {
|
|
2231
2335
|
try {
|
|
2232
2336
|
new Intl.DateTimeFormat(void 0, { timeZone });
|
|
@@ -2235,107 +2339,65 @@ function isKnownTimeZone(timeZone) {
|
|
|
2235
2339
|
return false;
|
|
2236
2340
|
}
|
|
2237
2341
|
}
|
|
2238
|
-
var ianaTz =
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
var
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
})
|
|
2252
|
-
var bookingLocationSchema =
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2342
|
+
var ianaTz = z5.string().check(
|
|
2343
|
+
z5.minLength(1),
|
|
2344
|
+
z5.maxLength(64),
|
|
2345
|
+
z5.regex(/^[A-Za-z0-9_+\-/]+$/),
|
|
2346
|
+
z5.refine(isKnownTimeZone, { error: "unknown IANA time zone" })
|
|
2347
|
+
);
|
|
2348
|
+
var bookingAttendeeSchema = zBookingAttendee;
|
|
2349
|
+
var bookingReminderSchema = zBookingReminder;
|
|
2350
|
+
var bookingCustomerSchema = zBookingCustomerInput;
|
|
2351
|
+
var bookingMetadataSchema = z5.extend(zBookingMetadata, {
|
|
2352
|
+
custom: z5.nullish(
|
|
2353
|
+
z5.record(z5.string(), z5.union([z5.string(), z5.int(), z5.number(), z5.boolean(), z5.null()]))
|
|
2354
|
+
)
|
|
2355
|
+
});
|
|
2356
|
+
var bookingLocationSchema = z5.union([
|
|
2357
|
+
zMeetLocation,
|
|
2358
|
+
zPhysicalLocation,
|
|
2359
|
+
zPhoneLocation,
|
|
2360
|
+
zCustomLocation
|
|
2361
|
+
]);
|
|
2362
|
+
var bookingLocationNullableSchema = z5.union([
|
|
2363
|
+
...bookingLocationSchema.def.options,
|
|
2364
|
+
z5.null()
|
|
2257
2365
|
]);
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
// booking, and that invite is the whole confirmation mechanism.
|
|
2262
|
-
email: import_zod13.z.string().max(320).email(),
|
|
2263
|
-
name: import_zod13.z.string().max(200).nullable().optional(),
|
|
2264
|
-
phone: import_zod13.z.string().max(64).nullable().optional(),
|
|
2265
|
-
sms_consent: import_zod13.z.boolean().default(false)
|
|
2266
|
-
}).strict();
|
|
2267
|
-
var jsonScalar = import_zod13.z.union([import_zod13.z.string(), import_zod13.z.number(), import_zod13.z.boolean(), import_zod13.z.null()]);
|
|
2268
|
-
var bookingMetadataSchema = import_zod13.z.object({
|
|
2269
|
-
schema_version: import_zod13.z.number().int().default(CALENDAR_METADATA_SCHEMA_VERSION),
|
|
2270
|
-
source: import_zod13.z.enum(BOOKING_SOURCES).nullable().optional(),
|
|
2271
|
-
service: import_zod13.z.string().max(64).nullable().optional(),
|
|
2272
|
-
visitor_id: import_zod13.z.string().max(64).nullable().optional(),
|
|
2273
|
-
session_id: import_zod13.z.string().max(64).nullable().optional(),
|
|
2274
|
-
gclid: import_zod13.z.string().max(256).nullable().optional(),
|
|
2275
|
-
fbclid: import_zod13.z.string().max(256).nullable().optional(),
|
|
2276
|
-
utm_source: import_zod13.z.string().max(128).nullable().optional(),
|
|
2277
|
-
utm_medium: import_zod13.z.string().max(128).nullable().optional(),
|
|
2278
|
-
utm_campaign: import_zod13.z.string().max(128).nullable().optional(),
|
|
2279
|
-
utm_term: import_zod13.z.string().max(128).nullable().optional(),
|
|
2280
|
-
utm_content: import_zod13.z.string().max(128).nullable().optional(),
|
|
2281
|
-
landing_page: import_zod13.z.string().max(2048).nullable().optional(),
|
|
2282
|
-
referrer: import_zod13.z.string().max(2048).nullable().optional(),
|
|
2283
|
-
notes: import_zod13.z.string().max(2e3).nullable().optional(),
|
|
2284
|
-
custom: import_zod13.z.record(jsonScalar).nullable().optional()
|
|
2285
|
-
}).strict();
|
|
2366
|
+
function addIssue2(ctx, path, message) {
|
|
2367
|
+
ctx.issues.push({ code: "custom", input: ctx.value, path, message });
|
|
2368
|
+
}
|
|
2286
2369
|
function refineEndXor(value, ctx) {
|
|
2287
2370
|
const hasEnd = value.end_at !== void 0 && value.end_at !== null;
|
|
2288
2371
|
const hasDuration = value.duration_minutes !== void 0 && value.duration_minutes !== null;
|
|
2289
2372
|
if (hasEnd === hasDuration) {
|
|
2290
|
-
ctx
|
|
2291
|
-
code: import_zod13.z.ZodIssueCode.custom,
|
|
2292
|
-
message: "provide exactly one of end_at or duration_minutes",
|
|
2293
|
-
path: ["end_at"]
|
|
2294
|
-
});
|
|
2373
|
+
addIssue2(ctx, ["end_at"], "provide exactly one of end_at or duration_minutes");
|
|
2295
2374
|
return;
|
|
2296
2375
|
}
|
|
2297
2376
|
if (hasEnd && new Date(value.end_at) <= new Date(value.start_at)) {
|
|
2298
|
-
ctx
|
|
2299
|
-
code: import_zod13.z.ZodIssueCode.custom,
|
|
2300
|
-
message: "end_at must be after start_at",
|
|
2301
|
-
path: ["end_at"]
|
|
2302
|
-
});
|
|
2377
|
+
addIssue2(ctx, ["end_at"], "end_at must be after start_at");
|
|
2303
2378
|
}
|
|
2304
2379
|
}
|
|
2305
|
-
var
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
duration_minutes: import_zod13.z.number().int().positive().max(MAX_BOOKING_MINUTES).nullable().optional(),
|
|
2313
|
-
/** The booker's zone — distinct from the business's and the calendar's. */
|
|
2314
|
-
time_zone: ianaTz,
|
|
2315
|
-
title: import_zod13.z.string().max(300).nullable().optional(),
|
|
2316
|
-
description: import_zod13.z.string().max(8e3).nullable().optional(),
|
|
2317
|
-
location: bookingLocationNullableSchema.optional(),
|
|
2318
|
-
customer: bookingCustomerSchema,
|
|
2319
|
-
attendees: import_zod13.z.array(bookingAttendeeSchema).max(MAX_ATTENDEES).default([]),
|
|
2320
|
-
send_invites: import_zod13.z.boolean().default(true),
|
|
2321
|
-
reminders: bookingRemindersSchema.nullable().optional(),
|
|
2322
|
-
metadata: bookingMetadataSchema.nullable().optional(),
|
|
2323
|
-
idempotency_key: import_zod13.z.string().max(128).nullable().optional(),
|
|
2324
|
-
buffer_before_minutes: import_zod13.z.number().int().min(0).max(MAX_BOOKING_MINUTES).default(0),
|
|
2325
|
-
buffer_after_minutes: import_zod13.z.number().int().min(0).max(MAX_BOOKING_MINUTES).default(0)
|
|
2326
|
-
}).strict().superRefine(refineEndXor);
|
|
2327
|
-
var bookingRescheduleSchema = import_zod13.z.object({
|
|
2328
|
-
start_at: isoInstant,
|
|
2329
|
-
end_at: isoInstant.nullable().optional(),
|
|
2330
|
-
duration_minutes: import_zod13.z.number().int().positive().max(MAX_BOOKING_MINUTES).nullable().optional(),
|
|
2380
|
+
var bookingRemindersSchema = z5.extend(zBookingReminders, {
|
|
2381
|
+
overrides: z5._default(
|
|
2382
|
+
z5.array(bookingReminderSchema).check(z5.maxLength(MAX_REMINDER_OVERRIDES)),
|
|
2383
|
+
[]
|
|
2384
|
+
)
|
|
2385
|
+
});
|
|
2386
|
+
var bookingCreateSchema = z5.extend(zBookingCreateSchema, {
|
|
2331
2387
|
time_zone: ianaTz,
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2388
|
+
// The generated field is `z.union([...variants]).nullish()`, which nests one
|
|
2389
|
+
// `anyOf` inside another; Pydantic's `BookingLocation | None` flattens to a
|
|
2390
|
+
// single list and the drift snapshot compares structure. Override with the
|
|
2391
|
+
// flattened union.
|
|
2392
|
+
location: z5.optional(bookingLocationNullableSchema),
|
|
2393
|
+
attendees: z5._default(z5.array(bookingAttendeeSchema).check(z5.maxLength(MAX_ATTENDEES)), []),
|
|
2394
|
+
// These reference the un-composed generated schemas; generation can't nest
|
|
2395
|
+
// our compositions into its own output.
|
|
2396
|
+
reminders: z5.nullish(bookingRemindersSchema),
|
|
2397
|
+
metadata: z5.nullish(bookingMetadataSchema)
|
|
2398
|
+
}).check((ctx) => refineEndXor(ctx.value, ctx));
|
|
2399
|
+
var bookingRescheduleSchema = z5.extend(zBookingRescheduleSchema, { time_zone: ianaTz }).check((ctx) => refineEndXor(ctx.value, ctx));
|
|
2400
|
+
var bookingCancelSchema = zBookingCancelSchema;
|
|
2339
2401
|
|
|
2340
2402
|
// ../tracking-core/src/resources/calendar/slots.ts
|
|
2341
2403
|
function parseHhMm(value) {
|
|
@@ -2563,6 +2625,7 @@ var import_client2 = require("@aranova/tracking-next/client");
|
|
|
2563
2625
|
createTrackingClientContext,
|
|
2564
2626
|
createTrackingEventCreatePayload,
|
|
2565
2627
|
createTrackingSessionUpsertPayload,
|
|
2628
|
+
currencySchema,
|
|
2566
2629
|
durationMinutes,
|
|
2567
2630
|
endOfDayInTz,
|
|
2568
2631
|
fetchServices,
|