@aranova/tracking-next 0.26.0 → 1.0.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.
Files changed (73) hide show
  1. package/dist/blog-server.d.mts +2 -1
  2. package/dist/blog-server.d.ts +2 -1
  3. package/dist/blog-server.js +121 -98
  4. package/dist/blog-server.js.map +1 -1
  5. package/dist/blog-server.mjs +86 -63
  6. package/dist/blog-server.mjs.map +1 -1
  7. package/dist/blog.d.mts +651 -1755
  8. package/dist/blog.d.ts +651 -1755
  9. package/dist/blog.js +121 -98
  10. package/dist/blog.js.map +1 -1
  11. package/dist/blog.mjs +86 -63
  12. package/dist/blog.mjs.map +1 -1
  13. package/dist/calendar-server.d.mts +2 -2
  14. package/dist/calendar-server.d.ts +2 -2
  15. package/dist/calendar-server.js +0 -26
  16. package/dist/calendar-server.js.map +1 -1
  17. package/dist/calendar-server.mjs +0 -26
  18. package/dist/calendar-server.mjs.map +1 -1
  19. package/dist/calendar.d.mts +3 -3
  20. package/dist/calendar.d.ts +3 -3
  21. package/dist/calendar.js +227 -126
  22. package/dist/calendar.js.map +1 -1
  23. package/dist/calendar.mjs +216 -125
  24. package/dist/calendar.mjs.map +1 -1
  25. package/dist/client.d.mts +5 -4
  26. package/dist/client.d.ts +5 -4
  27. package/dist/client.js +197 -283
  28. package/dist/client.js.map +1 -1
  29. package/dist/client.mjs +169 -255
  30. package/dist/client.mjs.map +1 -1
  31. package/dist/index.d.mts +9 -8
  32. package/dist/index.d.ts +9 -8
  33. package/dist/index.js +486 -485
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +475 -485
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/ingest-typed-BdKmlouW.d.ts +791 -0
  38. package/dist/ingest-typed-Bo7WPmpU.d.mts +791 -0
  39. package/dist/middleware.js +0 -465
  40. package/dist/middleware.js.map +1 -1
  41. package/dist/middleware.mjs +0 -465
  42. package/dist/middleware.mjs.map +1 -1
  43. package/dist/{phone-utils-BVzSNBf1.d.mts → phone-utils-CubQif9Z.d.mts} +18 -78
  44. package/dist/{phone-utils-BVzSNBf1.d.ts → phone-utils-CubQif9Z.d.ts} +18 -78
  45. package/dist/phone.d.mts +2 -2
  46. package/dist/phone.d.ts +2 -2
  47. package/dist/phone.js +0 -462
  48. package/dist/phone.js.map +1 -1
  49. package/dist/phone.mjs +0 -462
  50. package/dist/phone.mjs.map +1 -1
  51. package/dist/{sales-f1iXwlaV.d.mts → sales-D7KstKA-.d.mts} +90 -329
  52. package/dist/{sales-C3dIw4LW.d.ts → sales-DG150g3o.d.ts} +90 -329
  53. package/dist/sales.d.mts +3 -3
  54. package/dist/sales.d.ts +3 -3
  55. package/dist/sales.js +265 -127
  56. package/dist/sales.js.map +1 -1
  57. package/dist/sales.mjs +254 -127
  58. package/dist/sales.mjs.map +1 -1
  59. package/dist/server.d.mts +2 -2
  60. package/dist/server.d.ts +2 -2
  61. package/dist/server.js +0 -465
  62. package/dist/server.js.map +1 -1
  63. package/dist/server.mjs +0 -465
  64. package/dist/server.mjs.map +1 -1
  65. package/dist/{tracking-config-runtime-BnUlS_Ae.d.mts → tracking-config-runtime-D7prdTE1.d.mts} +6 -0
  66. package/dist/{tracking-config-runtime-BnUlS_Ae.d.ts → tracking-config-runtime-D7prdTE1.d.ts} +6 -0
  67. package/dist/transport-CDmGOiCq.d.ts +253 -0
  68. package/dist/transport-I_cMSFQ6.d.mts +253 -0
  69. package/package.json +2 -2
  70. package/dist/ingest-typed-BioxtBJD.d.mts +0 -1365
  71. package/dist/ingest-typed-C-SPiigr.d.ts +0 -1365
  72. package/dist/transport-C-_rFSR4.d.ts +0 -721
  73. package/dist/transport-yUF5Wize.d.mts +0 -721
package/dist/index.mjs CHANGED
@@ -47,7 +47,7 @@ function normalizeEmail(raw) {
47
47
  return EMAIL_SHAPE.test(cleaned) ? cleaned : null;
48
48
  }
49
49
  function stashUserData(data, country) {
50
- const email = normalizeEmail(data.email);
50
+ const email4 = normalizeEmail(data.email);
51
51
  let phoneNumber = null;
52
52
  if (typeof data.phone === "string" && data.phone.length > 0) {
53
53
  try {
@@ -57,7 +57,7 @@ function stashUserData(data, country) {
57
57
  }
58
58
  }
59
59
  stash = {
60
- email: email ?? stash.email,
60
+ email: email4 ?? stash.email,
61
61
  phoneNumber: phoneNumber ?? stash.phoneNumber
62
62
  };
63
63
  }
@@ -66,11 +66,11 @@ function clearStashedUserData() {
66
66
  }
67
67
  function applyUserDataForConversion(explicit, country) {
68
68
  if (typeof window === "undefined" || typeof window.gtag !== "function") return false;
69
- let email = stash.email;
69
+ let email4 = stash.email;
70
70
  let phoneNumber = stash.phoneNumber;
71
71
  if (explicit) {
72
72
  const normalizedEmail = normalizeEmail(explicit.email);
73
- if (normalizedEmail) email = normalizedEmail;
73
+ if (normalizedEmail) email4 = normalizedEmail;
74
74
  if (typeof explicit.phone === "string" && explicit.phone.length > 0) {
75
75
  try {
76
76
  phoneNumber = toE164(explicit.phone, country) ?? phoneNumber;
@@ -78,10 +78,10 @@ function applyUserDataForConversion(explicit, country) {
78
78
  }
79
79
  }
80
80
  }
81
- if (email === null && phoneNumber === null) return false;
81
+ if (email4 === null && phoneNumber === null) return false;
82
82
  try {
83
83
  window.gtag("set", "user_data", {
84
- ...email !== null ? { email } : {},
84
+ ...email4 !== null ? { email: email4 } : {},
85
85
  ...phoneNumber !== null ? { phone_number: phoneNumber } : {}
86
86
  });
87
87
  return true;
@@ -437,10 +437,10 @@ function readStoredRecord() {
437
437
  return null;
438
438
  }
439
439
  }
440
- function writeRecord(record) {
441
- memoryRecord = record;
440
+ function writeRecord(record5) {
441
+ memoryRecord = record5;
442
442
  try {
443
- window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record));
443
+ window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record5));
444
444
  } catch {
445
445
  }
446
446
  }
@@ -462,9 +462,9 @@ function getOrCaptureLandingParams(sessionId, url) {
462
462
  if (memoryRecord && memoryRecord.session_id === sessionId) {
463
463
  return memoryRecord.params;
464
464
  }
465
- const record = { session_id: sessionId, params: captureFromUrl(url) };
466
- writeRecord(record);
467
- return record.params;
465
+ const record5 = { session_id: sessionId, params: captureFromUrl(url) };
466
+ writeRecord(record5);
467
+ return record5.params;
468
468
  }
469
469
  function buildLandingPayloadFields(sessionId, override) {
470
470
  const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
@@ -841,9 +841,9 @@ function automaticThresholdMet(goal, eventType, metadata) {
841
841
  }
842
842
 
843
843
  // ../tracking-core/src/resources/intl/date.ts
844
- function formatDateInTz(iso, timeZone, opts, locale) {
845
- const date = new Date(iso);
846
- if (Number.isNaN(date.getTime())) return iso;
844
+ function formatDateInTz(iso4, timeZone, opts, locale) {
845
+ const date = new Date(iso4);
846
+ if (Number.isNaN(date.getTime())) return iso4;
847
847
  return new Intl.DateTimeFormat(locale, {
848
848
  year: "numeric",
849
849
  month: "short",
@@ -877,14 +877,15 @@ function formatMoney(cents, currency, locale) {
877
877
 
878
878
  // ../tracking-core/src/resources/tracking-config-runtime.ts
879
879
  var DEFAULT_CDN_BASE_URL = "https://demos.aranova.io";
880
- function trackingConfigKey(businessId, environment) {
881
- return `tracking-config/v1/${businessId}-${environment}.json`;
880
+ function trackingConfigKey(ref) {
881
+ if (ref.siteId) return `tracking-config/v1/sites/${ref.siteId}-${ref.environment}.json`;
882
+ return `tracking-config/v1/${ref.businessId}-${ref.environment}.json`;
882
883
  }
883
884
  function resolveTrackingConfigUrl(ref) {
884
885
  if (ref.cdnUrl) return ref.cdnUrl;
885
886
  const configured = ref.cdnBaseUrl?.trim();
886
887
  const base = (configured || DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
887
- return `${base}/${trackingConfigKey(ref.businessId, ref.environment)}`;
888
+ return `${base}/${trackingConfigKey(ref)}`;
888
889
  }
889
890
  var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
890
891
  var AUTHORITY_TTL_MS = 6e4;
@@ -1254,29 +1255,6 @@ function getTrackingConfigRuntime(ref, fetchImpl) {
1254
1255
  return runtime;
1255
1256
  }
1256
1257
 
1257
- // ../tracking-core/src/session.ts
1258
- var SESSION_IDLE_MS = 30 * 60 * 1e3;
1259
-
1260
- // ../tracking-core/src/events/page-view.ts
1261
- import { z } from "zod";
1262
- var pageViewMetadataSchema = z.object({
1263
- page: z.object({
1264
- title: z.string().nullable(),
1265
- path: z.string(),
1266
- search: z.string(),
1267
- hash: z.string()
1268
- }).strict(),
1269
- referrer: z.string().nullable(),
1270
- // `.nullable().optional()` — absent (undefined) OR explicit null OR a
1271
- // real viewport object. Mirrors Pydantic's `_Viewport | None = None`
1272
- // on the backend side so the drift test stays clean.
1273
- viewport: z.object({
1274
- w: z.number(),
1275
- h: z.number()
1276
- }).strict().nullable().optional()
1277
- }).strict();
1278
- var pageViewConfigSchema = z.object({}).strict();
1279
-
1280
1258
  // ../tracking-core/src/ingest.ts
1281
1259
  var API_KEY_HEADER = "X-Aranova-Api-Key";
1282
1260
  var SDK_VERSION_HEADER = "X-Aranova-Sdk-Version";
@@ -1284,185 +1262,6 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
1284
1262
  var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
1285
1263
  var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
1286
1264
 
1287
- // ../tracking-core/src/events/cta-click.ts
1288
- import { z as z2 } from "zod";
1289
- var ctaClickMetadataSchema = z2.object({
1290
- cta_name: z2.string(),
1291
- page: z2.object({
1292
- path: z2.string()
1293
- }).strict(),
1294
- section: z2.string().nullable().optional(),
1295
- destination_url: z2.string().nullable().optional(),
1296
- // Set by auto-capture (and available to manual callers): the link target
1297
- // and a short element descriptor (tag#id) for tying clicks to specific UI.
1298
- href: z2.string().nullable().optional(),
1299
- element: z2.string().nullable().optional()
1300
- }).strict();
1301
- var ctaClickConfigSchema = z2.object({
1302
- autoCapture: z2.object({
1303
- selector: z2.string().optional()
1304
- }).strict().optional()
1305
- }).strict();
1306
-
1307
- // ../tracking-core/src/events/sdk-heartbeat.ts
1308
- import { z as z3 } from "zod";
1309
- var sdkHeartbeatTriggersSchema = z3.object({
1310
- automatic: z3.array(z3.string()),
1311
- manual: z3.array(z3.string())
1312
- }).strict();
1313
- var sdkHeartbeatMetadataSchema = z3.object({
1314
- sdk_version: z3.string(),
1315
- package_name: z3.string().nullable(),
1316
- surface: z3.enum(["next", "react", "script"]),
1317
- triggers: sdkHeartbeatTriggersSchema,
1318
- trigger_config: z3.record(z3.string(), z3.record(z3.string(), z3.unknown())).nullable().optional(),
1319
- configured_gtag_ids: z3.record(z3.string(), z3.string()).nullable().optional()
1320
- }).strict();
1321
- var sdkHeartbeatConfigSchema = z3.object({}).strict();
1322
-
1323
- // ../tracking-core/src/events/form-start.ts
1324
- import { z as z4 } from "zod";
1325
- var formStartMetadataSchema = z4.object({
1326
- form: z4.object({
1327
- id: z4.string(),
1328
- action: z4.string().nullable()
1329
- }).strict(),
1330
- page: z4.object({
1331
- path: z4.string()
1332
- }).strict()
1333
- }).strict();
1334
- var formStartConfigSchema = z4.object({
1335
- selector: z4.string().optional()
1336
- }).strict();
1337
-
1338
- // ../tracking-core/src/events/form-submit.ts
1339
- import { z as z5 } from "zod";
1340
- var jsonValueSchema = z5.lazy(
1341
- () => z5.union([
1342
- z5.string(),
1343
- z5.number().finite(),
1344
- z5.boolean(),
1345
- z5.null(),
1346
- z5.array(jsonValueSchema),
1347
- z5.record(jsonValueSchema)
1348
- ])
1349
- );
1350
- var formSubmitMetadataSchema = z5.object({
1351
- form: z5.object({
1352
- id: z5.string(),
1353
- action: z5.string().nullable(),
1354
- fields: z5.array(
1355
- z5.object({
1356
- name: z5.string(),
1357
- type: z5.string(),
1358
- label: z5.string().nullable(),
1359
- value: jsonValueSchema
1360
- }).strict()
1361
- ).optional()
1362
- }).strict(),
1363
- page: z5.object({
1364
- path: z5.string()
1365
- }).strict()
1366
- }).strict();
1367
- var formSubmitConfigSchema = z5.object({}).strict();
1368
-
1369
- // ../tracking-core/src/events/multi-page-session.ts
1370
- import { z as z6 } from "zod";
1371
- var multiPageSessionMetadataSchema = z6.object({
1372
- page_count: z6.number().int().min(2),
1373
- page: z6.object({
1374
- path: z6.string()
1375
- }).strict()
1376
- }).strict();
1377
- var multiPageSessionConfigSchema = z6.object({
1378
- pageThreshold: z6.number().int().min(2)
1379
- }).strict();
1380
-
1381
- // ../tracking-core/src/events/page-exit.ts
1382
- import { z as z7 } from "zod";
1383
- var pageExitMetadataSchema = z7.object({
1384
- dwell_ms: z7.number().int().min(0),
1385
- // null = left without any scroll signal; floor is 0 so a valid 0% is never
1386
- // rejected (a single bad field 422s the whole keepalive beacon batch).
1387
- max_scroll_percent: z7.number().int().min(0).max(100).nullable(),
1388
- // The gating baseline: the fraction of the page visible at load with
1389
- // zero scrolling — or, for pages that grew after the post-paint snapshot
1390
- // (skeleton/streaming renders), the first-scroll position that
1391
- // established it. null = page had no scrollable range, or the segment
1392
- // ended before the snapshot. `.optional()` is load-bearing: SDK builds
1393
- // predating this field keep POSTing page_exit without the key —
1394
- // requiring it would 422 whole keepalive beacon batches.
1395
- scroll_baseline_percent: z7.number().int().min(0).max(100).nullable().optional(),
1396
- page: z7.object({
1397
- path: z7.string()
1398
- }).strict()
1399
- }).strict();
1400
- var pageExitConfigSchema = z7.object({}).strict();
1401
-
1402
- // ../tracking-core/src/events/phone-click.ts
1403
- import { z as z8 } from "zod";
1404
- var phoneClickMetadataSchema = z8.object({
1405
- phone_number: z8.string(),
1406
- page: z8.object({
1407
- path: z8.string()
1408
- }).strict(),
1409
- section: z8.string().nullable().optional()
1410
- }).strict();
1411
- var phoneClickConfigSchema = z8.object({
1412
- autoCapture: z8.object({
1413
- selector: z8.string().optional()
1414
- }).strict().optional()
1415
- }).strict();
1416
-
1417
- // ../tracking-core/src/events/scroll-depth.ts
1418
- import { z as z9 } from "zod";
1419
- var scrollDepthMetadataSchema = z9.object({
1420
- depth_percent: z9.number().int().min(1).max(100),
1421
- page: z9.object({
1422
- path: z9.string()
1423
- }).strict()
1424
- }).strict();
1425
- var scrollDepthConfigSchema = z9.object({
1426
- thresholds: z9.array(z9.number().int().min(1).max(100)).min(1)
1427
- }).strict();
1428
-
1429
- // ../tracking-core/src/events/specific-page-visit.ts
1430
- import { z as z10 } from "zod";
1431
- var PAGE_IDENTITY_MAX_LENGTH = 64;
1432
- var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
1433
- var pageIdentitySchema = z10.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
1434
- message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
1435
- });
1436
- var specificPageNameSchema = pageIdentitySchema;
1437
- var specificPageVisitMetadataSchema = z10.object({
1438
- page_name: specificPageNameSchema,
1439
- page: z10.object({
1440
- path: z10.string()
1441
- }).strict()
1442
- }).strict();
1443
- var specificPageVisitConfigSchema = z10.object({
1444
- pages: z10.array(
1445
- z10.object({
1446
- name: specificPageNameSchema,
1447
- pathPattern: z10.custom((value) => value instanceof RegExp, {
1448
- message: "pathPattern must be a RegExp"
1449
- })
1450
- }).strict()
1451
- ).min(1)
1452
- }).strict();
1453
-
1454
- // ../tracking-core/src/events/time-on-site.ts
1455
- import { z as z11 } from "zod";
1456
- var timeOnSiteMetadataSchema = z11.object({
1457
- duration_ms: z11.number().int().nonnegative(),
1458
- page: z11.object({
1459
- path: z11.string()
1460
- }).strict()
1461
- }).strict();
1462
- var timeOnSiteConfigSchema = z11.object({
1463
- thresholdSeconds: z11.number().int().positive()
1464
- }).strict();
1465
-
1466
1265
  // ../tracking-core/src/events/semantics.ts
1467
1266
  var EVENT_SEMANTICS = {
1468
1267
  page_view: {
@@ -1536,82 +1335,6 @@ function getEventSemantics(eventName) {
1536
1335
  return eventName in EVENT_SEMANTICS ? EVENT_SEMANTICS[eventName] : null;
1537
1336
  }
1538
1337
 
1539
- // ../tracking-core/src/events/registry.ts
1540
- var EVENT_REGISTRY = {
1541
- // --- automatic triggers ---
1542
- page_view: {
1543
- kind: "automatic",
1544
- semantics: EVENT_SEMANTICS.page_view,
1545
- metadataSchema: pageViewMetadataSchema,
1546
- configSchema: pageViewConfigSchema
1547
- },
1548
- time_on_site: {
1549
- kind: "automatic",
1550
- semantics: EVENT_SEMANTICS.time_on_site,
1551
- metadataSchema: timeOnSiteMetadataSchema,
1552
- configSchema: timeOnSiteConfigSchema
1553
- },
1554
- specific_page_visit: {
1555
- kind: "automatic",
1556
- semantics: EVENT_SEMANTICS.specific_page_visit,
1557
- metadataSchema: specificPageVisitMetadataSchema,
1558
- configSchema: specificPageVisitConfigSchema
1559
- },
1560
- scroll_depth: {
1561
- kind: "automatic",
1562
- semantics: EVENT_SEMANTICS.scroll_depth,
1563
- metadataSchema: scrollDepthMetadataSchema,
1564
- configSchema: scrollDepthConfigSchema
1565
- },
1566
- multi_page_session: {
1567
- kind: "automatic",
1568
- semantics: EVENT_SEMANTICS.multi_page_session,
1569
- metadataSchema: multiPageSessionMetadataSchema,
1570
- configSchema: multiPageSessionConfigSchema
1571
- },
1572
- form_start: {
1573
- kind: "automatic",
1574
- semantics: EVENT_SEMANTICS.form_start,
1575
- metadataSchema: formStartMetadataSchema,
1576
- configSchema: formStartConfigSchema
1577
- },
1578
- // --- SDK-internal automatic (not consumer-configurable) ---
1579
- sdk_heartbeat: {
1580
- kind: "automatic",
1581
- semantics: EVENT_SEMANTICS.sdk_heartbeat,
1582
- metadataSchema: sdkHeartbeatMetadataSchema,
1583
- configSchema: sdkHeartbeatConfigSchema
1584
- },
1585
- page_exit: {
1586
- kind: "automatic",
1587
- semantics: EVENT_SEMANTICS.page_exit,
1588
- metadataSchema: pageExitMetadataSchema,
1589
- configSchema: pageExitConfigSchema
1590
- },
1591
- // --- manual triggers ---
1592
- form_submit: {
1593
- kind: "manual",
1594
- semantics: EVENT_SEMANTICS.form_submit,
1595
- metadataSchema: formSubmitMetadataSchema,
1596
- configSchema: formSubmitConfigSchema
1597
- },
1598
- phone_click: {
1599
- kind: "manual",
1600
- semantics: EVENT_SEMANTICS.phone_click,
1601
- metadataSchema: phoneClickMetadataSchema,
1602
- configSchema: phoneClickConfigSchema
1603
- },
1604
- cta_click: {
1605
- kind: "manual",
1606
- semantics: EVENT_SEMANTICS.cta_click,
1607
- metadataSchema: ctaClickMetadataSchema,
1608
- configSchema: ctaClickConfigSchema
1609
- }
1610
- };
1611
- var ALL_AUTOMATIC_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "automatic").map(([name]) => name);
1612
- var ALL_MANUAL_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "manual").map(([name]) => name);
1613
- var ALL_LEAD_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.semantics.outcomeRole === "lead").map(([name]) => name);
1614
-
1615
1338
  // ../tracking-core/src/resources/http/errors.ts
1616
1339
  var AranovaApiError = class extends Error {
1617
1340
  constructor(message, options) {
@@ -1649,9 +1372,9 @@ async function apiRequest(config, method, path, body, extraHeaders) {
1649
1372
  try {
1650
1373
  const parsed = await response.json();
1651
1374
  if (parsed && typeof parsed === "object") {
1652
- const record = parsed;
1653
- if (typeof record.detail === "string") detail = record.detail;
1654
- if (typeof record.code === "string") code = record.code;
1375
+ const record5 = parsed;
1376
+ if (typeof record5.detail === "string") detail = record5.detail;
1377
+ if (typeof record5.code === "string") code = record5.code;
1655
1378
  }
1656
1379
  } catch {
1657
1380
  }
@@ -1700,7 +1423,7 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
1700
1423
  }
1701
1424
  function createSalesClient(config) {
1702
1425
  if (config.firing) registerCapability("conversion_goals_manual");
1703
- async function record(input) {
1426
+ async function record5(input) {
1704
1427
  const currency = input.currency ?? config.defaultCurrency;
1705
1428
  if (!currency) {
1706
1429
  throw new Error(
@@ -1726,9 +1449,9 @@ function createSalesClient(config) {
1726
1449
  return sale;
1727
1450
  }
1728
1451
  return {
1729
- record,
1452
+ record: record5,
1730
1453
  // recordSale is the intent-revealing alias — same behavior, clearer call site.
1731
- recordSale: record,
1454
+ recordSale: record5,
1732
1455
  trackConversion(key, options) {
1733
1456
  if (config.firing && "fireConversion" in config.firing) {
1734
1457
  if (options?.userData && getConsentState() !== "denied") stashUserData(options.userData);
@@ -1847,115 +1570,264 @@ function createSalesClient(config) {
1847
1570
  }
1848
1571
 
1849
1572
  // ../tracking-core/src/resources/sales/schema.ts
1850
- import { z as z12 } from "zod";
1851
- var SUPPORTED_CURRENCIES = ["USD", "CAD"];
1852
- var TRACKING_ENVIRONMENTS = ["production", "development"];
1853
- var currencySchema = z12.enum(SUPPORTED_CURRENCIES);
1854
- var centsSchema = z12.number().int().nonnegative();
1855
- var quantitySchema = z12.string().regex(/^\d+(\.\d{1,3})?$/);
1856
- var metadataSchema = z12.record(z12.unknown());
1857
- var saleItemSchema = z12.object({
1858
- external_item_id: z12.string().nullable().optional(),
1859
- name: z12.string().nullable().optional(),
1860
- category: z12.string().nullable().optional(),
1861
- quantity: quantitySchema,
1862
- unit_price_cents: centsSchema,
1863
- // Non-negativity validated on the wire — same contract as the other cents
1864
- // fields — and backstopped by the DB CHECK.
1865
- unit_cost_cents: centsSchema.nullable().optional()
1866
- }).strict();
1867
- var saleServiceSchema = z12.object({
1868
- service: z12.string(),
1869
- amount_cents: centsSchema
1870
- }).strict();
1871
- var customerNameSchema = z12.string().max(200);
1872
- var customerPhoneSchema = z12.string().max(64);
1873
- var customerEmailSchema = z12.string().max(320).email();
1573
+ import * as z2 from "zod/mini";
1574
+
1575
+ // ../tracking-core/src/resources/sales/generated/zod.gen.ts
1576
+ import * as z from "zod/mini";
1577
+ var zErrorCode = z.enum([
1578
+ "missing_credentials",
1579
+ "invalid_api_key",
1580
+ "not_authenticated",
1581
+ "wrong_key_type",
1582
+ "origin_missing",
1583
+ "origin_not_allowed",
1584
+ "capability_denied",
1585
+ "session_required",
1586
+ "operator_only",
1587
+ "cross_tenant",
1588
+ "business_id_required",
1589
+ "bad_request",
1590
+ "not_found",
1591
+ "conflict",
1592
+ "incompatible_payload",
1593
+ "repeat_confirmation_required",
1594
+ "idempotency_conflict",
1595
+ "validation_error",
1596
+ "unknown_service",
1597
+ "invalid_sale_properties",
1598
+ "invalid_cursor",
1599
+ "rate_limited",
1600
+ "internal_error"
1601
+ ]);
1602
+ var zSaleItemEntitySchema = z.object({
1603
+ category: z.nullable(z.string()),
1604
+ external_item_id: z.nullable(z.string()),
1605
+ id: z.uuid(),
1606
+ name: z.nullable(z.string()),
1607
+ quantity: z.string().check(z.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
1608
+ unit_cost_cents: z.nullable(z.int()),
1609
+ unit_price_cents: z.int()
1610
+ });
1611
+ var zSaleItemInputSchema = z.strictObject({
1612
+ category: z.nullish(z.string()),
1613
+ external_item_id: z.nullish(z.string()),
1614
+ name: z.nullish(z.string()),
1615
+ quantity: z.string().check(z.regex(/^\d+(\.\d{1,3})?$/)),
1616
+ unit_cost_cents: z.nullish(z.int().check(z.gte(0))),
1617
+ unit_price_cents: z.int().check(z.gte(0))
1618
+ });
1619
+ var zSaleServiceEntitySchema = z.object({
1620
+ amount_cents: z.int(),
1621
+ id: z.uuid(),
1622
+ mapped: z.nullable(z.boolean()),
1623
+ service_id: z.uuid(),
1624
+ service_key: z.string(),
1625
+ service_label: z.string()
1626
+ });
1627
+ var zSaleServiceInputSchema = z.strictObject({
1628
+ amount_cents: z.int().check(z.gte(0)),
1629
+ service: z.string()
1630
+ });
1631
+ var zSmsAutomationState = z.enum([
1632
+ "needs_check",
1633
+ "failed",
1634
+ "undelivered",
1635
+ "blocked_opted_out",
1636
+ "withheld",
1637
+ "queued",
1638
+ "sent",
1639
+ "delivered",
1640
+ "eligible",
1641
+ "not_applicable"
1642
+ ]);
1643
+ var zSmsWithheldReason = z.enum([
1644
+ "automation_disabled",
1645
+ "sms_disabled",
1646
+ "no_phone",
1647
+ "no_consent",
1648
+ "no_customer_identity",
1649
+ "missing_customer_name",
1650
+ "placeholder_customer_name",
1651
+ "opted_out",
1652
+ "already_messaged",
1653
+ "sender_not_ready",
1654
+ "missing_review_url",
1655
+ "no_handler",
1656
+ "dispatch_already_recorded"
1657
+ ]);
1658
+ var zSaleSmsStatusSchema = z.object({
1659
+ can_send_now: z._default(z.boolean(), false),
1660
+ last_message_at: z.nullable(z.iso.datetime({ offset: true })),
1661
+ reason_detail: z.nullable(z.string()),
1662
+ state: zSmsAutomationState,
1663
+ suppressed_by_other_sale: z._default(z.boolean(), false),
1664
+ withheld_reason: z.nullable(zSmsWithheldReason)
1665
+ });
1666
+ var zSupportedCurrency = z.enum(["USD", "CAD"]);
1667
+ var zTrackingEnvironment = z.enum(["production", "development"]);
1668
+ var zSaleCreateSchema = z.strictObject({
1669
+ amount_total_cents: z.nullish(z.int().check(z.gte(0))),
1670
+ currency: zSupportedCurrency,
1671
+ customer_email: z.nullish(z.email().check(z.maxLength(320))),
1672
+ customer_name: z.nullish(z.string().check(z.maxLength(200))),
1673
+ customer_phone: z.nullish(z.string().check(z.maxLength(64))),
1674
+ description: z.nullish(z.string()),
1675
+ environment: z._default(z.optional(zTrackingEnvironment), "production"),
1676
+ external_id: z.nullish(z.string()),
1677
+ items: z.optional(z.array(zSaleItemInputSchema)),
1678
+ metadata: z.nullish(z.record(z.string(), z.unknown())),
1679
+ occurred_at: z.iso.datetime({ offset: true }),
1680
+ service: z.nullish(z.string()),
1681
+ services: z.nullish(z.array(zSaleServiceInputSchema)),
1682
+ sms_consent: z.nullish(z.boolean())
1683
+ });
1684
+ var zValidationError = z.object({
1685
+ ctx: z.optional(z.record(z.string(), z.unknown())),
1686
+ input: z.optional(z.unknown()),
1687
+ loc: z.array(z.union([z.string(), z.int()])),
1688
+ msg: z.string(),
1689
+ type: z.string()
1690
+ });
1691
+ var zHttpValidationError = z.object({
1692
+ detail: z.optional(z.array(zValidationError))
1693
+ });
1694
+ var zValidationErrorItem = z.object({
1695
+ loc: z.array(z.union([z.string(), z.int()])),
1696
+ msg: z.string(),
1697
+ type: z.string()
1698
+ });
1699
+ var zApiErrorSchema = z.object({
1700
+ code: zErrorCode,
1701
+ context: z._default(z.nullish(z.record(z.string(), z.unknown())), null),
1702
+ detail: z.string(),
1703
+ errors: z._default(z.nullish(z.array(zValidationErrorItem)), null),
1704
+ request_id: z._default(z.nullish(z.string()), null)
1705
+ });
1706
+ var zWritebackEmailSource = z.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
1707
+ var zWritebackEnrichmentStatus = z.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
1708
+ var zWritebackSaleUploadCounts = z.object({
1709
+ failed: z._default(z.int(), 0),
1710
+ pending: z._default(z.int(), 0),
1711
+ skipped: z._default(z.int(), 0),
1712
+ submitted: z._default(z.int(), 0),
1713
+ total: z._default(z.int(), 0),
1714
+ uploaded: z._default(z.int(), 0)
1715
+ });
1716
+ var zSaleWritebackStatusSchema = z.object({
1717
+ blocked_reason: z.nullable(z.string()),
1718
+ can_dispatch: z._default(z.boolean(), false),
1719
+ email_source: z.nullable(zWritebackEmailSource),
1720
+ enrichment_status: z.nullable(zWritebackEnrichmentStatus),
1721
+ gclid_attached: z._default(z.boolean(), false),
1722
+ identifiers_sent: z.nullable(z.string()),
1723
+ mapped_service_ids: z.array(z.uuid()),
1724
+ matched_submit_count: z.nullable(z.int()),
1725
+ needs_force: z._default(z.boolean(), false),
1726
+ rollup: z.enum([
1727
+ "failed",
1728
+ "skipped",
1729
+ "pending",
1730
+ "submitted",
1731
+ "uploaded",
1732
+ "not_uploaded",
1733
+ "out_of_window",
1734
+ "blocked"
1735
+ ]),
1736
+ stale: z._default(z.boolean(), false),
1737
+ uncovered_service_ids: z.array(z.uuid()),
1738
+ uploads: zWritebackSaleUploadCounts
1739
+ });
1740
+ var zSaleEntitySchema = z.object({
1741
+ amount_total_cents: z.int(),
1742
+ business_id: z.uuid(),
1743
+ business_name: z.nullable(z.string()),
1744
+ created_at: z.iso.datetime({ offset: true }),
1745
+ currency: z.string(),
1746
+ customer_email: z.nullable(z.string()),
1747
+ customer_name: z.nullable(z.string()),
1748
+ customer_name_placeholder_confirmed: z._default(z.boolean(), false),
1749
+ customer_name_placeholder_confirmed_at: z.nullable(z.iso.datetime({ offset: true })),
1750
+ customer_phone: z.nullable(z.string()),
1751
+ description: z.nullable(z.string()),
1752
+ environment: zTrackingEnvironment,
1753
+ external_id: z.nullable(z.string()),
1754
+ id: z.uuid(),
1755
+ items: z.array(zSaleItemEntitySchema),
1756
+ metadata: z.nullable(z.record(z.string(), z.unknown())),
1757
+ occurred_at: z.iso.datetime({ offset: true }),
1758
+ service_id: z.nullable(z.uuid()),
1759
+ service_key: z.nullable(z.string()),
1760
+ service_label: z.nullable(z.string()),
1761
+ services: z.array(zSaleServiceEntitySchema),
1762
+ sms_automation: z.nullable(zSaleSmsStatusSchema),
1763
+ sms_consent: z._default(z.boolean(), false),
1764
+ sms_consent_granted_at: z.nullable(z.iso.datetime({ offset: true })),
1765
+ updated_at: z.iso.datetime({ offset: true }),
1766
+ writeback: z.nullable(zSaleWritebackStatusSchema)
1767
+ });
1768
+
1769
+ // ../tracking-core/src/resources/sales/schema.ts
1770
+ var saleItemSchema = zSaleItemInputSchema;
1771
+ var saleServiceSchema = zSaleServiceInputSchema;
1772
+ var currencySchema = zSupportedCurrency;
1773
+ var SUPPORTED_CURRENCIES = currencySchema.options;
1774
+ var centsSchema = z2.int().check(z2.gte(0));
1775
+ var metadataSchema = z2.record(z2.string(), z2.unknown());
1776
+ var customerNameSchema = z2.string().check(z2.maxLength(200));
1777
+ var customerPhoneSchema = z2.string().check(z2.maxLength(64));
1778
+ var customerEmailSchema = z2.email().check(z2.maxLength(320));
1779
+ function addIssue(ctx, path, message) {
1780
+ ctx.issues.push({ code: "custom", input: ctx.value, path, message });
1781
+ }
1874
1782
  function refineServiceXor(val, ctx, { requireAmount }) {
1875
1783
  if (val.services != null) {
1876
1784
  if (val.service != null) {
1877
- ctx.addIssue({
1878
- code: z12.ZodIssueCode.custom,
1879
- message: "pass either `service` or `services`, not both",
1880
- path: ["services"]
1881
- });
1785
+ addIssue(ctx, ["services"], "pass either `service` or `services`, not both");
1882
1786
  }
1883
1787
  if (val.services.length === 0) {
1884
- ctx.addIssue({
1885
- code: z12.ZodIssueCode.custom,
1886
- message: "`services` must not be empty",
1887
- path: ["services"]
1888
- });
1788
+ addIssue(ctx, ["services"], "`services` must not be empty");
1889
1789
  }
1890
1790
  const keys = val.services.map((s) => s.service);
1891
1791
  if (new Set(keys).size !== keys.length) {
1892
- ctx.addIssue({
1893
- code: z12.ZodIssueCode.custom,
1894
- message: "`services` must not list the same service more than once",
1895
- path: ["services"]
1896
- });
1792
+ addIssue(ctx, ["services"], "`services` must not list the same service more than once");
1897
1793
  }
1898
1794
  if (val.amount_total_cents != null) {
1899
1795
  const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
1900
1796
  if (val.amount_total_cents !== sum) {
1901
- ctx.addIssue({
1902
- code: z12.ZodIssueCode.custom,
1903
- message: "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)",
1904
- path: ["amount_total_cents"]
1905
- });
1797
+ addIssue(
1798
+ ctx,
1799
+ ["amount_total_cents"],
1800
+ "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)"
1801
+ );
1906
1802
  }
1907
1803
  }
1908
1804
  } else if (requireAmount && val.amount_total_cents == null) {
1909
- ctx.addIssue({
1910
- code: z12.ZodIssueCode.custom,
1911
- message: "amount_total_cents is required unless `services` is provided",
1912
- path: ["amount_total_cents"]
1913
- });
1805
+ addIssue(
1806
+ ctx,
1807
+ ["amount_total_cents"],
1808
+ "amount_total_cents is required unless `services` is provided"
1809
+ );
1914
1810
  }
1915
1811
  }
1916
- var saleCreateSchema = z12.object({
1917
- external_id: z12.string().nullable().optional(),
1918
- description: z12.string().nullable().optional(),
1919
- service: z12.string().nullable().optional(),
1920
- services: z12.array(saleServiceSchema).nullable().optional(),
1921
- currency: currencySchema,
1922
- // Optional only because the plural `services` form derives it from the sum
1923
- // (see refineServiceXor); the singular/serviceless path still requires it.
1924
- amount_total_cents: centsSchema.nullable().optional(),
1925
- occurred_at: z12.string().datetime(),
1926
- environment: z12.enum(TRACKING_ENVIRONMENTS).default("production"),
1927
- items: z12.array(saleItemSchema).default([]),
1928
- metadata: metadataSchema.nullable().optional(),
1929
- customer_name: customerNameSchema.nullable().optional(),
1930
- customer_phone: customerPhoneSchema.nullable().optional(),
1931
- customer_email: customerEmailSchema.nullable().optional(),
1932
- // CASL consent attestation: the customer agreed to receive SMS. Recorded
1933
- // with a timestamp server-side; every SMS send path gates on it.
1934
- //
1935
- // Tri-state: omit it (or send null) to let the server apply the business's
1936
- // configured default-opt-in policy, honouring a returning customer's
1937
- // remembered preference. Send an explicit boolean to assert consent state
1938
- // yourself — `false` records a deliberate opt-out.
1939
- sms_consent: z12.boolean().nullable().optional()
1940
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
1941
- var saleUpdateSchema = z12.object({
1942
- description: z12.string().nullable().optional(),
1943
- service: z12.string().nullable().optional(),
1944
- services: z12.array(saleServiceSchema).nullable().optional(),
1945
- currency: currencySchema.optional(),
1946
- amount_total_cents: centsSchema.optional(),
1947
- occurred_at: z12.string().datetime().optional(),
1948
- items: z12.array(saleItemSchema).optional(),
1949
- metadata: metadataSchema.nullable().optional(),
1950
- customer_name: customerNameSchema.nullable().optional(),
1812
+ var saleCreateSchema = z2.extend(zSaleCreateSchema, { items: z2._default(z2.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
1813
+ var saleUpdateSchema = z2.strictObject({
1814
+ description: z2.nullish(z2.string()),
1815
+ service: z2.nullish(z2.string()),
1816
+ services: z2.nullish(z2.array(saleServiceSchema)),
1817
+ currency: z2.optional(currencySchema),
1818
+ amount_total_cents: z2.optional(centsSchema),
1819
+ occurred_at: z2.optional(z2.iso.datetime()),
1820
+ items: z2.optional(z2.array(saleItemSchema)),
1821
+ metadata: z2.nullish(metadataSchema),
1822
+ customer_name: z2.nullish(customerNameSchema),
1951
1823
  // Re-attest when changing a filler-looking name; the server clears the
1952
1824
  // prior attestation whenever `customer_name` changes.
1953
- customer_name_placeholder_confirmed: z12.boolean().optional(),
1954
- customer_phone: customerPhoneSchema.nullable().optional(),
1955
- customer_email: customerEmailSchema.nullable().optional(),
1825
+ customer_name_placeholder_confirmed: z2.optional(z2.boolean()),
1826
+ customer_phone: z2.nullish(customerPhoneSchema),
1827
+ customer_email: z2.nullish(customerEmailSchema),
1956
1828
  // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
1957
- sms_consent: z12.boolean().optional()
1958
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: false }));
1829
+ sms_consent: z2.optional(z2.boolean())
1830
+ }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
1959
1831
  var TRACKING_RANGES = ["24h", "7d", "30d"];
1960
1832
  var NAMED_RANGES = [
1961
1833
  "today",
@@ -2036,8 +1908,8 @@ function instantFromWallClock(timeZone, year, month, day, hour = 0, minute = 0)
2036
1908
  const corrected = naive - offsetMinutesAt(firstGuess, timeZone) * 6e4;
2037
1909
  return new Date(corrected);
2038
1910
  }
2039
- function localDateKey(iso, timeZone) {
2040
- const p = partsInTz(new Date(iso), timeZone);
1911
+ function localDateKey(iso4, timeZone) {
1912
+ const p = partsInTz(new Date(iso4), timeZone);
2041
1913
  const pad = (n) => String(n).padStart(2, "0");
2042
1914
  return `${p.year}-${pad(p.month)}-${pad(p.day)}`;
2043
1915
  }
@@ -2092,7 +1964,167 @@ function isCalendarError(error, code) {
2092
1964
  }
2093
1965
 
2094
1966
  // ../tracking-core/src/resources/calendar/schema.ts
2095
- import { z as z13 } from "zod";
1967
+ import * as z4 from "zod/mini";
1968
+
1969
+ // ../tracking-core/src/resources/calendar/generated/zod.gen.ts
1970
+ import * as z3 from "zod/mini";
1971
+ var zBookingAttendee = z3.strictObject({
1972
+ display_name: z3.nullish(z3.string().check(z3.maxLength(200))),
1973
+ email: z3.email().check(z3.maxLength(320)),
1974
+ optional: z3._default(z3.optional(z3.boolean()), false)
1975
+ });
1976
+ var zBookingCancelSchema = z3.strictObject({
1977
+ notify_attendees: z3._default(z3.optional(z3.boolean()), true),
1978
+ reason: z3.nullish(z3.string().check(z3.maxLength(500)))
1979
+ });
1980
+ var zBookingCustomerInput = z3.strictObject({
1981
+ email: z3.email().check(z3.maxLength(320)),
1982
+ name: z3.nullish(z3.string().check(z3.maxLength(200))),
1983
+ phone: z3.nullish(z3.string().check(z3.maxLength(64))),
1984
+ sms_consent: z3._default(z3.optional(z3.boolean()), false)
1985
+ });
1986
+ var zBookingCustomerOutput = z3.strictObject({
1987
+ email: z3.email().check(z3.maxLength(320)),
1988
+ name: z3.nullable(z3.string().check(z3.maxLength(200))),
1989
+ phone: z3.nullable(z3.string().check(z3.maxLength(64))),
1990
+ sms_consent: z3._default(z3.boolean(), false)
1991
+ });
1992
+ var zBookingRescheduleSchema = z3.strictObject({
1993
+ duration_minutes: z3.nullish(z3.int().check(z3.gt(0), z3.lte(1440))),
1994
+ end_at: z3.nullish(z3.iso.datetime({ offset: true })),
1995
+ notify_attendees: z3._default(z3.optional(z3.boolean()), true),
1996
+ reason: z3.nullish(z3.string().check(z3.maxLength(500))),
1997
+ start_at: z3.iso.datetime({ offset: true }),
1998
+ time_zone: z3.string().check(z3.minLength(1), z3.maxLength(64), z3.regex(/^[A-Za-z0-9_+\-\/]+$/))
1999
+ });
2000
+ var zBookingResponse = z3.strictObject({
2001
+ appointment_type: z3.nullable(z3.string()),
2002
+ calendar_key: z3.string(),
2003
+ customer: zBookingCustomerOutput,
2004
+ end_at: z3.iso.datetime({ offset: true }),
2005
+ google_html_link: z3.nullable(z3.string()),
2006
+ google_sync_state: z3.string(),
2007
+ id: z3.string(),
2008
+ manage_token: z3.nullable(z3.string()),
2009
+ meet_url: z3.nullable(z3.string()),
2010
+ start_at: z3.iso.datetime({ offset: true }),
2011
+ status: z3.string(),
2012
+ time_zone: z3.string(),
2013
+ title: z3.string()
2014
+ });
2015
+ var zBookingSource = z3.enum(["website", "phone", "walk_in", "import", "operator"]);
2016
+ var zBookingMetadata = z3.strictObject({
2017
+ custom: z3.nullish(
2018
+ z3.record(z3.string(), z3.nullable(z3.union([z3.string(), z3.int(), z3.number(), z3.boolean()])))
2019
+ ),
2020
+ fbclid: z3.nullish(z3.string().check(z3.maxLength(256))),
2021
+ gclid: z3.nullish(z3.string().check(z3.maxLength(256))),
2022
+ landing_page: z3.nullish(z3.string().check(z3.maxLength(2048))),
2023
+ notes: z3.nullish(z3.string().check(z3.maxLength(2e3))),
2024
+ referrer: z3.nullish(z3.string().check(z3.maxLength(2048))),
2025
+ schema_version: z3._default(z3.optional(z3.int()), 1),
2026
+ service: z3.nullish(z3.string().check(z3.maxLength(64))),
2027
+ session_id: z3.nullish(z3.string().check(z3.maxLength(64))),
2028
+ source: z3.nullish(zBookingSource),
2029
+ utm_campaign: z3.nullish(z3.string().check(z3.maxLength(128))),
2030
+ utm_content: z3.nullish(z3.string().check(z3.maxLength(128))),
2031
+ utm_medium: z3.nullish(z3.string().check(z3.maxLength(128))),
2032
+ utm_source: z3.nullish(z3.string().check(z3.maxLength(128))),
2033
+ utm_term: z3.nullish(z3.string().check(z3.maxLength(128))),
2034
+ visitor_id: z3.nullish(z3.string().check(z3.maxLength(64)))
2035
+ });
2036
+ var zCustomLocation = z3.strictObject({
2037
+ kind: z3.literal("custom"),
2038
+ text: z3.string().check(z3.maxLength(1024))
2039
+ });
2040
+ var zErrorCode2 = z3.enum([
2041
+ "missing_credentials",
2042
+ "invalid_api_key",
2043
+ "not_authenticated",
2044
+ "wrong_key_type",
2045
+ "origin_missing",
2046
+ "origin_not_allowed",
2047
+ "capability_denied",
2048
+ "session_required",
2049
+ "operator_only",
2050
+ "cross_tenant",
2051
+ "business_id_required",
2052
+ "bad_request",
2053
+ "not_found",
2054
+ "conflict",
2055
+ "incompatible_payload",
2056
+ "repeat_confirmation_required",
2057
+ "idempotency_conflict",
2058
+ "validation_error",
2059
+ "unknown_service",
2060
+ "invalid_sale_properties",
2061
+ "invalid_cursor",
2062
+ "rate_limited",
2063
+ "internal_error"
2064
+ ]);
2065
+ var zMeetLocation = z3.strictObject({
2066
+ kind: z3.literal("google_meet")
2067
+ });
2068
+ var zPhoneLocation = z3.strictObject({
2069
+ kind: z3.literal("phone"),
2070
+ phone: z3.string().check(z3.maxLength(64))
2071
+ });
2072
+ var zPhysicalLocation = z3.strictObject({
2073
+ address: z3.string().check(z3.maxLength(1024)),
2074
+ kind: z3.literal("physical")
2075
+ });
2076
+ var zReminderMethod = z3.enum(["email", "popup"]);
2077
+ var zBookingReminder = z3.strictObject({
2078
+ method: zReminderMethod,
2079
+ minutes_before: z3.int().check(z3.gte(0), z3.lte(40320))
2080
+ });
2081
+ var zBookingReminders = z3.strictObject({
2082
+ overrides: z3.optional(z3.array(zBookingReminder).check(z3.maxLength(5))),
2083
+ use_calendar_defaults: z3._default(z3.optional(z3.boolean()), true)
2084
+ });
2085
+ var zBookingCreateSchema = z3.strictObject({
2086
+ appointment_type: z3.nullish(z3.string().check(z3.maxLength(64))),
2087
+ attendees: z3.optional(z3.array(zBookingAttendee).check(z3.maxLength(20))),
2088
+ buffer_after_minutes: z3._default(z3.optional(z3.int().check(z3.gte(0), z3.lte(1440))), 0),
2089
+ buffer_before_minutes: z3._default(z3.optional(z3.int().check(z3.gte(0), z3.lte(1440))), 0),
2090
+ calendar_key: z3.string().check(z3.minLength(1), z3.maxLength(64)),
2091
+ customer: zBookingCustomerInput,
2092
+ description: z3.nullish(z3.string().check(z3.maxLength(8e3))),
2093
+ duration_minutes: z3.nullish(z3.int().check(z3.gt(0), z3.lte(1440))),
2094
+ end_at: z3.nullish(z3.iso.datetime({ offset: true })),
2095
+ idempotency_key: z3.nullish(z3.string().check(z3.maxLength(128))),
2096
+ location: z3.nullish(z3.union([zMeetLocation, zPhysicalLocation, zPhoneLocation, zCustomLocation])),
2097
+ metadata: z3.nullish(zBookingMetadata),
2098
+ reminders: z3.nullish(zBookingReminders),
2099
+ send_invites: z3._default(z3.optional(z3.boolean()), true),
2100
+ start_at: z3.iso.datetime({ offset: true }),
2101
+ time_zone: z3.string().check(z3.minLength(1), z3.maxLength(64), z3.regex(/^[A-Za-z0-9_+\-\/]+$/)),
2102
+ title: z3.nullish(z3.string().check(z3.maxLength(300)))
2103
+ });
2104
+ var zValidationError2 = z3.object({
2105
+ ctx: z3.optional(z3.record(z3.string(), z3.unknown())),
2106
+ input: z3.optional(z3.unknown()),
2107
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2108
+ msg: z3.string(),
2109
+ type: z3.string()
2110
+ });
2111
+ var zHttpValidationError2 = z3.object({
2112
+ detail: z3.optional(z3.array(zValidationError2))
2113
+ });
2114
+ var zValidationErrorItem2 = z3.object({
2115
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2116
+ msg: z3.string(),
2117
+ type: z3.string()
2118
+ });
2119
+ var zApiErrorSchema2 = z3.object({
2120
+ code: zErrorCode2,
2121
+ context: z3._default(z3.nullish(z3.record(z3.string(), z3.unknown())), null),
2122
+ detail: z3.string(),
2123
+ errors: z3._default(z3.nullish(z3.array(zValidationErrorItem2)), null),
2124
+ request_id: z3._default(z3.nullish(z3.string()), null)
2125
+ });
2126
+
2127
+ // ../tracking-core/src/resources/calendar/schema.ts
2096
2128
  var CALENDAR_METADATA_SCHEMA_VERSION = 1;
2097
2129
  var MAX_ATTENDEES = 20;
2098
2130
  var MAX_REMINDER_OVERRIDES = 5;
@@ -2118,7 +2150,6 @@ var CALENDAR_ERROR_CODES = [
2118
2150
  "rate_limited",
2119
2151
  "google_error"
2120
2152
  ];
2121
- var isoInstant = z13.string().datetime({ offset: true });
2122
2153
  function isKnownTimeZone(timeZone) {
2123
2154
  try {
2124
2155
  new Intl.DateTimeFormat(void 0, { timeZone });
@@ -2127,107 +2158,65 @@ function isKnownTimeZone(timeZone) {
2127
2158
  return false;
2128
2159
  }
2129
2160
  }
2130
- var ianaTz = z13.string().min(1).max(64).regex(/^[A-Za-z0-9_+\-/]+$/).refine(isKnownTimeZone, { message: "unknown IANA time zone" });
2131
- var bookingAttendeeSchema = z13.object({
2132
- email: z13.string().max(320).email(),
2133
- display_name: z13.string().max(200).nullable().optional(),
2134
- optional: z13.boolean().default(false)
2135
- }).strict();
2136
- var bookingReminderSchema = z13.object({
2137
- method: z13.enum(["email", "popup"]),
2138
- minutes_before: z13.number().int().min(0).max(MAX_REMINDER_MINUTES)
2139
- }).strict();
2140
- var bookingRemindersSchema = z13.object({
2141
- use_calendar_defaults: z13.boolean().default(true),
2142
- overrides: z13.array(bookingReminderSchema).max(MAX_REMINDER_OVERRIDES).default([])
2143
- }).strict();
2144
- var bookingLocationSchema = z13.union([
2145
- z13.object({ kind: z13.literal("google_meet") }).strict(),
2146
- z13.object({ kind: z13.literal("physical"), address: z13.string().max(1024) }).strict(),
2147
- z13.object({ kind: z13.literal("phone"), phone: z13.string().max(64) }).strict(),
2148
- z13.object({ kind: z13.literal("custom"), text: z13.string().max(1024) }).strict()
2161
+ var ianaTz = z4.string().check(
2162
+ z4.minLength(1),
2163
+ z4.maxLength(64),
2164
+ z4.regex(/^[A-Za-z0-9_+\-/]+$/),
2165
+ z4.refine(isKnownTimeZone, { error: "unknown IANA time zone" })
2166
+ );
2167
+ var bookingAttendeeSchema = zBookingAttendee;
2168
+ var bookingReminderSchema = zBookingReminder;
2169
+ var bookingCustomerSchema = zBookingCustomerInput;
2170
+ var bookingMetadataSchema = z4.extend(zBookingMetadata, {
2171
+ custom: z4.nullish(
2172
+ z4.record(z4.string(), z4.union([z4.string(), z4.int(), z4.number(), z4.boolean(), z4.null()]))
2173
+ )
2174
+ });
2175
+ var bookingLocationSchema = z4.union([
2176
+ zMeetLocation,
2177
+ zPhysicalLocation,
2178
+ zPhoneLocation,
2179
+ zCustomLocation
2149
2180
  ]);
2150
- var bookingLocationNullableSchema = z13.union([...bookingLocationSchema.options, z13.null()]);
2151
- var bookingCustomerSchema = z13.object({
2152
- // Required: Google needs an address to send the invite that confirms the
2153
- // booking, and that invite is the whole confirmation mechanism.
2154
- email: z13.string().max(320).email(),
2155
- name: z13.string().max(200).nullable().optional(),
2156
- phone: z13.string().max(64).nullable().optional(),
2157
- sms_consent: z13.boolean().default(false)
2158
- }).strict();
2159
- var jsonScalar = z13.union([z13.string(), z13.number(), z13.boolean(), z13.null()]);
2160
- var bookingMetadataSchema = z13.object({
2161
- schema_version: z13.number().int().default(CALENDAR_METADATA_SCHEMA_VERSION),
2162
- source: z13.enum(BOOKING_SOURCES).nullable().optional(),
2163
- service: z13.string().max(64).nullable().optional(),
2164
- visitor_id: z13.string().max(64).nullable().optional(),
2165
- session_id: z13.string().max(64).nullable().optional(),
2166
- gclid: z13.string().max(256).nullable().optional(),
2167
- fbclid: z13.string().max(256).nullable().optional(),
2168
- utm_source: z13.string().max(128).nullable().optional(),
2169
- utm_medium: z13.string().max(128).nullable().optional(),
2170
- utm_campaign: z13.string().max(128).nullable().optional(),
2171
- utm_term: z13.string().max(128).nullable().optional(),
2172
- utm_content: z13.string().max(128).nullable().optional(),
2173
- landing_page: z13.string().max(2048).nullable().optional(),
2174
- referrer: z13.string().max(2048).nullable().optional(),
2175
- notes: z13.string().max(2e3).nullable().optional(),
2176
- custom: z13.record(jsonScalar).nullable().optional()
2177
- }).strict();
2181
+ var bookingLocationNullableSchema = z4.union([
2182
+ ...bookingLocationSchema.def.options,
2183
+ z4.null()
2184
+ ]);
2185
+ function addIssue2(ctx, path, message) {
2186
+ ctx.issues.push({ code: "custom", input: ctx.value, path, message });
2187
+ }
2178
2188
  function refineEndXor(value, ctx) {
2179
2189
  const hasEnd = value.end_at !== void 0 && value.end_at !== null;
2180
2190
  const hasDuration = value.duration_minutes !== void 0 && value.duration_minutes !== null;
2181
2191
  if (hasEnd === hasDuration) {
2182
- ctx.addIssue({
2183
- code: z13.ZodIssueCode.custom,
2184
- message: "provide exactly one of end_at or duration_minutes",
2185
- path: ["end_at"]
2186
- });
2192
+ addIssue2(ctx, ["end_at"], "provide exactly one of end_at or duration_minutes");
2187
2193
  return;
2188
2194
  }
2189
2195
  if (hasEnd && new Date(value.end_at) <= new Date(value.start_at)) {
2190
- ctx.addIssue({
2191
- code: z13.ZodIssueCode.custom,
2192
- message: "end_at must be after start_at",
2193
- path: ["end_at"]
2194
- });
2196
+ addIssue2(ctx, ["end_at"], "end_at must be after start_at");
2195
2197
  }
2196
2198
  }
2197
- var bookingCreateSchema = z13.object({
2198
- calendar_key: z13.string().min(1).max(64),
2199
- // Free-form: appointment types are the client site's own vocabulary, not
2200
- // configuration the dashboard holds.
2201
- appointment_type: z13.string().max(64).nullable().optional(),
2202
- start_at: isoInstant,
2203
- end_at: isoInstant.nullable().optional(),
2204
- duration_minutes: z13.number().int().positive().max(MAX_BOOKING_MINUTES).nullable().optional(),
2205
- /** The booker's zone — distinct from the business's and the calendar's. */
2206
- time_zone: ianaTz,
2207
- title: z13.string().max(300).nullable().optional(),
2208
- description: z13.string().max(8e3).nullable().optional(),
2209
- location: bookingLocationNullableSchema.optional(),
2210
- customer: bookingCustomerSchema,
2211
- attendees: z13.array(bookingAttendeeSchema).max(MAX_ATTENDEES).default([]),
2212
- send_invites: z13.boolean().default(true),
2213
- reminders: bookingRemindersSchema.nullable().optional(),
2214
- metadata: bookingMetadataSchema.nullable().optional(),
2215
- idempotency_key: z13.string().max(128).nullable().optional(),
2216
- buffer_before_minutes: z13.number().int().min(0).max(MAX_BOOKING_MINUTES).default(0),
2217
- buffer_after_minutes: z13.number().int().min(0).max(MAX_BOOKING_MINUTES).default(0)
2218
- }).strict().superRefine(refineEndXor);
2219
- var bookingRescheduleSchema = z13.object({
2220
- start_at: isoInstant,
2221
- end_at: isoInstant.nullable().optional(),
2222
- duration_minutes: z13.number().int().positive().max(MAX_BOOKING_MINUTES).nullable().optional(),
2199
+ var bookingRemindersSchema = z4.extend(zBookingReminders, {
2200
+ overrides: z4._default(
2201
+ z4.array(bookingReminderSchema).check(z4.maxLength(MAX_REMINDER_OVERRIDES)),
2202
+ []
2203
+ )
2204
+ });
2205
+ var bookingCreateSchema = z4.extend(zBookingCreateSchema, {
2223
2206
  time_zone: ianaTz,
2224
- notify_attendees: z13.boolean().default(true),
2225
- reason: z13.string().max(500).nullable().optional()
2226
- }).strict().superRefine(refineEndXor);
2227
- var bookingCancelSchema = z13.object({
2228
- reason: z13.string().max(500).nullable().optional(),
2229
- notify_attendees: z13.boolean().default(true)
2230
- }).strict();
2207
+ // The generated field is `z.union([...variants]).nullish()`, which nests one
2208
+ // `anyOf` inside another; Pydantic's `BookingLocation | None` flattens to a
2209
+ // single list and the drift snapshot compares structure. Override with the
2210
+ // flattened union.
2211
+ location: z4.optional(bookingLocationNullableSchema),
2212
+ attendees: z4._default(z4.array(bookingAttendeeSchema).check(z4.maxLength(MAX_ATTENDEES)), []),
2213
+ // These reference the un-composed generated schemas; generation can't nest
2214
+ // our compositions into its own output.
2215
+ reminders: z4.nullish(bookingRemindersSchema),
2216
+ metadata: z4.nullish(bookingMetadataSchema)
2217
+ }).check((ctx) => refineEndXor(ctx.value, ctx));
2218
+ var bookingRescheduleSchema = z4.extend(zBookingRescheduleSchema, { time_zone: ianaTz }).check((ctx) => refineEndXor(ctx.value, ctx));
2219
+ var bookingCancelSchema = zBookingCancelSchema;
2231
2220
 
2232
2221
  // ../tracking-core/src/resources/calendar/slots.ts
2233
2222
  function parseHhMm(value) {
@@ -2458,6 +2447,7 @@ export {
2458
2447
  createTrackingClientContext,
2459
2448
  createTrackingEventCreatePayload,
2460
2449
  createTrackingSessionUpsertPayload,
2450
+ currencySchema,
2461
2451
  durationMinutes,
2462
2452
  endOfDayInTz,
2463
2453
  fetchServices,