@aranova/tracking-next 0.27.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 (71) 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 +4 -3
  26. package/dist/client.d.ts +4 -3
  27. package/dist/client.js +185 -277
  28. package/dist/client.js.map +1 -1
  29. package/dist/client.mjs +157 -249
  30. package/dist/client.mjs.map +1 -1
  31. package/dist/index.d.mts +8 -7
  32. package/dist/index.d.ts +8 -7
  33. package/dist/index.js +482 -484
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +471 -484
  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 -467
  40. package/dist/middleware.js.map +1 -1
  41. package/dist/middleware.mjs +0 -467
  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 -464
  48. package/dist/phone.js.map +1 -1
  49. package/dist/phone.mjs +0 -464
  50. package/dist/phone.mjs.map +1 -1
  51. package/dist/{sales-DQGzXSgL.d.mts → sales-D7KstKA-.d.mts} +89 -328
  52. package/dist/{sales-IGC2tq4J.d.ts → sales-DG150g3o.d.ts} +89 -328
  53. package/dist/sales.d.mts +2 -2
  54. package/dist/sales.d.ts +2 -2
  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 -467
  62. package/dist/server.js.map +1 -1
  63. package/dist/server.mjs +0 -467
  64. package/dist/server.mjs.map +1 -1
  65. package/dist/transport-CDmGOiCq.d.ts +253 -0
  66. package/dist/transport-I_cMSFQ6.d.mts +253 -0
  67. package/package.json +2 -2
  68. package/dist/ingest-typed-BxLFlZ7N.d.mts +0 -1371
  69. package/dist/ingest-typed-ByQVRMvP.d.ts +0 -1371
  70. package/dist/transport-C-_rFSR4.d.ts +0 -721
  71. package/dist/transport-yUF5Wize.d.mts +0 -721
package/dist/client.mjs CHANGED
@@ -580,10 +580,10 @@ function readStoredRecord() {
580
580
  return null;
581
581
  }
582
582
  }
583
- function writeRecord(record) {
584
- memoryRecord = record;
583
+ function writeRecord(record3) {
584
+ memoryRecord = record3;
585
585
  try {
586
- window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record));
586
+ window.localStorage.setItem(LANDING_STORAGE_KEY, JSON.stringify(record3));
587
587
  } catch {
588
588
  }
589
589
  }
@@ -605,9 +605,9 @@ function getOrCaptureLandingParams(sessionId, url) {
605
605
  if (memoryRecord && memoryRecord.session_id === sessionId) {
606
606
  return memoryRecord.params;
607
607
  }
608
- const record = { session_id: sessionId, params: captureFromUrl(url) };
609
- writeRecord(record);
610
- return record.params;
608
+ const record3 = { session_id: sessionId, params: captureFromUrl(url) };
609
+ writeRecord(record3);
610
+ return record3.params;
611
611
  }
612
612
  function buildLandingPayloadFields(sessionId, override) {
613
613
  const params = override ?? (typeof window === "undefined" ? null : getOrCaptureLandingParams(sessionId));
@@ -1439,25 +1439,32 @@ function getOrRotateSessionId(now = Date.now()) {
1439
1439
  return { id: fresh.id, isNew: true };
1440
1440
  }
1441
1441
 
1442
+ // ../tracking-core/src/page-view.ts
1443
+ import { parse } from "zod/mini";
1444
+
1442
1445
  // ../tracking-core/src/events/page-view.ts
1443
- import { z } from "zod";
1444
- var pageViewMetadataSchema = z.object({
1445
- page: z.object({
1446
- title: z.string().nullable(),
1446
+ import * as z from "zod/mini";
1447
+ var pageViewMetadataSchema = z.strictObject({
1448
+ page: z.strictObject({
1449
+ title: z.nullable(z.string()),
1447
1450
  path: z.string(),
1448
1451
  search: z.string(),
1449
1452
  hash: z.string()
1450
- }).strict(),
1451
- referrer: z.string().nullable(),
1452
- // `.nullable().optional()` — absent (undefined) OR explicit null OR a
1453
+ }),
1454
+ referrer: z.nullable(z.string()),
1455
+ // Optional + nullable — absent (undefined) OR explicit null OR a
1453
1456
  // real viewport object. Mirrors Pydantic's `_Viewport | None = None`
1454
1457
  // on the backend side so the drift test stays clean.
1455
- viewport: z.object({
1456
- w: z.number(),
1457
- h: z.number()
1458
- }).strict().nullable().optional()
1459
- }).strict();
1460
- var pageViewConfigSchema = z.object({}).strict();
1458
+ viewport: z.optional(
1459
+ z.nullable(
1460
+ z.strictObject({
1461
+ w: z.number(),
1462
+ h: z.number()
1463
+ })
1464
+ )
1465
+ )
1466
+ });
1467
+ var pageViewConfigSchema = z.strictObject({});
1461
1468
 
1462
1469
  // ../tracking-core/src/page-view.ts
1463
1470
  var LAST_FIRED_URL_STORAGE_KEY = "aranova_tracking_last_fired_url";
@@ -1493,7 +1500,7 @@ function setLastFiredUrl(url) {
1493
1500
  }
1494
1501
  function buildPageViewMetadata(referrerOverride) {
1495
1502
  if (typeof window === "undefined" || typeof document === "undefined") return null;
1496
- return pageViewMetadataSchema.parse({
1503
+ return parse(pageViewMetadataSchema, {
1497
1504
  page: {
1498
1505
  title: document.title || null,
1499
1506
  path: window.location.pathname,
@@ -1951,186 +1958,198 @@ function createTrackingClient(config) {
1951
1958
  };
1952
1959
  }
1953
1960
 
1961
+ // ../tracking-core/src/ingest-typed.ts
1962
+ import { parse as parse2 } from "zod/mini";
1963
+
1954
1964
  // ../tracking-core/src/events/cta-click.ts
1955
- import { z as z2 } from "zod";
1956
- var ctaClickMetadataSchema = z2.object({
1965
+ import * as z2 from "zod/mini";
1966
+ var ctaClickMetadataSchema = z2.strictObject({
1957
1967
  cta_name: z2.string(),
1958
- page: z2.object({
1968
+ page: z2.strictObject({
1959
1969
  path: z2.string()
1960
- }).strict(),
1961
- section: z2.string().nullable().optional(),
1962
- destination_url: z2.string().nullable().optional(),
1970
+ }),
1971
+ section: z2.optional(z2.nullable(z2.string())),
1972
+ destination_url: z2.optional(z2.nullable(z2.string())),
1963
1973
  // Set by auto-capture (and available to manual callers): the link target
1964
1974
  // and a short element descriptor (tag#id) for tying clicks to specific UI.
1965
- href: z2.string().nullable().optional(),
1966
- element: z2.string().nullable().optional()
1967
- }).strict();
1968
- var ctaClickConfigSchema = z2.object({
1969
- autoCapture: z2.object({
1970
- selector: z2.string().optional()
1971
- }).strict().optional()
1972
- }).strict();
1975
+ href: z2.optional(z2.nullable(z2.string())),
1976
+ element: z2.optional(z2.nullable(z2.string()))
1977
+ });
1978
+ var ctaClickConfigSchema = z2.strictObject({
1979
+ autoCapture: z2.optional(
1980
+ z2.strictObject({
1981
+ selector: z2.optional(z2.string())
1982
+ })
1983
+ )
1984
+ });
1973
1985
 
1974
1986
  // ../tracking-core/src/events/sdk-heartbeat.ts
1975
- import { z as z3 } from "zod";
1976
- var sdkHeartbeatTriggersSchema = z3.object({
1987
+ import * as z3 from "zod/mini";
1988
+ var sdkHeartbeatTriggersSchema = z3.strictObject({
1977
1989
  automatic: z3.array(z3.string()),
1978
1990
  manual: z3.array(z3.string())
1979
- }).strict();
1980
- var sdkHeartbeatMetadataSchema = z3.object({
1991
+ });
1992
+ var sdkHeartbeatMetadataSchema = z3.strictObject({
1981
1993
  sdk_version: z3.string(),
1982
- package_name: z3.string().nullable(),
1994
+ package_name: z3.nullable(z3.string()),
1983
1995
  surface: z3.enum(["next", "react", "script"]),
1984
1996
  triggers: sdkHeartbeatTriggersSchema,
1985
- trigger_config: z3.record(z3.string(), z3.record(z3.string(), z3.unknown())).nullable().optional(),
1986
- configured_gtag_ids: z3.record(z3.string(), z3.string()).nullable().optional(),
1997
+ trigger_config: z3.optional(z3.nullable(z3.record(z3.string(), z3.record(z3.string(), z3.unknown())))),
1998
+ configured_gtag_ids: z3.optional(z3.nullable(z3.record(z3.string(), z3.string()))),
1987
1999
  // Site whose config object the SDK resolves; null on a legacy business ref.
1988
- config_site_id: z3.string().uuid().nullable().optional()
1989
- }).strict();
1990
- var sdkHeartbeatConfigSchema = z3.object({}).strict();
2000
+ config_site_id: z3.optional(z3.nullable(z3.uuid()))
2001
+ });
2002
+ var sdkHeartbeatConfigSchema = z3.strictObject({});
1991
2003
 
1992
2004
  // ../tracking-core/src/events/form-start.ts
1993
- import { z as z4 } from "zod";
1994
- var formStartMetadataSchema = z4.object({
1995
- form: z4.object({
2005
+ import * as z4 from "zod/mini";
2006
+ var formStartMetadataSchema = z4.strictObject({
2007
+ form: z4.strictObject({
1996
2008
  id: z4.string(),
1997
- action: z4.string().nullable()
1998
- }).strict(),
1999
- page: z4.object({
2009
+ action: z4.nullable(z4.string())
2010
+ }),
2011
+ page: z4.strictObject({
2000
2012
  path: z4.string()
2001
- }).strict()
2002
- }).strict();
2003
- var formStartConfigSchema = z4.object({
2004
- selector: z4.string().optional()
2005
- }).strict();
2013
+ })
2014
+ });
2015
+ var formStartConfigSchema = z4.strictObject({
2016
+ selector: z4.optional(z4.string())
2017
+ });
2006
2018
 
2007
2019
  // ../tracking-core/src/events/form-submit.ts
2008
- import { z as z5 } from "zod";
2020
+ import * as z5 from "zod/mini";
2009
2021
  var jsonValueSchema = z5.lazy(
2010
2022
  () => z5.union([
2011
2023
  z5.string(),
2012
- z5.number().finite(),
2024
+ z5.number(),
2013
2025
  z5.boolean(),
2014
2026
  z5.null(),
2015
2027
  z5.array(jsonValueSchema),
2016
- z5.record(jsonValueSchema)
2028
+ z5.record(z5.string(), jsonValueSchema)
2017
2029
  ])
2018
- );
2019
- var formSubmitMetadataSchema = z5.object({
2020
- form: z5.object({
2030
+ ).register(z5.globalRegistry, { id: "JsonSerializableValue" });
2031
+ var formSubmitMetadataSchema = z5.strictObject({
2032
+ form: z5.strictObject({
2021
2033
  id: z5.string(),
2022
- action: z5.string().nullable(),
2023
- fields: z5.array(
2024
- z5.object({
2025
- name: z5.string(),
2026
- type: z5.string(),
2027
- label: z5.string().nullable(),
2028
- value: jsonValueSchema
2029
- }).strict()
2030
- ).optional()
2031
- }).strict(),
2032
- page: z5.object({
2034
+ action: z5.nullable(z5.string()),
2035
+ fields: z5.optional(
2036
+ z5.array(
2037
+ z5.strictObject({
2038
+ name: z5.string(),
2039
+ type: z5.string(),
2040
+ label: z5.nullable(z5.string()),
2041
+ value: jsonValueSchema
2042
+ })
2043
+ )
2044
+ )
2045
+ }),
2046
+ page: z5.strictObject({
2033
2047
  path: z5.string()
2034
- }).strict()
2035
- }).strict();
2036
- var formSubmitConfigSchema = z5.object({}).strict();
2048
+ })
2049
+ });
2050
+ var formSubmitConfigSchema = z5.strictObject({});
2037
2051
 
2038
2052
  // ../tracking-core/src/events/multi-page-session.ts
2039
- import { z as z6 } from "zod";
2040
- var multiPageSessionMetadataSchema = z6.object({
2041
- page_count: z6.number().int().min(2),
2042
- page: z6.object({
2053
+ import * as z6 from "zod/mini";
2054
+ var multiPageSessionMetadataSchema = z6.strictObject({
2055
+ page_count: z6.int().check(z6.gte(2)),
2056
+ page: z6.strictObject({
2043
2057
  path: z6.string()
2044
- }).strict()
2045
- }).strict();
2046
- var multiPageSessionConfigSchema = z6.object({
2047
- pageThreshold: z6.number().int().min(2)
2048
- }).strict();
2058
+ })
2059
+ });
2060
+ var multiPageSessionConfigSchema = z6.strictObject({
2061
+ pageThreshold: z6.int().check(z6.gte(2))
2062
+ });
2049
2063
 
2050
2064
  // ../tracking-core/src/events/page-exit.ts
2051
- import { z as z7 } from "zod";
2052
- var pageExitMetadataSchema = z7.object({
2053
- dwell_ms: z7.number().int().min(0),
2065
+ import * as z7 from "zod/mini";
2066
+ var pageExitMetadataSchema = z7.strictObject({
2067
+ dwell_ms: z7.int().check(z7.gte(0)),
2054
2068
  // null = left without any scroll signal; floor is 0 so a valid 0% is never
2055
2069
  // rejected (a single bad field 422s the whole keepalive beacon batch).
2056
- max_scroll_percent: z7.number().int().min(0).max(100).nullable(),
2070
+ max_scroll_percent: z7.nullable(z7.int().check(z7.gte(0), z7.lte(100))),
2057
2071
  // The gating baseline: the fraction of the page visible at load with
2058
2072
  // zero scrolling — or, for pages that grew after the post-paint snapshot
2059
2073
  // (skeleton/streaming renders), the first-scroll position that
2060
2074
  // established it. null = page had no scrollable range, or the segment
2061
- // ended before the snapshot. `.optional()` is load-bearing: SDK builds
2075
+ // ended before the snapshot. Optionality is load-bearing: SDK builds
2062
2076
  // predating this field keep POSTing page_exit without the key —
2063
2077
  // requiring it would 422 whole keepalive beacon batches.
2064
- scroll_baseline_percent: z7.number().int().min(0).max(100).nullable().optional(),
2065
- page: z7.object({
2078
+ scroll_baseline_percent: z7.optional(z7.nullable(z7.int().check(z7.gte(0), z7.lte(100)))),
2079
+ page: z7.strictObject({
2066
2080
  path: z7.string()
2067
- }).strict()
2068
- }).strict();
2069
- var pageExitConfigSchema = z7.object({}).strict();
2081
+ })
2082
+ });
2083
+ var pageExitConfigSchema = z7.strictObject({});
2070
2084
 
2071
2085
  // ../tracking-core/src/events/phone-click.ts
2072
- import { z as z8 } from "zod";
2073
- var phoneClickMetadataSchema = z8.object({
2086
+ import * as z8 from "zod/mini";
2087
+ var phoneClickMetadataSchema = z8.strictObject({
2074
2088
  phone_number: z8.string(),
2075
- page: z8.object({
2089
+ page: z8.strictObject({
2076
2090
  path: z8.string()
2077
- }).strict(),
2078
- section: z8.string().nullable().optional()
2079
- }).strict();
2080
- var phoneClickConfigSchema = z8.object({
2081
- autoCapture: z8.object({
2082
- selector: z8.string().optional()
2083
- }).strict().optional()
2084
- }).strict();
2091
+ }),
2092
+ section: z8.optional(z8.nullable(z8.string()))
2093
+ });
2094
+ var phoneClickConfigSchema = z8.strictObject({
2095
+ autoCapture: z8.optional(
2096
+ z8.strictObject({
2097
+ selector: z8.optional(z8.string())
2098
+ })
2099
+ )
2100
+ });
2085
2101
 
2086
2102
  // ../tracking-core/src/events/scroll-depth.ts
2087
- import { z as z9 } from "zod";
2088
- var scrollDepthMetadataSchema = z9.object({
2089
- depth_percent: z9.number().int().min(1).max(100),
2090
- page: z9.object({
2103
+ import * as z9 from "zod/mini";
2104
+ var scrollDepthMetadataSchema = z9.strictObject({
2105
+ depth_percent: z9.int().check(z9.gte(1), z9.lte(100)),
2106
+ page: z9.strictObject({
2091
2107
  path: z9.string()
2092
- }).strict()
2093
- }).strict();
2094
- var scrollDepthConfigSchema = z9.object({
2095
- thresholds: z9.array(z9.number().int().min(1).max(100)).min(1)
2096
- }).strict();
2108
+ })
2109
+ });
2110
+ var scrollDepthConfigSchema = z9.strictObject({
2111
+ thresholds: z9.array(z9.int().check(z9.gte(1), z9.lte(100))).check(z9.minLength(1))
2112
+ });
2097
2113
 
2098
2114
  // ../tracking-core/src/events/specific-page-visit.ts
2099
- import { z as z10 } from "zod";
2115
+ import * as z10 from "zod/mini";
2100
2116
  var PAGE_IDENTITY_MAX_LENGTH = 64;
2101
2117
  var PAGE_IDENTITY_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
2102
- var pageIdentitySchema = z10.string().max(PAGE_IDENTITY_MAX_LENGTH).regex(PAGE_IDENTITY_PATTERN, {
2103
- message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2104
- });
2118
+ var pageIdentitySchema = z10.string().check(
2119
+ z10.maxLength(PAGE_IDENTITY_MAX_LENGTH),
2120
+ z10.regex(PAGE_IDENTITY_PATTERN, {
2121
+ message: "page identity must be lowercase snake_case, start with a letter, and contain at most 64 characters"
2122
+ })
2123
+ );
2105
2124
  var specificPageNameSchema = pageIdentitySchema;
2106
- var specificPageVisitMetadataSchema = z10.object({
2125
+ var specificPageVisitMetadataSchema = z10.strictObject({
2107
2126
  page_name: specificPageNameSchema,
2108
- page: z10.object({
2127
+ page: z10.strictObject({
2109
2128
  path: z10.string()
2110
- }).strict()
2111
- }).strict();
2112
- var specificPageVisitConfigSchema = z10.object({
2129
+ })
2130
+ });
2131
+ var specificPageVisitConfigSchema = z10.strictObject({
2113
2132
  pages: z10.array(
2114
- z10.object({
2133
+ z10.strictObject({
2115
2134
  name: specificPageNameSchema,
2116
2135
  pathPattern: z10.custom((value) => value instanceof RegExp, {
2117
2136
  message: "pathPattern must be a RegExp"
2118
2137
  })
2119
- }).strict()
2120
- ).min(1)
2121
- }).strict();
2138
+ })
2139
+ ).check(z10.minLength(1))
2140
+ });
2122
2141
 
2123
2142
  // ../tracking-core/src/events/time-on-site.ts
2124
- import { z as z11 } from "zod";
2125
- var timeOnSiteMetadataSchema = z11.object({
2126
- duration_ms: z11.number().int().nonnegative(),
2127
- page: z11.object({
2143
+ import * as z11 from "zod/mini";
2144
+ var timeOnSiteMetadataSchema = z11.strictObject({
2145
+ duration_ms: z11.int().check(z11.nonnegative()),
2146
+ page: z11.strictObject({
2128
2147
  path: z11.string()
2129
- }).strict()
2130
- }).strict();
2131
- var timeOnSiteConfigSchema = z11.object({
2132
- thresholdSeconds: z11.number().int().positive()
2133
- }).strict();
2148
+ })
2149
+ });
2150
+ var timeOnSiteConfigSchema = z11.strictObject({
2151
+ thresholdSeconds: z11.int().check(z11.positive())
2152
+ });
2134
2153
 
2135
2154
  // ../tracking-core/src/events/semantics.ts
2136
2155
  var EVENT_SEMANTICS = {
@@ -2289,7 +2308,7 @@ function createTypedClient(raw, registry, options = {}) {
2289
2308
  trackEvent(eventType, metadata, opts) {
2290
2309
  if (debug) {
2291
2310
  const def = getEventDefinition(eventType);
2292
- def.metadataSchema.parse(metadata);
2311
+ parse2(def.metadataSchema, metadata);
2293
2312
  }
2294
2313
  raw.trackEvent({
2295
2314
  eventType,
@@ -2778,117 +2797,6 @@ function attachPhoneClickCapture(client, config) {
2778
2797
  };
2779
2798
  }
2780
2799
 
2781
- // ../tracking-core/src/resources/sales/schema.ts
2782
- import { z as z12 } from "zod";
2783
- var SUPPORTED_CURRENCIES = ["USD", "CAD"];
2784
- var TRACKING_ENVIRONMENTS = ["production", "development"];
2785
- var currencySchema = z12.enum(SUPPORTED_CURRENCIES);
2786
- var centsSchema = z12.number().int().nonnegative();
2787
- var quantitySchema = z12.string().regex(/^\d+(\.\d{1,3})?$/);
2788
- var metadataSchema = z12.record(z12.unknown());
2789
- var saleItemSchema = z12.object({
2790
- external_item_id: z12.string().nullable().optional(),
2791
- name: z12.string().nullable().optional(),
2792
- category: z12.string().nullable().optional(),
2793
- quantity: quantitySchema,
2794
- unit_price_cents: centsSchema,
2795
- // Non-negativity validated on the wire — same contract as the other cents
2796
- // fields — and backstopped by the DB CHECK.
2797
- unit_cost_cents: centsSchema.nullable().optional()
2798
- }).strict();
2799
- var saleServiceSchema = z12.object({
2800
- service: z12.string(),
2801
- amount_cents: centsSchema
2802
- }).strict();
2803
- var customerNameSchema = z12.string().max(200);
2804
- var customerPhoneSchema = z12.string().max(64);
2805
- var customerEmailSchema = z12.string().max(320).email();
2806
- function refineServiceXor(val, ctx, { requireAmount }) {
2807
- if (val.services != null) {
2808
- if (val.service != null) {
2809
- ctx.addIssue({
2810
- code: z12.ZodIssueCode.custom,
2811
- message: "pass either `service` or `services`, not both",
2812
- path: ["services"]
2813
- });
2814
- }
2815
- if (val.services.length === 0) {
2816
- ctx.addIssue({
2817
- code: z12.ZodIssueCode.custom,
2818
- message: "`services` must not be empty",
2819
- path: ["services"]
2820
- });
2821
- }
2822
- const keys = val.services.map((s) => s.service);
2823
- if (new Set(keys).size !== keys.length) {
2824
- ctx.addIssue({
2825
- code: z12.ZodIssueCode.custom,
2826
- message: "`services` must not list the same service more than once",
2827
- path: ["services"]
2828
- });
2829
- }
2830
- if (val.amount_total_cents != null) {
2831
- const sum = val.services.reduce((acc, s) => acc + s.amount_cents, 0);
2832
- if (val.amount_total_cents !== sum) {
2833
- ctx.addIssue({
2834
- code: z12.ZodIssueCode.custom,
2835
- message: "amount_total_cents must equal the sum of the services amounts (omit it to derive it automatically)",
2836
- path: ["amount_total_cents"]
2837
- });
2838
- }
2839
- }
2840
- } else if (requireAmount && val.amount_total_cents == null) {
2841
- ctx.addIssue({
2842
- code: z12.ZodIssueCode.custom,
2843
- message: "amount_total_cents is required unless `services` is provided",
2844
- path: ["amount_total_cents"]
2845
- });
2846
- }
2847
- }
2848
- var saleCreateSchema = z12.object({
2849
- external_id: z12.string().nullable().optional(),
2850
- description: z12.string().nullable().optional(),
2851
- service: z12.string().nullable().optional(),
2852
- services: z12.array(saleServiceSchema).nullable().optional(),
2853
- currency: currencySchema,
2854
- // Optional only because the plural `services` form derives it from the sum
2855
- // (see refineServiceXor); the singular/serviceless path still requires it.
2856
- amount_total_cents: centsSchema.nullable().optional(),
2857
- occurred_at: z12.string().datetime(),
2858
- environment: z12.enum(TRACKING_ENVIRONMENTS).default("production"),
2859
- items: z12.array(saleItemSchema).default([]),
2860
- metadata: metadataSchema.nullable().optional(),
2861
- customer_name: customerNameSchema.nullable().optional(),
2862
- customer_phone: customerPhoneSchema.nullable().optional(),
2863
- customer_email: customerEmailSchema.nullable().optional(),
2864
- // CASL consent attestation: the customer agreed to receive SMS. Recorded
2865
- // with a timestamp server-side; every SMS send path gates on it.
2866
- //
2867
- // Tri-state: omit it (or send null) to let the server apply the business's
2868
- // configured default-opt-in policy, honouring a returning customer's
2869
- // remembered preference. Send an explicit boolean to assert consent state
2870
- // yourself — `false` records a deliberate opt-out.
2871
- sms_consent: z12.boolean().nullable().optional()
2872
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: true }));
2873
- var saleUpdateSchema = z12.object({
2874
- description: z12.string().nullable().optional(),
2875
- service: z12.string().nullable().optional(),
2876
- services: z12.array(saleServiceSchema).nullable().optional(),
2877
- currency: currencySchema.optional(),
2878
- amount_total_cents: centsSchema.optional(),
2879
- occurred_at: z12.string().datetime().optional(),
2880
- items: z12.array(saleItemSchema).optional(),
2881
- metadata: metadataSchema.nullable().optional(),
2882
- customer_name: customerNameSchema.nullable().optional(),
2883
- // Re-attest when changing a filler-looking name; the server clears the
2884
- // prior attestation whenever `customer_name` changes.
2885
- customer_name_placeholder_confirmed: z12.boolean().optional(),
2886
- customer_phone: customerPhoneSchema.nullable().optional(),
2887
- customer_email: customerEmailSchema.nullable().optional(),
2888
- // NOT NULL server-side: omit to leave unchanged (explicit null is rejected).
2889
- sms_consent: z12.boolean().optional()
2890
- }).strict().superRefine((val, ctx) => refineServiceXor(val, ctx, { requireAmount: false }));
2891
-
2892
2800
  // src/hooks.ts
2893
2801
  function useGclid() {
2894
2802
  const [gclid, setGclid] = useState(null);
@@ -3229,7 +3137,7 @@ function GoogleAdsTracking(props) {
3229
3137
  import { usePathname, useSearchParams } from "next/navigation";
3230
3138
 
3231
3139
  // package.json
3232
- var version = "0.27.0";
3140
+ var version = "1.0.0";
3233
3141
 
3234
3142
  // src/factory.tsx
3235
3143
  import {