@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.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 email = normalizeEmail(data.email);
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: email ?? stash.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 email = stash.email;
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) email = 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 (email === null && phoneNumber === null) return false;
207
+ if (email4 === null && phoneNumber === null) return false;
197
208
  try {
198
209
  window.gtag("set", "user_data", {
199
- ...email !== null ? { email } : {},
210
+ ...email4 !== null ? { email: email4 } : {},
200
211
  ...phoneNumber !== null ? { phone_number: phoneNumber } : {}
201
212
  });
202
213
  return true;
@@ -552,10 +563,10 @@ function readStoredRecord() {
552
563
  return null;
553
564
  }
554
565
  }
555
- function writeRecord(record) {
556
- memoryRecord = record;
566
+ function writeRecord(record5) {
567
+ memoryRecord = record5;
557
568
  try {
558
- window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record));
569
+ window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record5));
559
570
  } catch {
560
571
  }
561
572
  }
@@ -577,9 +588,9 @@ function getOrCaptureLandingParams(sessionId, url) {
577
588
  if (memoryRecord && memoryRecord.session_id === sessionId) {
578
589
  return memoryRecord.params;
579
590
  }
580
- const record = { session_id: sessionId, params: captureFromUrl(url) };
581
- writeRecord(record);
582
- return record.params;
591
+ const record5 = { session_id: sessionId, params: captureFromUrl(url) };
592
+ writeRecord(record5);
593
+ return record5.params;
583
594
  }
584
595
  function buildLandingPayloadFields(sessionId, override) {
585
596
  const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
@@ -956,9 +967,9 @@ function automaticThresholdMet(goal, eventType, metadata) {
956
967
  }
957
968
 
958
969
  // ../tracking-core/src/resources/intl/date.ts
959
- function formatDateInTz(iso, timeZone, opts, locale) {
960
- const date = new Date(iso);
961
- if (Number.isNaN(date.getTime())) return iso;
970
+ function formatDateInTz(iso4, timeZone, opts, locale) {
971
+ const date = new Date(iso4);
972
+ if (Number.isNaN(date.getTime())) return iso4;
962
973
  return new Intl.DateTimeFormat(locale, {
963
974
  year: "numeric",
964
975
  month: "short",
@@ -992,14 +1003,15 @@ function formatMoney(cents, currency, locale) {
992
1003
 
993
1004
  // ../tracking-core/src/resources/tracking-config-runtime.ts
994
1005
  var DEFAULT_CDN_BASE_URL = "https://demos.aranova.io";
995
- function trackingConfigKey(businessId, environment) {
996
- return `tracking-config/v1/${businessId}-${environment}.json`;
1006
+ function trackingConfigKey(ref) {
1007
+ if (ref.siteId) return `tracking-config/v1/sites/${ref.siteId}-${ref.environment}.json`;
1008
+ return `tracking-config/v1/${ref.businessId}-${ref.environment}.json`;
997
1009
  }
998
1010
  function resolveTrackingConfigUrl(ref) {
999
1011
  if (ref.cdnUrl) return ref.cdnUrl;
1000
1012
  const configured = ref.cdnBaseUrl?.trim();
1001
1013
  const base = (configured || DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
1002
- return `${base}/${trackingConfigKey(ref.businessId, ref.environment)}`;
1014
+ return `${base}/${trackingConfigKey(ref)}`;
1003
1015
  }
1004
1016
  var CACHE_PREFIX2 = "_aranova_cfg_runtime_";
1005
1017
  var AUTHORITY_TTL_MS = 6e4;
@@ -1369,29 +1381,6 @@ function getTrackingConfigRuntime(ref, fetchImpl) {
1369
1381
  return runtime;
1370
1382
  }
1371
1383
 
1372
- // ../tracking-core/src/session.ts
1373
- var SESSION_IDLE_MS = 30 * 60 * 1e3;
1374
-
1375
- // ../tracking-core/src/events/page-view.ts
1376
- var import_zod = require("zod");
1377
- var pageViewMetadataSchema = import_zod.z.object({
1378
- page: import_zod.z.object({
1379
- title: import_zod.z.string().nullable(),
1380
- path: import_zod.z.string(),
1381
- search: import_zod.z.string(),
1382
- hash: import_zod.z.string()
1383
- }).strict(),
1384
- referrer: import_zod.z.string().nullable(),
1385
- // `.nullable().optional()` — absent (undefined) OR explicit null OR a
1386
- // real viewport object. Mirrors Pydantic's `_Viewport | None = None`
1387
- // on the backend side so the drift test stays clean.
1388
- viewport: import_zod.z.object({
1389
- w: import_zod.z.number(),
1390
- h: import_zod.z.number()
1391
- }).strict().nullable().optional()
1392
- }).strict();
1393
- var pageViewConfigSchema = import_zod.z.object({}).strict();
1394
-
1395
1384
  // ../tracking-core/src/ingest.ts
1396
1385
  var API_KEY_HEADER = "X-Aranova-Api-Key";
1397
1386
  var SDK_VERSION_HEADER = "X-Aranova-Sdk-Version";
@@ -1399,185 +1388,6 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
1399
1388
  var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
1400
1389
  var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
1401
1390
 
1402
- // ../tracking-core/src/events/cta-click.ts
1403
- var import_zod2 = require("zod");
1404
- var ctaClickMetadataSchema = import_zod2.z.object({
1405
- cta_name: import_zod2.z.string(),
1406
- page: import_zod2.z.object({
1407
- path: import_zod2.z.string()
1408
- }).strict(),
1409
- section: import_zod2.z.string().nullable().optional(),
1410
- destination_url: import_zod2.z.string().nullable().optional(),
1411
- // Set by auto-capture (and available to manual callers): the link target
1412
- // and a short element descriptor (tag#id) for tying clicks to specific UI.
1413
- href: import_zod2.z.string().nullable().optional(),
1414
- element: import_zod2.z.string().nullable().optional()
1415
- }).strict();
1416
- var ctaClickConfigSchema = import_zod2.z.object({
1417
- autoCapture: import_zod2.z.object({
1418
- selector: import_zod2.z.string().optional()
1419
- }).strict().optional()
1420
- }).strict();
1421
-
1422
- // ../tracking-core/src/events/sdk-heartbeat.ts
1423
- var import_zod3 = require("zod");
1424
- var sdkHeartbeatTriggersSchema = import_zod3.z.object({
1425
- automatic: import_zod3.z.array(import_zod3.z.string()),
1426
- manual: import_zod3.z.array(import_zod3.z.string())
1427
- }).strict();
1428
- var sdkHeartbeatMetadataSchema = import_zod3.z.object({
1429
- sdk_version: import_zod3.z.string(),
1430
- package_name: import_zod3.z.string().nullable(),
1431
- surface: import_zod3.z.enum(["next", "react", "script"]),
1432
- triggers: sdkHeartbeatTriggersSchema,
1433
- trigger_config: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown())).nullable().optional(),
1434
- configured_gtag_ids: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).nullable().optional()
1435
- }).strict();
1436
- var sdkHeartbeatConfigSchema = import_zod3.z.object({}).strict();
1437
-
1438
- // ../tracking-core/src/events/form-start.ts
1439
- var import_zod4 = require("zod");
1440
- var formStartMetadataSchema = import_zod4.z.object({
1441
- form: import_zod4.z.object({
1442
- id: import_zod4.z.string(),
1443
- action: import_zod4.z.string().nullable()
1444
- }).strict(),
1445
- page: import_zod4.z.object({
1446
- path: import_zod4.z.string()
1447
- }).strict()
1448
- }).strict();
1449
- var formStartConfigSchema = import_zod4.z.object({
1450
- selector: import_zod4.z.string().optional()
1451
- }).strict();
1452
-
1453
- // ../tracking-core/src/events/form-submit.ts
1454
- var import_zod5 = require("zod");
1455
- var jsonValueSchema = import_zod5.z.lazy(
1456
- () => import_zod5.z.union([
1457
- import_zod5.z.string(),
1458
- import_zod5.z.number().finite(),
1459
- import_zod5.z.boolean(),
1460
- import_zod5.z.null(),
1461
- import_zod5.z.array(jsonValueSchema),
1462
- import_zod5.z.record(jsonValueSchema)
1463
- ])
1464
- );
1465
- var formSubmitMetadataSchema = import_zod5.z.object({
1466
- form: import_zod5.z.object({
1467
- id: import_zod5.z.string(),
1468
- action: import_zod5.z.string().nullable(),
1469
- fields: import_zod5.z.array(
1470
- import_zod5.z.object({
1471
- name: import_zod5.z.string(),
1472
- type: import_zod5.z.string(),
1473
- label: import_zod5.z.string().nullable(),
1474
- value: jsonValueSchema
1475
- }).strict()
1476
- ).optional()
1477
- }).strict(),
1478
- page: import_zod5.z.object({
1479
- path: import_zod5.z.string()
1480
- }).strict()
1481
- }).strict();
1482
- var formSubmitConfigSchema = import_zod5.z.object({}).strict();
1483
-
1484
- // ../tracking-core/src/events/multi-page-session.ts
1485
- var import_zod6 = require("zod");
1486
- var multiPageSessionMetadataSchema = import_zod6.z.object({
1487
- page_count: import_zod6.z.number().int().min(2),
1488
- page: import_zod6.z.object({
1489
- path: import_zod6.z.string()
1490
- }).strict()
1491
- }).strict();
1492
- var multiPageSessionConfigSchema = import_zod6.z.object({
1493
- pageThreshold: import_zod6.z.number().int().min(2)
1494
- }).strict();
1495
-
1496
- // ../tracking-core/src/events/page-exit.ts
1497
- var import_zod7 = require("zod");
1498
- var pageExitMetadataSchema = import_zod7.z.object({
1499
- dwell_ms: import_zod7.z.number().int().min(0),
1500
- // null = left without any scroll signal; floor is 0 so a valid 0% is never
1501
- // rejected (a single bad field 422s the whole keepalive beacon batch).
1502
- max_scroll_percent: import_zod7.z.number().int().min(0).max(100).nullable(),
1503
- // The gating baseline: the fraction of the page visible at load with
1504
- // zero scrolling — or, for pages that grew after the post-paint snapshot
1505
- // (skeleton/streaming renders), the first-scroll position that
1506
- // established it. null = page had no scrollable range, or the segment
1507
- // ended before the snapshot. `.optional()` is load-bearing: SDK builds
1508
- // predating this field keep POSTing page_exit without the key —
1509
- // requiring it would 422 whole keepalive beacon batches.
1510
- scroll_baseline_percent: import_zod7.z.number().int().min(0).max(100).nullable().optional(),
1511
- page: import_zod7.z.object({
1512
- path: import_zod7.z.string()
1513
- }).strict()
1514
- }).strict();
1515
- var pageExitConfigSchema = import_zod7.z.object({}).strict();
1516
-
1517
- // ../tracking-core/src/events/phone-click.ts
1518
- var import_zod8 = require("zod");
1519
- var phoneClickMetadataSchema = import_zod8.z.object({
1520
- phone_number: import_zod8.z.string(),
1521
- page: import_zod8.z.object({
1522
- path: import_zod8.z.string()
1523
- }).strict(),
1524
- section: import_zod8.z.string().nullable().optional()
1525
- }).strict();
1526
- var phoneClickConfigSchema = import_zod8.z.object({
1527
- autoCapture: import_zod8.z.object({
1528
- selector: import_zod8.z.string().optional()
1529
- }).strict().optional()
1530
- }).strict();
1531
-
1532
- // ../tracking-core/src/events/scroll-depth.ts
1533
- var import_zod9 = require("zod");
1534
- var scrollDepthMetadataSchema = import_zod9.z.object({
1535
- depth_percent: import_zod9.z.number().int().min(1).max(100),
1536
- page: import_zod9.z.object({
1537
- path: import_zod9.z.string()
1538
- }).strict()
1539
- }).strict();
1540
- var scrollDepthConfigSchema = import_zod9.z.object({
1541
- thresholds: import_zod9.z.array(import_zod9.z.number().int().min(1).max(100)).min(1)
1542
- }).strict();
1543
-
1544
- // ../tracking-core/src/events/specific-page-visit.ts
1545
- var import_zod10 = require("zod");
1546
- var PAGE_IDENTITY_MAX_LENGTH = 64;
1547
- var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
1548
- var pageIdentitySchema = import_zod10.z.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
1549
- message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
1550
- });
1551
- var specificPageNameSchema = pageIdentitySchema;
1552
- var specificPageVisitMetadataSchema = import_zod10.z.object({
1553
- page_name: specificPageNameSchema,
1554
- page: import_zod10.z.object({
1555
- path: import_zod10.z.string()
1556
- }).strict()
1557
- }).strict();
1558
- var specificPageVisitConfigSchema = import_zod10.z.object({
1559
- pages: import_zod10.z.array(
1560
- import_zod10.z.object({
1561
- name: specificPageNameSchema,
1562
- pathPattern: import_zod10.z.custom((value) => value instanceof RegExp, {
1563
- message: "pathPattern must be a RegExp"
1564
- })
1565
- }).strict()
1566
- ).min(1)
1567
- }).strict();
1568
-
1569
- // ../tracking-core/src/events/time-on-site.ts
1570
- var import_zod11 = require("zod");
1571
- var timeOnSiteMetadataSchema = import_zod11.z.object({
1572
- duration_ms: import_zod11.z.number().int().nonnegative(),
1573
- page: import_zod11.z.object({
1574
- path: import_zod11.z.string()
1575
- }).strict()
1576
- }).strict();
1577
- var timeOnSiteConfigSchema = import_zod11.z.object({
1578
- thresholdSeconds: import_zod11.z.number().int().positive()
1579
- }).strict();
1580
-
1581
1391
  // ../tracking-core/src/events/semantics.ts
1582
1392
  var EVENT_SEMANTICS = {
1583
1393
  page_view: {
@@ -1651,82 +1461,6 @@ function getEventSemantics(eventName) {
1651
1461
  return eventName in EVENT_SEMANTICS ? EVENT_SEMANTICS[eventName] : null;
1652
1462
  }
1653
1463
 
1654
- // ../tracking-core/src/events/registry.ts
1655
- var EVENT_REGISTRY = {
1656
- // --- automatic triggers ---
1657
- page_view: {
1658
- kind: "automatic",
1659
- semantics: EVENT_SEMANTICS.page_view,
1660
- metadataSchema: pageViewMetadataSchema,
1661
- configSchema: pageViewConfigSchema
1662
- },
1663
- time_on_site: {
1664
- kind: "automatic",
1665
- semantics: EVENT_SEMANTICS.time_on_site,
1666
- metadataSchema: timeOnSiteMetadataSchema,
1667
- configSchema: timeOnSiteConfigSchema
1668
- },
1669
- specific_page_visit: {
1670
- kind: "automatic",
1671
- semantics: EVENT_SEMANTICS.specific_page_visit,
1672
- metadataSchema: specificPageVisitMetadataSchema,
1673
- configSchema: specificPageVisitConfigSchema
1674
- },
1675
- scroll_depth: {
1676
- kind: "automatic",
1677
- semantics: EVENT_SEMANTICS.scroll_depth,
1678
- metadataSchema: scrollDepthMetadataSchema,
1679
- configSchema: scrollDepthConfigSchema
1680
- },
1681
- multi_page_session: {
1682
- kind: "automatic",
1683
- semantics: EVENT_SEMANTICS.multi_page_session,
1684
- metadataSchema: multiPageSessionMetadataSchema,
1685
- configSchema: multiPageSessionConfigSchema
1686
- },
1687
- form_start: {
1688
- kind: "automatic",
1689
- semantics: EVENT_SEMANTICS.form_start,
1690
- metadataSchema: formStartMetadataSchema,
1691
- configSchema: formStartConfigSchema
1692
- },
1693
- // --- SDK-internal automatic (not consumer-configurable) ---
1694
- sdk_heartbeat: {
1695
- kind: "automatic",
1696
- semantics: EVENT_SEMANTICS.sdk_heartbeat,
1697
- metadataSchema: sdkHeartbeatMetadataSchema,
1698
- configSchema: sdkHeartbeatConfigSchema
1699
- },
1700
- page_exit: {
1701
- kind: "automatic",
1702
- semantics: EVENT_SEMANTICS.page_exit,
1703
- metadataSchema: pageExitMetadataSchema,
1704
- configSchema: pageExitConfigSchema
1705
- },
1706
- // --- manual triggers ---
1707
- form_submit: {
1708
- kind: "manual",
1709
- semantics: EVENT_SEMANTICS.form_submit,
1710
- metadataSchema: formSubmitMetadataSchema,
1711
- configSchema: formSubmitConfigSchema
1712
- },
1713
- phone_click: {
1714
- kind: "manual",
1715
- semantics: EVENT_SEMANTICS.phone_click,
1716
- metadataSchema: phoneClickMetadataSchema,
1717
- configSchema: phoneClickConfigSchema
1718
- },
1719
- cta_click: {
1720
- kind: "manual",
1721
- semantics: EVENT_SEMANTICS.cta_click,
1722
- metadataSchema: ctaClickMetadataSchema,
1723
- configSchema: ctaClickConfigSchema
1724
- }
1725
- };
1726
- var ALL_AUTOMATIC_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "automatic").map(([name]) => name);
1727
- var ALL_MANUAL_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "manual").map(([name]) => name);
1728
- var ALL_LEAD_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.semantics.outcomeRole === "lead").map(([name]) => name);
1729
-
1730
1464
  // ../tracking-core/src/resources/http/errors.ts
1731
1465
  var AranovaApiError = class extends Error {
1732
1466
  constructor(message, options) {
@@ -1764,9 +1498,9 @@ async function apiRequest(config, method, path, body, extraHeaders) {
1764
1498
  try {
1765
1499
  const parsed = await response.json();
1766
1500
  if (parsed && typeof parsed === "object") {
1767
- const record = parsed;
1768
- if (typeof record.detail === "string") detail = record.detail;
1769
- if (typeof record.code === "string") code = record.code;
1501
+ const record5 = parsed;
1502
+ if (typeof record5.detail === "string") detail = record5.detail;
1503
+ if (typeof record5.code === "string") code = record5.code;
1770
1504
  }
1771
1505
  } catch {
1772
1506
  }
@@ -1815,7 +1549,7 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
1815
1549
  }
1816
1550
  function createSalesClient(config) {
1817
1551
  if (config.firing) registerCapability("conversion_goals_manual");
1818
- async function record(input) {
1552
+ async function record5(input) {
1819
1553
  const currency = input.currency ?? config.defaultCurrency;
1820
1554
  if (!currency) {
1821
1555
  throw new Error(
@@ -1841,9 +1575,9 @@ function createSalesClient(config) {
1841
1575
  return sale;
1842
1576
  }
1843
1577
  return {
1844
- record,
1578
+ record: record5,
1845
1579
  // recordSale is the intent-revealing alias — same behavior, clearer call site.
1846
- recordSale: record,
1580
+ recordSale: record5,
1847
1581
  trackConversion(key, options) {
1848
1582
  if (config.firing && "fireConversion" in config.firing) {
1849
1583
  if (options?.userData && getConsentState() !== "denied") stashUserData(options.userData);
@@ -1962,115 +1696,264 @@ function createSalesClient(config) {
1962
1696
  }
1963
1697
 
1964
1698
  // ../tracking-core/src/resources/sales/schema.ts
1965
- var import_zod12 = require("zod");
1966
- var SUPPORTED_CURRENCIES = ["USD", "CAD"];
1967
- var TRACKING_ENVIRONMENTS = ["production", "development"];
1968
- var currencySchema = import_zod12.z.enum(SUPPORTED_CURRENCIES);
1969
- var centsSchema = import_zod12.z.number().int().nonnegative();
1970
- var quantitySchema = import_zod12.z.string().regex(/^\d+(\.\d{1,3})?$/);
1971
- var metadataSchema = import_zod12.z.record(import_zod12.z.unknown());
1972
- var saleItemSchema = import_zod12.z.object({
1973
- external_item_id: import_zod12.z.string().nullable().optional(),
1974
- name: import_zod12.z.string().nullable().optional(),
1975
- category: import_zod12.z.string().nullable().optional(),
1976
- quantity: quantitySchema,
1977
- unit_price_cents: centsSchema,
1978
- // Non-negativity validated on the wire — same contract as the other cents
1979
- // fields — and backstopped by the DB CHECK.
1980
- unit_cost_cents: centsSchema.nullable().optional()
1981
- }).strict();
1982
- var saleServiceSchema = import_zod12.z.object({
1983
- service: import_zod12.z.string(),
1984
- amount_cents: centsSchema
1985
- }).strict();
1986
- var customerNameSchema = import_zod12.z.string().max(200);
1987
- var customerPhoneSchema = import_zod12.z.string().max(64);
1988
- var customerEmailSchema = import_zod12.z.string().max(320).email();
1699
+ var z2 = __toESM(require("zod/mini"));
1700
+
1701
+ // ../tracking-core/src/resources/sales/generated/zod.gen.ts
1702
+ var z = __toESM(require("zod/mini"));
1703
+ var zErrorCode = z.enum([
1704
+ "missing_credentials",
1705
+ "invalid_api_key",
1706
+ "not_authenticated",
1707
+ "wrong_key_type",
1708
+ "origin_missing",
1709
+ "origin_not_allowed",
1710
+ "capability_denied",
1711
+ "session_required",
1712
+ "operator_only",
1713
+ "cross_tenant",
1714
+ "business_id_required",
1715
+ "bad_request",
1716
+ "not_found",
1717
+ "conflict",
1718
+ "incompatible_payload",
1719
+ "repeat_confirmation_required",
1720
+ "idempotency_conflict",
1721
+ "validation_error",
1722
+ "unknown_service",
1723
+ "invalid_sale_properties",
1724
+ "invalid_cursor",
1725
+ "rate_limited",
1726
+ "internal_error"
1727
+ ]);
1728
+ var zSaleItemEntitySchema = z.object({
1729
+ category: z.nullable(z.string()),
1730
+ external_item_id: z.nullable(z.string()),
1731
+ id: z.uuid(),
1732
+ name: z.nullable(z.string()),
1733
+ quantity: z.string().check(z.regex(/^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/)),
1734
+ unit_cost_cents: z.nullable(z.int()),
1735
+ unit_price_cents: z.int()
1736
+ });
1737
+ var zSaleItemInputSchema = z.strictObject({
1738
+ category: z.nullish(z.string()),
1739
+ external_item_id: z.nullish(z.string()),
1740
+ name: z.nullish(z.string()),
1741
+ quantity: z.string().check(z.regex(/^\d+(\.\d{1,3})?$/)),
1742
+ unit_cost_cents: z.nullish(z.int().check(z.gte(0))),
1743
+ unit_price_cents: z.int().check(z.gte(0))
1744
+ });
1745
+ var zSaleServiceEntitySchema = z.object({
1746
+ amount_cents: z.int(),
1747
+ id: z.uuid(),
1748
+ mapped: z.nullable(z.boolean()),
1749
+ service_id: z.uuid(),
1750
+ service_key: z.string(),
1751
+ service_label: z.string()
1752
+ });
1753
+ var zSaleServiceInputSchema = z.strictObject({
1754
+ amount_cents: z.int().check(z.gte(0)),
1755
+ service: z.string()
1756
+ });
1757
+ var zSmsAutomationState = z.enum([
1758
+ "needs_check",
1759
+ "failed",
1760
+ "undelivered",
1761
+ "blocked_opted_out",
1762
+ "withheld",
1763
+ "queued",
1764
+ "sent",
1765
+ "delivered",
1766
+ "eligible",
1767
+ "not_applicable"
1768
+ ]);
1769
+ var zSmsWithheldReason = z.enum([
1770
+ "automation_disabled",
1771
+ "sms_disabled",
1772
+ "no_phone",
1773
+ "no_consent",
1774
+ "no_customer_identity",
1775
+ "missing_customer_name",
1776
+ "placeholder_customer_name",
1777
+ "opted_out",
1778
+ "already_messaged",
1779
+ "sender_not_ready",
1780
+ "missing_review_url",
1781
+ "no_handler",
1782
+ "dispatch_already_recorded"
1783
+ ]);
1784
+ var zSaleSmsStatusSchema = z.object({
1785
+ can_send_now: z._default(z.boolean(), false),
1786
+ last_message_at: z.nullable(z.iso.datetime({ offset: true })),
1787
+ reason_detail: z.nullable(z.string()),
1788
+ state: zSmsAutomationState,
1789
+ suppressed_by_other_sale: z._default(z.boolean(), false),
1790
+ withheld_reason: z.nullable(zSmsWithheldReason)
1791
+ });
1792
+ var zSupportedCurrency = z.enum(["USD", "CAD"]);
1793
+ var zTrackingEnvironment = z.enum(["production", "development"]);
1794
+ var zSaleCreateSchema = z.strictObject({
1795
+ amount_total_cents: z.nullish(z.int().check(z.gte(0))),
1796
+ currency: zSupportedCurrency,
1797
+ customer_email: z.nullish(z.email().check(z.maxLength(320))),
1798
+ customer_name: z.nullish(z.string().check(z.maxLength(200))),
1799
+ customer_phone: z.nullish(z.string().check(z.maxLength(64))),
1800
+ description: z.nullish(z.string()),
1801
+ environment: z._default(z.optional(zTrackingEnvironment), "production"),
1802
+ external_id: z.nullish(z.string()),
1803
+ items: z.optional(z.array(zSaleItemInputSchema)),
1804
+ metadata: z.nullish(z.record(z.string(), z.unknown())),
1805
+ occurred_at: z.iso.datetime({ offset: true }),
1806
+ service: z.nullish(z.string()),
1807
+ services: z.nullish(z.array(zSaleServiceInputSchema)),
1808
+ sms_consent: z.nullish(z.boolean())
1809
+ });
1810
+ var zValidationError = z.object({
1811
+ ctx: z.optional(z.record(z.string(), z.unknown())),
1812
+ input: z.optional(z.unknown()),
1813
+ loc: z.array(z.union([z.string(), z.int()])),
1814
+ msg: z.string(),
1815
+ type: z.string()
1816
+ });
1817
+ var zHttpValidationError = z.object({
1818
+ detail: z.optional(z.array(zValidationError))
1819
+ });
1820
+ var zValidationErrorItem = z.object({
1821
+ loc: z.array(z.union([z.string(), z.int()])),
1822
+ msg: z.string(),
1823
+ type: z.string()
1824
+ });
1825
+ var zApiErrorSchema = z.object({
1826
+ code: zErrorCode,
1827
+ context: z._default(z.nullish(z.record(z.string(), z.unknown())), null),
1828
+ detail: z.string(),
1829
+ errors: z._default(z.nullish(z.array(zValidationErrorItem)), null),
1830
+ request_id: z._default(z.nullish(z.string()), null)
1831
+ });
1832
+ var zWritebackEmailSource = z.enum(["NONE", "SALE", "CUSTOMER", "HARVESTED"]);
1833
+ var zWritebackEnrichmentStatus = z.enum(["NONE", "MATCHED", "AMBIGUOUS"]);
1834
+ var zWritebackSaleUploadCounts = z.object({
1835
+ failed: z._default(z.int(), 0),
1836
+ pending: z._default(z.int(), 0),
1837
+ skipped: z._default(z.int(), 0),
1838
+ submitted: z._default(z.int(), 0),
1839
+ total: z._default(z.int(), 0),
1840
+ uploaded: z._default(z.int(), 0)
1841
+ });
1842
+ var zSaleWritebackStatusSchema = z.object({
1843
+ blocked_reason: z.nullable(z.string()),
1844
+ can_dispatch: z._default(z.boolean(), false),
1845
+ email_source: z.nullable(zWritebackEmailSource),
1846
+ enrichment_status: z.nullable(zWritebackEnrichmentStatus),
1847
+ gclid_attached: z._default(z.boolean(), false),
1848
+ identifiers_sent: z.nullable(z.string()),
1849
+ mapped_service_ids: z.array(z.uuid()),
1850
+ matched_submit_count: z.nullable(z.int()),
1851
+ needs_force: z._default(z.boolean(), false),
1852
+ rollup: z.enum([
1853
+ "failed",
1854
+ "skipped",
1855
+ "pending",
1856
+ "submitted",
1857
+ "uploaded",
1858
+ "not_uploaded",
1859
+ "out_of_window",
1860
+ "blocked"
1861
+ ]),
1862
+ stale: z._default(z.boolean(), false),
1863
+ uncovered_service_ids: z.array(z.uuid()),
1864
+ uploads: zWritebackSaleUploadCounts
1865
+ });
1866
+ var zSaleEntitySchema = z.object({
1867
+ amount_total_cents: z.int(),
1868
+ business_id: z.uuid(),
1869
+ business_name: z.nullable(z.string()),
1870
+ created_at: z.iso.datetime({ offset: true }),
1871
+ currency: z.string(),
1872
+ customer_email: z.nullable(z.string()),
1873
+ customer_name: z.nullable(z.string()),
1874
+ customer_name_placeholder_confirmed: z._default(z.boolean(), false),
1875
+ customer_name_placeholder_confirmed_at: z.nullable(z.iso.datetime({ offset: true })),
1876
+ customer_phone: z.nullable(z.string()),
1877
+ description: z.nullable(z.string()),
1878
+ environment: zTrackingEnvironment,
1879
+ external_id: z.nullable(z.string()),
1880
+ id: z.uuid(),
1881
+ items: z.array(zSaleItemEntitySchema),
1882
+ metadata: z.nullable(z.record(z.string(), z.unknown())),
1883
+ occurred_at: z.iso.datetime({ offset: true }),
1884
+ service_id: z.nullable(z.uuid()),
1885
+ service_key: z.nullable(z.string()),
1886
+ service_label: z.nullable(z.string()),
1887
+ services: z.array(zSaleServiceEntitySchema),
1888
+ sms_automation: z.nullable(zSaleSmsStatusSchema),
1889
+ sms_consent: z._default(z.boolean(), false),
1890
+ sms_consent_granted_at: z.nullable(z.iso.datetime({ offset: true })),
1891
+ updated_at: z.iso.datetime({ offset: true }),
1892
+ writeback: z.nullable(zSaleWritebackStatusSchema)
1893
+ });
1894
+
1895
+ // ../tracking-core/src/resources/sales/schema.ts
1896
+ var saleItemSchema = zSaleItemInputSchema;
1897
+ var saleServiceSchema = zSaleServiceInputSchema;
1898
+ var currencySchema = zSupportedCurrency;
1899
+ var SUPPORTED_CURRENCIES = currencySchema.options;
1900
+ var centsSchema = z2.int().check(z2.gte(0));
1901
+ var metadataSchema = z2.record(z2.string(), z2.unknown());
1902
+ var customerNameSchema = z2.string().check(z2.maxLength(200));
1903
+ var customerPhoneSchema = z2.string().check(z2.maxLength(64));
1904
+ var customerEmailSchema = z2.email().check(z2.maxLength(320));
1905
+ function addIssue(ctx, path, message) {
1906
+ ctx.issues.push({ code: "custom", input: ctx.value, path, message });
1907
+ }
1989
1908
  function refineServiceXor(val, ctx, { requireAmount }) {
1990
1909
  if (val.services != null) {
1991
1910
  if (val.service != null) {
1992
- ctx.addIssue({
1993
- code: import_zod12.z.ZodIssueCode.custom,
1994
- message: "pass either `service` or `services`, not both",
1995
- path: ["services"]
1996
- });
1911
+ addIssue(ctx, ["services"], "pass either `service` or `services`, not both");
1997
1912
  }
1998
1913
  if (val.services.length === 0) {
1999
- ctx.addIssue({
2000
- code: import_zod12.z.ZodIssueCode.custom,
2001
- message: "`services` must not be empty",
2002
- path: ["services"]
2003
- });
1914
+ addIssue(ctx, ["services"], "`services` must not be empty");
2004
1915
  }
2005
1916
  const keys = val.services.map((s) => s.service);
2006
1917
  if (new Set(keys).size !== keys.length) {
2007
- ctx.addIssue({
2008
- code: import_zod12.z.ZodIssueCode.custom,
2009
- message: "`services` must not list the same service more than once",
2010
- path: ["services"]
2011
- });
1918
+ addIssue(ctx, ["services"], "`services` must not list the same service more than once");
2012
1919
  }
2013
1920
  if (val.amount_total_cents != null) {
2014
1921
  const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
2015
1922
  if (val.amount_total_cents !== sum) {
2016
- ctx.addIssue({
2017
- code: import_zod12.z.ZodIssueCode.custom,
2018
- message: "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)",
2019
- path: ["amount_total_cents"]
2020
- });
1923
+ addIssue(
1924
+ ctx,
1925
+ ["amount_total_cents"],
1926
+ "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)"
1927
+ );
2021
1928
  }
2022
1929
  }
2023
1930
  } else if (requireAmount && val.amount_total_cents == null) {
2024
- ctx.addIssue({
2025
- code: import_zod12.z.ZodIssueCode.custom,
2026
- message: "amount_total_cents is required unless `services` is provided",
2027
- path: ["amount_total_cents"]
2028
- });
1931
+ addIssue(
1932
+ ctx,
1933
+ ["amount_total_cents"],
1934
+ "amount_total_cents is required unless `services` is provided"
1935
+ );
2029
1936
  }
2030
1937
  }
2031
- var saleCreateSchema = import_zod12.z.object({
2032
- external_id: import_zod12.z.string().nullable().optional(),
2033
- description: import_zod12.z.string().nullable().optional(),
2034
- service: import_zod12.z.string().nullable().optional(),
2035
- services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
2036
- currency: currencySchema,
2037
- // Optional only because the plural `services` form derives it from the sum
2038
- // (see refineServiceXor); the singular/serviceless path still requires it.
2039
- amount_total_cents: centsSchema.nullable().optional(),
2040
- occurred_at: import_zod12.z.string().datetime(),
2041
- environment: import_zod12.z.enum(TRACKING_ENVIRONMENTS).default("production"),
2042
- items: import_zod12.z.array(saleItemSchema).default([]),
2043
- metadata: metadataSchema.nullable().optional(),
2044
- customer_name: customerNameSchema.nullable().optional(),
2045
- customer_phone: customerPhoneSchema.nullable().optional(),
2046
- customer_email: customerEmailSchema.nullable().optional(),
2047
- // CASL consent attestation: the customer agreed to receive SMS. Recorded
2048
- // with a timestamp server-side; every SMS send path gates on it.
2049
- //
2050
- // Tri-state: omit it (or send null) to let the server apply the business's
2051
- // configured default-opt-in policy, honouring a returning customer's
2052
- // remembered preference. Send an explicit boolean to assert consent state
2053
- // yourself — `false` records a deliberate opt-out.
2054
- sms_consent: import_zod12.z.boolean().nullable().optional()
2055
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
2056
- var saleUpdateSchema = import_zod12.z.object({
2057
- description: import_zod12.z.string().nullable().optional(),
2058
- service: import_zod12.z.string().nullable().optional(),
2059
- services: import_zod12.z.array(saleServiceSchema).nullable().optional(),
2060
- currency: currencySchema.optional(),
2061
- amount_total_cents: centsSchema.optional(),
2062
- occurred_at: import_zod12.z.string().datetime().optional(),
2063
- items: import_zod12.z.array(saleItemSchema).optional(),
2064
- metadata: metadataSchema.nullable().optional(),
2065
- customer_name: customerNameSchema.nullable().optional(),
1938
+ var saleCreateSchema = z2.extend(zSaleCreateSchema, { items: z2._default(z2.array(saleItemSchema), []) }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: true }));
1939
+ var saleUpdateSchema = z2.strictObject({
1940
+ description: z2.nullish(z2.string()),
1941
+ service: z2.nullish(z2.string()),
1942
+ services: z2.nullish(z2.array(saleServiceSchema)),
1943
+ currency: z2.optional(currencySchema),
1944
+ amount_total_cents: z2.optional(centsSchema),
1945
+ occurred_at: z2.optional(z2.iso.datetime()),
1946
+ items: z2.optional(z2.array(saleItemSchema)),
1947
+ metadata: z2.nullish(metadataSchema),
1948
+ customer_name: z2.nullish(customerNameSchema),
2066
1949
  // Re-attest when changing a filler-looking name; the server clears the
2067
1950
  // prior attestation whenever `customer_name` changes.
2068
- customer_name_placeholder_confirmed: import_zod12.z.boolean().optional(),
2069
- customer_phone: customerPhoneSchema.nullable().optional(),
2070
- customer_email: customerEmailSchema.nullable().optional(),
1951
+ customer_name_placeholder_confirmed: z2.optional(z2.boolean()),
1952
+ customer_phone: z2.nullish(customerPhoneSchema),
1953
+ customer_email: z2.nullish(customerEmailSchema),
2071
1954
  // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
2072
- sms_consent: import_zod12.z.boolean().optional()
2073
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: false }));
1955
+ sms_consent: z2.optional(z2.boolean())
1956
+ }).check((ctx) => refineServiceXor(ctx.value, ctx, { requireAmount: false }));
2074
1957
  var TRACKING_RANGES = ["24h", "7d", "30d"];
2075
1958
  var NAMED_RANGES = [
2076
1959
  "today",
@@ -2141,8 +2024,8 @@ function instantFromWallClock(timeZone, year, month, day, hour = 0, minute = 0)
2141
2024
  const corrected = naive - offsetMinutesAt(firstGuess, timeZone) * 6e4;
2142
2025
  return new Date(corrected);
2143
2026
  }
2144
- function localDateKey(iso, timeZone) {
2145
- const p = partsInTz(new Date(iso), timeZone);
2027
+ function localDateKey(iso4, timeZone) {
2028
+ const p = partsInTz(new Date(iso4), timeZone);
2146
2029
  const pad = (n) => String(n).padStart(2, "0");
2147
2030
  return `${p.year}-${pad(p.month)}-${pad(p.day)}`;
2148
2031
  }
@@ -2197,7 +2080,167 @@ function isCalendarError(error, code) {
2197
2080
  }
2198
2081
 
2199
2082
  // ../tracking-core/src/resources/calendar/schema.ts
2200
- var import_zod13 = require("zod");
2083
+ var z4 = __toESM(require("zod/mini"));
2084
+
2085
+ // ../tracking-core/src/resources/calendar/generated/zod.gen.ts
2086
+ var z3 = __toESM(require("zod/mini"));
2087
+ var zBookingAttendee = z3.strictObject({
2088
+ display_name: z3.nullish(z3.string().check(z3.maxLength(200))),
2089
+ email: z3.email().check(z3.maxLength(320)),
2090
+ optional: z3._default(z3.optional(z3.boolean()), false)
2091
+ });
2092
+ var zBookingCancelSchema = z3.strictObject({
2093
+ notify_attendees: z3._default(z3.optional(z3.boolean()), true),
2094
+ reason: z3.nullish(z3.string().check(z3.maxLength(500)))
2095
+ });
2096
+ var zBookingCustomerInput = z3.strictObject({
2097
+ email: z3.email().check(z3.maxLength(320)),
2098
+ name: z3.nullish(z3.string().check(z3.maxLength(200))),
2099
+ phone: z3.nullish(z3.string().check(z3.maxLength(64))),
2100
+ sms_consent: z3._default(z3.optional(z3.boolean()), false)
2101
+ });
2102
+ var zBookingCustomerOutput = z3.strictObject({
2103
+ email: z3.email().check(z3.maxLength(320)),
2104
+ name: z3.nullable(z3.string().check(z3.maxLength(200))),
2105
+ phone: z3.nullable(z3.string().check(z3.maxLength(64))),
2106
+ sms_consent: z3._default(z3.boolean(), false)
2107
+ });
2108
+ var zBookingRescheduleSchema = z3.strictObject({
2109
+ duration_minutes: z3.nullish(z3.int().check(z3.gt(0), z3.lte(1440))),
2110
+ end_at: z3.nullish(z3.iso.datetime({ offset: true })),
2111
+ notify_attendees: z3._default(z3.optional(z3.boolean()), true),
2112
+ reason: z3.nullish(z3.string().check(z3.maxLength(500))),
2113
+ start_at: z3.iso.datetime({ offset: true }),
2114
+ time_zone: z3.string().check(z3.minLength(1), z3.maxLength(64), z3.regex(/^[A-Za-z0-9_+\-\/]+$/))
2115
+ });
2116
+ var zBookingResponse = z3.strictObject({
2117
+ appointment_type: z3.nullable(z3.string()),
2118
+ calendar_key: z3.string(),
2119
+ customer: zBookingCustomerOutput,
2120
+ end_at: z3.iso.datetime({ offset: true }),
2121
+ google_html_link: z3.nullable(z3.string()),
2122
+ google_sync_state: z3.string(),
2123
+ id: z3.string(),
2124
+ manage_token: z3.nullable(z3.string()),
2125
+ meet_url: z3.nullable(z3.string()),
2126
+ start_at: z3.iso.datetime({ offset: true }),
2127
+ status: z3.string(),
2128
+ time_zone: z3.string(),
2129
+ title: z3.string()
2130
+ });
2131
+ var zBookingSource = z3.enum(["website", "phone", "walk_in", "import", "operator"]);
2132
+ var zBookingMetadata = z3.strictObject({
2133
+ custom: z3.nullish(
2134
+ z3.record(z3.string(), z3.nullable(z3.union([z3.string(), z3.int(), z3.number(), z3.boolean()])))
2135
+ ),
2136
+ fbclid: z3.nullish(z3.string().check(z3.maxLength(256))),
2137
+ gclid: z3.nullish(z3.string().check(z3.maxLength(256))),
2138
+ landing_page: z3.nullish(z3.string().check(z3.maxLength(2048))),
2139
+ notes: z3.nullish(z3.string().check(z3.maxLength(2e3))),
2140
+ referrer: z3.nullish(z3.string().check(z3.maxLength(2048))),
2141
+ schema_version: z3._default(z3.optional(z3.int()), 1),
2142
+ service: z3.nullish(z3.string().check(z3.maxLength(64))),
2143
+ session_id: z3.nullish(z3.string().check(z3.maxLength(64))),
2144
+ source: z3.nullish(zBookingSource),
2145
+ utm_campaign: z3.nullish(z3.string().check(z3.maxLength(128))),
2146
+ utm_content: z3.nullish(z3.string().check(z3.maxLength(128))),
2147
+ utm_medium: z3.nullish(z3.string().check(z3.maxLength(128))),
2148
+ utm_source: z3.nullish(z3.string().check(z3.maxLength(128))),
2149
+ utm_term: z3.nullish(z3.string().check(z3.maxLength(128))),
2150
+ visitor_id: z3.nullish(z3.string().check(z3.maxLength(64)))
2151
+ });
2152
+ var zCustomLocation = z3.strictObject({
2153
+ kind: z3.literal("custom"),
2154
+ text: z3.string().check(z3.maxLength(1024))
2155
+ });
2156
+ var zErrorCode2 = z3.enum([
2157
+ "missing_credentials",
2158
+ "invalid_api_key",
2159
+ "not_authenticated",
2160
+ "wrong_key_type",
2161
+ "origin_missing",
2162
+ "origin_not_allowed",
2163
+ "capability_denied",
2164
+ "session_required",
2165
+ "operator_only",
2166
+ "cross_tenant",
2167
+ "business_id_required",
2168
+ "bad_request",
2169
+ "not_found",
2170
+ "conflict",
2171
+ "incompatible_payload",
2172
+ "repeat_confirmation_required",
2173
+ "idempotency_conflict",
2174
+ "validation_error",
2175
+ "unknown_service",
2176
+ "invalid_sale_properties",
2177
+ "invalid_cursor",
2178
+ "rate_limited",
2179
+ "internal_error"
2180
+ ]);
2181
+ var zMeetLocation = z3.strictObject({
2182
+ kind: z3.literal("google_meet")
2183
+ });
2184
+ var zPhoneLocation = z3.strictObject({
2185
+ kind: z3.literal("phone"),
2186
+ phone: z3.string().check(z3.maxLength(64))
2187
+ });
2188
+ var zPhysicalLocation = z3.strictObject({
2189
+ address: z3.string().check(z3.maxLength(1024)),
2190
+ kind: z3.literal("physical")
2191
+ });
2192
+ var zReminderMethod = z3.enum(["email", "popup"]);
2193
+ var zBookingReminder = z3.strictObject({
2194
+ method: zReminderMethod,
2195
+ minutes_before: z3.int().check(z3.gte(0), z3.lte(40320))
2196
+ });
2197
+ var zBookingReminders = z3.strictObject({
2198
+ overrides: z3.optional(z3.array(zBookingReminder).check(z3.maxLength(5))),
2199
+ use_calendar_defaults: z3._default(z3.optional(z3.boolean()), true)
2200
+ });
2201
+ var zBookingCreateSchema = z3.strictObject({
2202
+ appointment_type: z3.nullish(z3.string().check(z3.maxLength(64))),
2203
+ attendees: z3.optional(z3.array(zBookingAttendee).check(z3.maxLength(20))),
2204
+ buffer_after_minutes: z3._default(z3.optional(z3.int().check(z3.gte(0), z3.lte(1440))), 0),
2205
+ buffer_before_minutes: z3._default(z3.optional(z3.int().check(z3.gte(0), z3.lte(1440))), 0),
2206
+ calendar_key: z3.string().check(z3.minLength(1), z3.maxLength(64)),
2207
+ customer: zBookingCustomerInput,
2208
+ description: z3.nullish(z3.string().check(z3.maxLength(8e3))),
2209
+ duration_minutes: z3.nullish(z3.int().check(z3.gt(0), z3.lte(1440))),
2210
+ end_at: z3.nullish(z3.iso.datetime({ offset: true })),
2211
+ idempotency_key: z3.nullish(z3.string().check(z3.maxLength(128))),
2212
+ location: z3.nullish(z3.union([zMeetLocation, zPhysicalLocation, zPhoneLocation, zCustomLocation])),
2213
+ metadata: z3.nullish(zBookingMetadata),
2214
+ reminders: z3.nullish(zBookingReminders),
2215
+ send_invites: z3._default(z3.optional(z3.boolean()), true),
2216
+ start_at: z3.iso.datetime({ offset: true }),
2217
+ time_zone: z3.string().check(z3.minLength(1), z3.maxLength(64), z3.regex(/^[A-Za-z0-9_+\-\/]+$/)),
2218
+ title: z3.nullish(z3.string().check(z3.maxLength(300)))
2219
+ });
2220
+ var zValidationError2 = z3.object({
2221
+ ctx: z3.optional(z3.record(z3.string(), z3.unknown())),
2222
+ input: z3.optional(z3.unknown()),
2223
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2224
+ msg: z3.string(),
2225
+ type: z3.string()
2226
+ });
2227
+ var zHttpValidationError2 = z3.object({
2228
+ detail: z3.optional(z3.array(zValidationError2))
2229
+ });
2230
+ var zValidationErrorItem2 = z3.object({
2231
+ loc: z3.array(z3.union([z3.string(), z3.int()])),
2232
+ msg: z3.string(),
2233
+ type: z3.string()
2234
+ });
2235
+ var zApiErrorSchema2 = z3.object({
2236
+ code: zErrorCode2,
2237
+ context: z3._default(z3.nullish(z3.record(z3.string(), z3.unknown())), null),
2238
+ detail: z3.string(),
2239
+ errors: z3._default(z3.nullish(z3.array(zValidationErrorItem2)), null),
2240
+ request_id: z3._default(z3.nullish(z3.string()), null)
2241
+ });
2242
+
2243
+ // ../tracking-core/src/resources/calendar/schema.ts
2201
2244
  var CALENDAR_METADATA_SCHEMA_VERSION = 1;
2202
2245
  var MAX_ATTENDEES = 20;
2203
2246
  var MAX_REMINDER_OVERRIDES = 5;
@@ -2223,7 +2266,6 @@ var CALENDAR_ERROR_CODES = [
2223
2266
  "rate_limited",
2224
2267
  "google_error"
2225
2268
  ];
2226
- var isoInstant = import_zod13.z.string().datetime({ offset: true });
2227
2269
  function isKnownTimeZone(timeZone) {
2228
2270
  try {
2229
2271
  new Intl.DateTimeFormat(void 0, { timeZone });
@@ -2232,107 +2274,65 @@ function isKnownTimeZone(timeZone) {
2232
2274
  return false;
2233
2275
  }
2234
2276
  }
2235
- var ianaTz = import_zod13.z.string().min(1).max(64).regex(/^[A-Za-z0-9_+\-/]+$/).refine(isKnownTimeZone, { message: "unknown IANA time zone" });
2236
- var bookingAttendeeSchema = import_zod13.z.object({
2237
- email: import_zod13.z.string().max(320).email(),
2238
- display_name: import_zod13.z.string().max(200).nullable().optional(),
2239
- optional: import_zod13.z.boolean().default(false)
2240
- }).strict();
2241
- var bookingReminderSchema = import_zod13.z.object({
2242
- method: import_zod13.z.enum(["email", "popup"]),
2243
- minutes_before: import_zod13.z.number().int().min(0).max(MAX_REMINDER_MINUTES)
2244
- }).strict();
2245
- var bookingRemindersSchema = import_zod13.z.object({
2246
- use_calendar_defaults: import_zod13.z.boolean().default(true),
2247
- overrides: import_zod13.z.array(bookingReminderSchema).max(MAX_REMINDER_OVERRIDES).default([])
2248
- }).strict();
2249
- var bookingLocationSchema = import_zod13.z.union([
2250
- import_zod13.z.object({ kind: import_zod13.z.literal("google_meet") }).strict(),
2251
- import_zod13.z.object({ kind: import_zod13.z.literal("physical"), address: import_zod13.z.string().max(1024) }).strict(),
2252
- import_zod13.z.object({ kind: import_zod13.z.literal("phone"), phone: import_zod13.z.string().max(64) }).strict(),
2253
- import_zod13.z.object({ kind: import_zod13.z.literal("custom"), text: import_zod13.z.string().max(1024) }).strict()
2277
+ var ianaTz = z4.string().check(
2278
+ z4.minLength(1),
2279
+ z4.maxLength(64),
2280
+ z4.regex(/^[A-Za-z0-9_+\-/]+$/),
2281
+ z4.refine(isKnownTimeZone, { error: "unknown IANA time zone" })
2282
+ );
2283
+ var bookingAttendeeSchema = zBookingAttendee;
2284
+ var bookingReminderSchema = zBookingReminder;
2285
+ var bookingCustomerSchema = zBookingCustomerInput;
2286
+ var bookingMetadataSchema = z4.extend(zBookingMetadata, {
2287
+ custom: z4.nullish(
2288
+ z4.record(z4.string(), z4.union([z4.string(), z4.int(), z4.number(), z4.boolean(), z4.null()]))
2289
+ )
2290
+ });
2291
+ var bookingLocationSchema = z4.union([
2292
+ zMeetLocation,
2293
+ zPhysicalLocation,
2294
+ zPhoneLocation,
2295
+ zCustomLocation
2254
2296
  ]);
2255
- var bookingLocationNullableSchema = import_zod13.z.union([...bookingLocationSchema.options, import_zod13.z.null()]);
2256
- var bookingCustomerSchema = import_zod13.z.object({
2257
- // Required: Google needs an address to send the invite that confirms the
2258
- // booking, and that invite is the whole confirmation mechanism.
2259
- email: import_zod13.z.string().max(320).email(),
2260
- name: import_zod13.z.string().max(200).nullable().optional(),
2261
- phone: import_zod13.z.string().max(64).nullable().optional(),
2262
- sms_consent: import_zod13.z.boolean().default(false)
2263
- }).strict();
2264
- var jsonScalar = import_zod13.z.union([import_zod13.z.string(), import_zod13.z.number(), import_zod13.z.boolean(), import_zod13.z.null()]);
2265
- var bookingMetadataSchema = import_zod13.z.object({
2266
- schema_version: import_zod13.z.number().int().default(CALENDAR_METADATA_SCHEMA_VERSION),
2267
- source: import_zod13.z.enum(BOOKING_SOURCES).nullable().optional(),
2268
- service: import_zod13.z.string().max(64).nullable().optional(),
2269
- visitor_id: import_zod13.z.string().max(64).nullable().optional(),
2270
- session_id: import_zod13.z.string().max(64).nullable().optional(),
2271
- gclid: import_zod13.z.string().max(256).nullable().optional(),
2272
- fbclid: import_zod13.z.string().max(256).nullable().optional(),
2273
- utm_source: import_zod13.z.string().max(128).nullable().optional(),
2274
- utm_medium: import_zod13.z.string().max(128).nullable().optional(),
2275
- utm_campaign: import_zod13.z.string().max(128).nullable().optional(),
2276
- utm_term: import_zod13.z.string().max(128).nullable().optional(),
2277
- utm_content: import_zod13.z.string().max(128).nullable().optional(),
2278
- landing_page: import_zod13.z.string().max(2048).nullable().optional(),
2279
- referrer: import_zod13.z.string().max(2048).nullable().optional(),
2280
- notes: import_zod13.z.string().max(2e3).nullable().optional(),
2281
- custom: import_zod13.z.record(jsonScalar).nullable().optional()
2282
- }).strict();
2297
+ var bookingLocationNullableSchema = z4.union([
2298
+ ...bookingLocationSchema.def.options,
2299
+ z4.null()
2300
+ ]);
2301
+ function addIssue2(ctx, path, message) {
2302
+ ctx.issues.push({ code: "custom", input: ctx.value, path, message });
2303
+ }
2283
2304
  function refineEndXor(value, ctx) {
2284
2305
  const hasEnd = value.end_at !== void 0 && value.end_at !== null;
2285
2306
  const hasDuration = value.duration_minutes !== void 0 && value.duration_minutes !== null;
2286
2307
  if (hasEnd === hasDuration) {
2287
- ctx.addIssue({
2288
- code: import_zod13.z.ZodIssueCode.custom,
2289
- message: "provide exactly one of end_at or duration_minutes",
2290
- path: ["end_at"]
2291
- });
2308
+ addIssue2(ctx, ["end_at"], "provide exactly one of end_at or duration_minutes");
2292
2309
  return;
2293
2310
  }
2294
2311
  if (hasEnd && new Date(value.end_at) <= new Date(value.start_at)) {
2295
- ctx.addIssue({
2296
- code: import_zod13.z.ZodIssueCode.custom,
2297
- message: "end_at must be after start_at",
2298
- path: ["end_at"]
2299
- });
2312
+ addIssue2(ctx, ["end_at"], "end_at must be after start_at");
2300
2313
  }
2301
2314
  }
2302
- var bookingCreateSchema = import_zod13.z.object({
2303
- calendar_key: import_zod13.z.string().min(1).max(64),
2304
- // Free-form: appointment types are the client site's own vocabulary, not
2305
- // configuration the dashboard holds.
2306
- appointment_type: import_zod13.z.string().max(64).nullable().optional(),
2307
- start_at: isoInstant,
2308
- end_at: isoInstant.nullable().optional(),
2309
- duration_minutes: import_zod13.z.number().int().positive().max(MAX_BOOKING_MINUTES).nullable().optional(),
2310
- /** The booker's zone — distinct from the business's and the calendar's. */
2311
- time_zone: ianaTz,
2312
- title: import_zod13.z.string().max(300).nullable().optional(),
2313
- description: import_zod13.z.string().max(8e3).nullable().optional(),
2314
- location: bookingLocationNullableSchema.optional(),
2315
- customer: bookingCustomerSchema,
2316
- attendees: import_zod13.z.array(bookingAttendeeSchema).max(MAX_ATTENDEES).default([]),
2317
- send_invites: import_zod13.z.boolean().default(true),
2318
- reminders: bookingRemindersSchema.nullable().optional(),
2319
- metadata: bookingMetadataSchema.nullable().optional(),
2320
- idempotency_key: import_zod13.z.string().max(128).nullable().optional(),
2321
- buffer_before_minutes: import_zod13.z.number().int().min(0).max(MAX_BOOKING_MINUTES).default(0),
2322
- buffer_after_minutes: import_zod13.z.number().int().min(0).max(MAX_BOOKING_MINUTES).default(0)
2323
- }).strict().superRefine(refineEndXor);
2324
- var bookingRescheduleSchema = import_zod13.z.object({
2325
- start_at: isoInstant,
2326
- end_at: isoInstant.nullable().optional(),
2327
- duration_minutes: import_zod13.z.number().int().positive().max(MAX_BOOKING_MINUTES).nullable().optional(),
2315
+ var bookingRemindersSchema = z4.extend(zBookingReminders, {
2316
+ overrides: z4._default(
2317
+ z4.array(bookingReminderSchema).check(z4.maxLength(MAX_REMINDER_OVERRIDES)),
2318
+ []
2319
+ )
2320
+ });
2321
+ var bookingCreateSchema = z4.extend(zBookingCreateSchema, {
2328
2322
  time_zone: ianaTz,
2329
- notify_attendees: import_zod13.z.boolean().default(true),
2330
- reason: import_zod13.z.string().max(500).nullable().optional()
2331
- }).strict().superRefine(refineEndXor);
2332
- var bookingCancelSchema = import_zod13.z.object({
2333
- reason: import_zod13.z.string().max(500).nullable().optional(),
2334
- notify_attendees: import_zod13.z.boolean().default(true)
2335
- }).strict();
2323
+ // The generated field is `z.union([...variants]).nullish()`, which nests one
2324
+ // `anyOf` inside another; Pydantic's `BookingLocation | None` flattens to a
2325
+ // single list and the drift snapshot compares structure. Override with the
2326
+ // flattened union.
2327
+ location: z4.optional(bookingLocationNullableSchema),
2328
+ attendees: z4._default(z4.array(bookingAttendeeSchema).check(z4.maxLength(MAX_ATTENDEES)), []),
2329
+ // These reference the un-composed generated schemas; generation can't nest
2330
+ // our compositions into its own output.
2331
+ reminders: z4.nullish(bookingRemindersSchema),
2332
+ metadata: z4.nullish(bookingMetadataSchema)
2333
+ }).check((ctx) => refineEndXor(ctx.value, ctx));
2334
+ var bookingRescheduleSchema = z4.extend(zBookingRescheduleSchema, { time_zone: ianaTz }).check((ctx) => refineEndXor(ctx.value, ctx));
2335
+ var bookingCancelSchema = zBookingCancelSchema;
2336
2336
 
2337
2337
  // ../tracking-core/src/resources/calendar/slots.ts
2338
2338
  function parseHhMm(value) {
@@ -2560,6 +2560,7 @@ var import_client2 = require("@aranova/tracking-next/client");
2560
2560
  createTrackingClientContext,
2561
2561
  createTrackingEventCreatePayload,
2562
2562
  createTrackingSessionUpsertPayload,
2563
+ currencySchema,
2563
2564
  durationMinutes,
2564
2565
  endOfDayInTz,
2565
2566
  fetchServices,